Package org.apache.zookeeper.server
Class SessionTrackerImpl
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.zookeeper.server.ZooKeeperThread
-
- org.apache.zookeeper.server.ZooKeeperCriticalThread
-
- org.apache.zookeeper.server.SessionTrackerImpl
-
- All Implemented Interfaces:
java.lang.Runnable,SessionTracker
public class SessionTrackerImpl extends ZooKeeperCriticalThread implements SessionTracker
This is a full featured SessionTracker. It tracks session in grouped by tick interval. It always rounds up the tick interval to provide a sort of grace period. Sessions are thus expired in batches made up of sessions that expire in a given interval.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSessionTrackerImpl.SessionImpl-
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
-
Nested classes/interfaces inherited from interface org.apache.zookeeper.server.SessionTracker
SessionTracker.Session, SessionTracker.SessionExpirer
-
-
Constructor Summary
Constructors Constructor Description SessionTrackerImpl(SessionTracker.SessionExpirer expirer, java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> sessionsWithTimeout, int tickTime, long sid, ZooKeeperServerListener listener)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSession(long id, int sessionTimeout)voidcheckSession(long sessionId, java.lang.Object owner)longcreateSession(int sessionTimeout)voiddumpSessions(java.io.PrintWriter pwriter)Text dump of session information, suitable for debugging.static longinitializeNextSession(long id)voidremoveSession(long sessionId)voidrun()voidsetOwner(long id, java.lang.Object owner)voidsetSessionClosing(long sessionId)Mark that the session is in the process of closing.voidshutdown()java.lang.StringtoString()booleantouchSession(long sessionId, int timeout)-
Methods inherited from class org.apache.zookeeper.server.ZooKeeperCriticalThread
handleException
-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
-
-
-
Constructor Detail
-
SessionTrackerImpl
public SessionTrackerImpl(SessionTracker.SessionExpirer expirer, java.util.concurrent.ConcurrentHashMap<java.lang.Long,java.lang.Integer> sessionsWithTimeout, int tickTime, long sid, ZooKeeperServerListener listener)
-
-
Method Detail
-
initializeNextSession
public static long initializeNextSession(long id)
-
dumpSessions
public void dumpSessions(java.io.PrintWriter pwriter)
Description copied from interface:SessionTrackerText dump of session information, suitable for debugging.- Specified by:
dumpSessionsin interfaceSessionTracker- Parameters:
pwriter- the output writer
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Thread
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
touchSession
public boolean touchSession(long sessionId, int timeout)- Specified by:
touchSessionin interfaceSessionTracker- Returns:
- false if session is no longer active
-
setSessionClosing
public void setSessionClosing(long sessionId)
Description copied from interface:SessionTrackerMark that the session is in the process of closing.- Specified by:
setSessionClosingin interfaceSessionTracker
-
removeSession
public void removeSession(long sessionId)
- Specified by:
removeSessionin interfaceSessionTracker
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceSessionTracker
-
createSession
public long createSession(int sessionTimeout)
- Specified by:
createSessionin interfaceSessionTracker
-
addSession
public void addSession(long id, int sessionTimeout)- Specified by:
addSessionin interfaceSessionTracker
-
checkSession
public void checkSession(long sessionId, java.lang.Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException- Specified by:
checkSessionin interfaceSessionTracker- Throws:
KeeperException.SessionExpiredExceptionKeeperException.SessionMovedException
-
setOwner
public void setOwner(long id, java.lang.Object owner) throws KeeperException.SessionExpiredException- Specified by:
setOwnerin interfaceSessionTracker- Throws:
KeeperException.SessionExpiredException
-
-