/** * Do a heartbeat action */ @Override public void onSessionIdle(Session session) { checkHeartBeat(session); }
public void setEnableHeartBeat(boolean enableHeartBeat) { this.memcachedHandler.setEnableHeartBeat(enableHeartBeat); }
private final void startConnector() throws IOException { if (this.shutdown) { this.shutdown = false; this.connector.start(); this.memcachedHandler.start(); if (AddrUtil.isEnableShutDownHook()) { this.shutdownHookThread = new Thread() { @Override public void run() { try { XMemcachedClient.this.isHutdownHookCalled = true; XMemcachedClient.this.shutdown(); } catch (IOException e) { log.error("Shutdown XMemcachedClient error", e); } } }; Runtime.getRuntime().addShutdownHook(this.shutdownHookThread); } } }
/** * Check if have to reconnect on session closed */ @Override public final void onSessionClosed(Session session) { this.client.getConnector().removeSession(session); // Clear write queue to release noreply operations. ((AbstractSession) session).clearWriteQueue(); MemcachedTCPSession memcachedSession = (MemcachedTCPSession) session; // destroy memached session memcachedSession.destroy(); if (this.client.getConnector().isStarted() && memcachedSession.isAllowReconnect()) { this.reconnect(memcachedSession); } for (MemcachedClientStateListener listener : this.client.getStateListeners()) { listener.onDisconnected(this.client, session.getRemoteSocketAddress()); } }
public final void shutdown() throws IOException { if (this.shutdown) { return; } this.shutdown0(); this.shutdown = true; this.connector.shuttingDown(); this.connector.quitAllSessions(); this.connector.stop(); this.memcachedHandler.stop(); XMemcachedMbeanServer.getInstance().shutdown(); if (AddrUtil.isEnableShutDownHook() && !this.isHutdownHookCalled) { try { Runtime.getRuntime().removeShutdownHook(this.shutdownHookThread); } catch (Exception e) { // ignore; } } }
this.connector = this.newConnector(bufferAllocator, configuration, this.sessionLocator, this.commandFactory, this.connectionPoolSize, this.maxQueuedNoReplyOperations); this.memcachedHandler = new MemcachedHandler(this); this.connector.setHandler(this.memcachedHandler); this.connector.setCodecFactory(new MemcachedCodecFactory());
/** * Check if have to reconnect on session closed */ @Override public final void onSessionClosed(Session session) { this.client.getConnector().removeSession(session); // Clear write queue to release noreply operations. ((AbstractSession) session).clearWriteQueue(); MemcachedTCPSession memcachedSession = (MemcachedTCPSession) session; // destroy memached session memcachedSession.destroy(); if (this.client.getConnector().isStarted() && memcachedSession.isAllowReconnect()) { this.reconnect(memcachedSession); } for (MemcachedClientStateListener listener : this.client.getStateListeners()) { listener.onDisconnected(this.client, session.getRemoteSocketAddress()); } }
public final void shutdown() throws IOException { if (this.shutdown) { return; } this.shutdown0(); this.shutdown = true; this.connector.shuttingDown(); this.connector.quitAllSessions(); this.connector.stop(); this.memcachedHandler.stop(); XMemcachedMbeanServer.getInstance().shutdown(); if (AddrUtil.isEnableShutDownHook() && !this.isHutdownHookCalled) { try { Runtime.getRuntime().removeShutdownHook(this.shutdownHookThread); } catch (Exception e) { // ignore; } } }
this.connector = this.newConnector(bufferAllocator, configuration, this.sessionLocator, this.commandFactory, this.connectionPoolSize, this.maxQueuedNoReplyOperations); this.memcachedHandler = new MemcachedHandler(this); this.connector.setHandler(this.memcachedHandler); this.connector.setCodecFactory(new MemcachedCodecFactory());
/** * Do a heartbeat action */ @Override public void onSessionIdle(Session session) { checkHeartBeat(session); }
public void setEnableHeartBeat(boolean enableHeartBeat) { this.memcachedHandler.setEnableHeartBeat(enableHeartBeat); }
private final void startConnector() throws IOException { if (this.shutdown) { this.shutdown = false; this.connector.start(); this.memcachedHandler.start(); if (AddrUtil.isEnableShutDownHook()) { this.shutdownHookThread = new Thread() { @Override public void run() { try { XMemcachedClient.this.isHutdownHookCalled = true; XMemcachedClient.this.shutdown(); } catch (IOException e) { log.error("Shutdown XMemcachedClient error", e); } } }; Runtime.getRuntime().addShutdownHook(this.shutdownHookThread); } } }