Class MemcachedHandler
java.lang.Object
com.google.code.yanf4j.core.impl.HandlerAdapter
net.rubyeye.xmemcached.impl.MemcachedHandler
- All Implemented Interfaces:
Handler
Memcached Session Handler,used for dispatching commands and session's lifecycle management
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MemcachedClientstatic final IoBufferprivate booleanprivate static final String(package private) final longprivate ExecutorServiceprivate final MemcachedSessionConnectListenerprivate static final org.slf4j.Loggerprivate static final intprivate static final intprivate final StatisticsHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckHeartBeat(Session session) voidonExceptionCaught(Session session, Throwable throwable) final voidonMessageReceived(Session session, Object msg) On receive message from memcached serverfinal voidonMessageSent(Session session, Object msg) put command which have been sent to queuefinal voidonSessionClosed(Session session) Check if have to reconnect on session closedvoidonSessionIdle(Session session) Do a heartbeat actionvoidonSessionStarted(Session session) On session startedprotected voidreconnect(MemcachedTCPSession session) Auto reconect to memcached servervoidsetEnableHeartBeat(boolean enableHeartBeat) voidstart()voidstop()Methods inherited from class HandlerAdapter
onSessionConnected, onSessionCreated, onSessionExpired
-
Field Details
-
MAX_HEARTBEAT_THREADS
private static final int MAX_HEARTBEAT_THREADS -
statisticsHandler
-
heartBeatThreadPool
-
listener
-
client
-
log
private static final org.slf4j.Logger log -
enableHeartBeat
private volatile boolean enableHeartBeat -
EMPTY_BUF
-
HEART_BEAT_FAIL_COUNT_ATTR
- See Also:
-
MAX_HEART_BEAT_FAIL_COUNT
private static final int MAX_HEART_BEAT_FAIL_COUNT -
HEARTBEAT_PERIOD
final long HEARTBEAT_PERIOD
-
-
Constructor Details
-
MemcachedHandler
-
-
Method Details
-
onMessageReceived
On receive message from memcached server- Specified by:
onMessageReceivedin interfaceHandler- Overrides:
onMessageReceivedin classHandlerAdapter
-
setEnableHeartBeat
public void setEnableHeartBeat(boolean enableHeartBeat) -
onMessageSent
put command which have been sent to queue- Specified by:
onMessageSentin interfaceHandler- Overrides:
onMessageSentin classHandlerAdapter
-
onExceptionCaught
- Specified by:
onExceptionCaughtin interfaceHandler- Overrides:
onExceptionCaughtin classHandlerAdapter
-
onSessionStarted
On session started- Specified by:
onSessionStartedin interfaceHandler- Overrides:
onSessionStartedin classHandlerAdapter
-
onSessionClosed
Check if have to reconnect on session closed- Specified by:
onSessionClosedin interfaceHandler- Overrides:
onSessionClosedin classHandlerAdapter
-
onSessionIdle
Do a heartbeat action- Specified by:
onSessionIdlein interfaceHandler- Overrides:
onSessionIdlein classHandlerAdapter
-
checkHeartBeat
-
reconnect
Auto reconect to memcached server- Parameters:
session-
-
stop
public void stop() -
start
public void start()
-