/** * Cancel the current {@link SelectionKey} */ public void cancelKey(SelectionKey key){ selectorHandler.getSelectionKeyHandler().cancel(key); }
/** * Cancel the current {@link SelectionKey} */ public void cancelKey(SelectionKey key){ selectorHandler.getSelectionKeyHandler().cancel(key); }
@Override public void removeRemotePeer(String instanceName) { for (Map.Entry<SelectionKey, String> entry : selectionKeyMap.entrySet()) { if (entry.getValue().equals(instanceName)) { if (getLogger().isLoggable(Level.FINE)) { getLogger().log(Level.FINE, "remove selection key for instance name: " + entry.getValue() + " selectionKey:" + entry.getKey()); } tcpSelectorHandler.getSelectionKeyHandler().cancel(entry.getKey()); selectionKeyMap.remove(entry.getKey()); } } }
/** * Close the underlying connection. */ public void close() throws IOException{ if (socketChannel != null){ if (selectorHandler != null){ SelectionKey key = socketChannel.keyFor(selectorHandler.getSelector()); if (key == null) return; selectorHandler.getSelectionKeyHandler().cancel(key); } else { socketChannel.close(); } } if (controller != null && isStandalone){ controller.stop(); controller = null; } isStandalone = false; isConnected = false; connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; }