private void shutdownChannels () { Iterator iter = channels.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); WeakReference ref = (WeakReference) entry.getValue(); ISOChannel c = (ISOChannel) ref.get (); if (c != null) { try { c.disconnect (); fireEvent(new ISOServerClientDisconnectEvent(this, c)); } catch (IOException e) { Logger.log (new LogEvent (this, "shutdown", e)); } } } } private void purgeChannels () {
protected void disconnect () { // do not synchronize on this as both Sender and Receiver can deadlock against a thread calling stop() synchronized (disconnectLock) { try { SpaceUtil.wipe(sp, ready); channel.disconnect(); } catch (Exception e) { getLog().warn("disconnect", e); } } } public synchronized void setHost (String host) {
protected void disconnect () { try { while (sp.inp (ready) != null) ; channel.disconnect (); } catch (IOException e) { Logger.log ( new LogEvent ( ISOChannelAdaptor.this, "disconnect", e ) ); } } private String get (String prop) throws ConfigurationException
public synchronized void disconnect () throws IOException { current = null; LogEvent evt = new LogEvent (this, "disconnect"); for (Object aPool : pool) { try { ISOChannel c = (ISOChannel) aPool; c.disconnect(); } catch (IOException e) { evt.addMessage(e); } } Logger.log (evt); } public synchronized void reconnect() throws IOException {
private void disconnect (ISOChannel channel) { try { if (getConnectedCount() <= 1) SpaceUtil.wipe(sp, ready); channel.disconnect (); } catch (IOException e) { getLog().warn ("disconnect", e); } } private void disconnectAll() {
/** * ISOMUXs usually calls connect() on the underlying ISOChannel<br> * You can prevent this behaveour by passing a false value. * @param connect false to prevent connection (default true) */ public void setConnect (boolean connect) { this.doConnect = connect; if (!connect && isConnected()) { channel.setUsable(false); try { channel.disconnect(); } catch (IOException e) { Logger.log (new LogEvent(this, "set-connect", e)); } synchronized(this) { this.notify(); } } } /**
channel.disconnect(); } catch (IOException e) { }
@Test public void stopCanWaitForWorkersEvenWhenSenderBlockedTryingToConnect() throws Exception { // Think a link where the other ends plays the client role. Eg a BaseChannel with a serverSocket. // So connect() calls socket.accept(). If no client connects accept() blocks forever. // Ensures disconnect() is called on stop() regardless of channel.isConnected() return value. ISOChannel channel = mock(ISOChannel.class); ThreadTrap trap = new ThreadTrap(SENDER_THREAD_NAME); when(channel.isConnected()).thenReturn(false); trap.catchVictim().when(channel).connect(); trap.release().when(channel).disconnect(); channelAdaptor = configureAndStart(new ChannelAdaptorWithoutQ2(channel)); waitForSenderAndReceiverToStart(); assertThat("Sender did not call connect()", trap.catchesVictim(), is(true)); assertCallToStopCompletes(1); }
channel.send (m); m = channel.receive(); channel.disconnect(); if (handBack != null) m.merge (handBack); } finally { try { channel.disconnect(); } catch (Exception e) { getLog().warn ("channel-worker-"+id, e.getMessage ());
channel.send(req); ISOMsg rsp = channel.receive(); channel.disconnect(); if (handBack != null) channel.disconnect();
channel.disconnect();