/** * Adds a connection listener that will be notified if/when the connection to the server fails * while the client is idle (no calls being made). The current behavior is to ping the server * periodically. Various parameters may be specified in metadata. * * @see org.jboss.remoting.ConnectionValidator */ public void addConnectionListener(ConnectionListener listener, Map metadata) { if (invoker == null) { throw new RuntimeException("Can not add connection listener to remoting client " + "until client has been connected."); } else { // if local, then no point in having connection listener if (invoker instanceof LocalClientInvoker) { return; } } if (connectionValidator == null) { connectionValidator = new ConnectionValidator(this, metadata); } connectionValidator.addConnectionListener(listener); }
public void stop() { if (stopped) { return; } doStop(); }
public ConnectionValidator(Client client, Map metadata) { this.client = client; this.pingPeriod = DEFAULT_PING_PERIOD; this.listeners = new ArrayList(); this.stopped = false; this.metadata = new HashMap(metadata); getParameters(client, metadata); log.debug(this + " created"); }
isValid = doCheckConnectionWithLease(); isValid = doCheckConnection(clientInvoker); notifyListeners(new Exception("Could not connect to server!")); notifyListeners(thr); cancel();
Map configMap = createPingConfig(config, null); ClientInvoker innerClientInvoker = null; pingWorked = doCheckConnection(innerClientInvoker);
private void getParameters(Client client, Map metadata) { getParametersFromMap(client.getConfiguration()); getParametersFromMap(metadata); ClientInvoker clientInvoker = client.getInvoker(); if (clientInvoker instanceof MicroRemoteClientInvoker) { invokerSessionId = ((MicroRemoteClientInvoker) clientInvoker).getSessionId(); } else { throw new RuntimeException("creating a ConnectionValidator on a local connection"); } }
private void start() { configMap = createPingConfig(client.getConfiguration(), metadata); log.debug(this + " timeout: " + configMap.get(ServerInvoker.TIMEOUT)); log.debug(this + " ping retries: " + configMap.get("NumberOfCallRetries")); log.debug(this + " connection retries: " + configMap.get("NumberOfRetries")); locator = client.getInvoker().getLocator(); try { clientInvoker = InvokerRegistry.createClientInvoker(locator, configMap); } catch (Exception e) { log.debug("Unable to create client invoker for locator: " + locator); throw new RuntimeException("Unable to create client invoker for locator: " + locator, e); } if (!clientInvoker.isConnected()) { if (trace) { log.trace("inner client invoker not connected, connecting ..."); } clientInvoker.connect(); } TimerUtil.schedule(this, pingPeriod); stopped = false; log.debug(this + " started"); }
locator = invokerMetadata.getInvokerLocator(); boolean isValid = ConnectionValidator.checkConnection(locator, config); if(isValid)
public boolean cancel() { return doStop(); }
public ConnectionValidator(Client client, long pingPeriod) { this.client = client; this.pingPeriod = pingPeriod; this.listeners = new ArrayList(); this.stopped = false; getParameters(client, new HashMap()); log.debug(this + " created"); }