Class LeaderSessionTracker
- java.lang.Object
- 
- org.apache.zookeeper.server.quorum.UpgradeableSessionTracker
- 
- org.apache.zookeeper.server.quorum.LeaderSessionTracker
 
 
- 
- All Implemented Interfaces:
- SessionTracker
 
 public class LeaderSessionTracker extends UpgradeableSessionTracker The leader session tracker tracks local and global sessions on the leader.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.zookeeper.server.SessionTrackerSessionTracker.Session, SessionTracker.SessionExpirer
 
- 
 - 
Field Summary- 
Fields inherited from class org.apache.zookeeper.server.quorum.UpgradeableSessionTrackerlocalSessionsEnabled, localSessionTracker
 
- 
 - 
Constructor SummaryConstructors Constructor Description LeaderSessionTracker(SessionTracker.SessionExpirer expirer, ConcurrentMap<Long,Integer> sessionsWithTimeouts, int tickTime, long id, boolean localSessionsEnabled, ZooKeeperServerListener listener)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete 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 sessionId, int sessionTimeout)Synchronized on this to avoid race condition of adding a local session after committed global session, which may cause the same session being tracked on this server and leader.longcreateSession(int sessionTimeout)voiddumpSessions(PrintWriter pwriter)Text dump of session information, suitable for debugging.static longgetServerIdFromSessionId(long sessionId)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 IDsbooleanisGlobalSession(long sessionId)voidremoveSession(long sessionId)voidsetOwner(long sessionId, Object owner)voidsetSessionClosing(long sessionId)Mark that the session is in the process of closing.voidshutdown()voidstart()booleantouchSession(long sessionId, int sessionTimeout)booleantrackSession(long sessionId, int sessionTimeout)Track the session expire, not add to ZkDb.- 
Methods inherited from class org.apache.zookeeper.server.quorum.UpgradeableSessionTrackercreateLocalSessionTracker, finishedUpgrading, getLocalSessionCount, isLocalSession, isLocalSessionsEnabled, isTrackingSession, isUpgradingSession, localSessions, removeLocalSession, upgradeSession
 
- 
 
- 
- 
- 
Constructor Detail- 
LeaderSessionTrackerpublic LeaderSessionTracker(SessionTracker.SessionExpirer expirer, ConcurrentMap<Long,Integer> sessionsWithTimeouts, int tickTime, long id, boolean localSessionsEnabled, ZooKeeperServerListener listener) 
 
- 
 - 
Method Detail- 
removeSessionpublic void removeSession(long sessionId) 
 - 
startpublic void start() - Overrides:
- startin class- UpgradeableSessionTracker
 
 - 
shutdownpublic void shutdown() 
 - 
isGlobalSessionpublic boolean isGlobalSession(long sessionId) - Specified by:
- isGlobalSessionin class- UpgradeableSessionTracker
 
 - 
trackSessionpublic boolean trackSession(long sessionId, int sessionTimeout)Description copied from interface:SessionTrackerTrack the session expire, not add to ZkDb.- Parameters:
- sessionId- sessionId
- sessionTimeout- sessionTimeout
- Returns:
- whether the session was newly tracked (if false, already tracked)
 
 - 
commitSessionpublic boolean commitSession(long sessionId, int sessionTimeout)Synchronized on this to avoid race condition of adding a local session after committed global session, which may cause the same session being tracked on this server and leader.- Parameters:
- sessionId- sessionId
- sessionTimeout- sessionTimeout
- Returns:
- whether the session was newly added (if false, already existed)
 
 - 
touchSessionpublic boolean touchSession(long sessionId, int sessionTimeout)- Returns:
- false if session is no longer active
 
 - 
createSessionpublic long createSession(int sessionTimeout) 
 - 
getServerIdFromSessionIdpublic static long getServerIdFromSessionId(long sessionId) 
 - 
checkSessionpublic void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException, KeeperException.UnknownSessionExceptionDescription copied from interface:SessionTrackerChecks 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
 - 
checkGlobalSessionpublic void checkGlobalSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedExceptionDescription copied from interface:SessionTrackerStrictly check that a given session is a global session or not- Specified by:
- checkGlobalSessionin interface- SessionTracker
- Overrides:
- checkGlobalSessionin class- UpgradeableSessionTracker
- Throws:
- KeeperException.SessionExpiredException
- KeeperException.SessionMovedException
 
 - 
setOwnerpublic void setOwner(long sessionId, Object owner) throws KeeperException.SessionExpiredException
 - 
dumpSessionspublic void dumpSessions(PrintWriter pwriter) Description copied from interface:SessionTrackerText dump of session information, suitable for debugging.- Parameters:
- pwriter- the output writer
 
 - 
setSessionClosingpublic void setSessionClosing(long sessionId) Description copied from interface:SessionTrackerMark that the session is in the process of closing.
 - 
getSessionExpiryMappublic Map<Long,Set<Long>> getSessionExpiryMap() Description copied from interface:SessionTrackerReturns a mapping of time to session IDs that expire at that time.
 - 
globalSessionspublic Set<Long> globalSessions() Description copied from interface:SessionTrackerGet a set of global session IDs
 
- 
 
-