Package org.apache.zookeeper.server
Interface SessionTracker
-
- All Known Implementing Classes:
LeaderSessionTracker,LearnerSessionTracker,LocalSessionTracker,SessionTrackerImpl,UpgradeableSessionTracker
public interface SessionTrackerThis is the basic interface that ZooKeeperServer uses to track sessions. The standalone and leader ZooKeeperServer use the same SessionTracker. The FollowerZooKeeperServer uses a SessionTracker which is basically a simple shell to track information to be forwarded to the leader.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceSessionTracker.Sessionstatic interfaceSessionTracker.SessionExpirer
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcheckGlobalSession(long sessionId, Object owner)Strictly check that a given session is a global session or notvoidcheckSession(long sessionId, Object owner)Checks whether the SessionTracker is aware of this session, the session is still active, and the owner matches.booleancommitSession(long id, int to)Add the session to the local session map or global one in zkDB.longcreateSession(int sessionTimeout)voiddumpSessions(PrintWriter pwriter)Text dump of session information, suitable for debugging.longgetLocalSessionCount()If this session tracker supports local sessions, return how many.Map<Long,Set<Long>>getSessionExpiryMap()Returns a mapping of time to session IDs that expire at that time.Set<Long>globalSessions()Get a set of global session IDsbooleanisLocalSessionsEnabled()booleanisTrackingSession(long sessionId)Set<Long>localSessions()Get a set of local session IDsvoidremoveSession(long sessionId)voidsetOwner(long id, Object owner)voidsetSessionClosing(long sessionId)Mark that the session is in the process of closing.voidshutdown()booleantouchSession(long sessionId, int sessionTimeout)booleantrackSession(long id, int to)Track the session expire, not add to ZkDb.
-
-
-
Method Detail
-
createSession
long createSession(int sessionTimeout)
-
trackSession
boolean trackSession(long id, int to)Track the session expire, not add to ZkDb.- Parameters:
id- sessionIdto- sessionTimeout- Returns:
- whether the session was newly tracked (if false, already tracked)
-
commitSession
boolean commitSession(long id, int to)Add the session to the local session map or global one in zkDB.- Parameters:
id- sessionIdto- sessionTimeout- Returns:
- whether the session was newly added (if false, already existed)
-
touchSession
boolean touchSession(long sessionId, int sessionTimeout)- Parameters:
sessionId-sessionTimeout-- Returns:
- false if session is no longer active
-
setSessionClosing
void setSessionClosing(long sessionId)
Mark that the session is in the process of closing.- Parameters:
sessionId-
-
shutdown
void shutdown()
-
removeSession
void removeSession(long sessionId)
- Parameters:
sessionId-
-
isTrackingSession
boolean isTrackingSession(long sessionId)
- Parameters:
sessionId-- Returns:
- whether or not the SessionTracker is aware of this session
-
checkSession
void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException, KeeperException.UnknownSessionExceptionChecks whether the SessionTracker is aware of this session, the session is still active, and the owner matches. If the owner wasn't previously set, this sets the owner of the session. UnknownSessionException should never been thrown to the client. It is only used internally to deal with possible local session from other machine- Parameters:
sessionId-owner-- Throws:
KeeperException.SessionExpiredExceptionKeeperException.SessionMovedExceptionKeeperException.UnknownSessionException
-
checkGlobalSession
void checkGlobalSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedExceptionStrictly check that a given session is a global session or not- Parameters:
sessionId-owner-- Throws:
KeeperException.SessionExpiredExceptionKeeperException.SessionMovedException
-
setOwner
void setOwner(long id, Object owner) throws KeeperException.SessionExpiredException
-
dumpSessions
void dumpSessions(PrintWriter pwriter)
Text dump of session information, suitable for debugging.- Parameters:
pwriter- the output writer
-
getSessionExpiryMap
Map<Long,Set<Long>> getSessionExpiryMap()
Returns a mapping of time to session IDs that expire at that time.
-
getLocalSessionCount
long getLocalSessionCount()
If this session tracker supports local sessions, return how many. otherwise returns 0;
-
isLocalSessionsEnabled
boolean isLocalSessionsEnabled()
-
-