public void shutdown() { for (ClientEndpoint endpoint : endpoints.values()) { try { endpoint.destroy(); } catch (LoginException e) { logger.finest(e.getMessage()); } try { final Connection conn = endpoint.getConnection(); if (conn.live()) { conn.close(); } } catch (Exception e) { logger.finest(e); } } endpoints.clear(); }
private void destroyEndpoint(ClientEndpoint endpoint, boolean closeImmediately) { if (endpoint != null) { logger.info("Destroying " + endpoint); try { endpoint.destroy(); } catch (LoginException e) { logger.warning(e); } final Connection connection = endpoint.getConnection(); if (closeImmediately) { try { connection.close(); } catch (Throwable e) { logger.warning("While closing client connection: " + connection, e); } } else { nodeEngine .getExecutionService() .schedule( new Runnable() { public void run() { if (connection.live()) { try { connection.close(); } catch (Throwable e) { logger.warning("While closing client connection: " + e.toString()); } } } }, 1111, TimeUnit.MILLISECONDS); } sendClientEvent(endpoint); } }
void removeEndpoint(final ClientEndpoint endpoint, boolean closeImmediately) { endpoints.remove(endpoint.getConnection()); LOGGER.info("Destroying " + endpoint); try { endpoint.destroy(); } catch (LoginException e) { LOGGER.warning(e); } final Connection connection = endpoint.getConnection(); if (closeImmediately) { try { connection.close(); } catch (Throwable e) { LOGGER.warning("While closing client connection: " + connection, e); } } else { nodeEngine .getExecutionService() .schedule( new Runnable() { public void run() { if (connection.live()) { try { connection.close(); } catch (Throwable e) { LOGGER.warning("While closing client connection: " + e.toString()); } } } }, DESTROY_ENDPOINT_DELAY_MS, TimeUnit.MILLISECONDS); } clientEngine.sendClientEvent(endpoint); }