public class SessionTrackerImpl extends ZooKeeperCriticalThread implements SessionTracker
| Modifier and Type | Class and Description |
|---|---|
static class |
SessionTrackerImpl.SessionImpl |
Thread.State, Thread.UncaughtExceptionHandlerSessionTracker.Session, SessionTracker.SessionExpirer| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentHashMap<Long,SessionTrackerImpl.SessionImpl> |
sessionsById |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
SessionTrackerImpl(SessionTracker.SessionExpirer expirer,
ConcurrentMap<Long,Integer> sessionsWithTimeout,
int tickTime,
long serverId,
ZooKeeperServerListener listener) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkGlobalSession(long sessionId,
Object owner)
Strictly check that a given session is a global session or not
|
void |
checkSession(long sessionId,
Object owner)
Checks whether the SessionTracker is aware of this session, the session
is still active, and the owner matches.
|
boolean |
commitSession(long id,
int sessionTimeout)
Add the session to the local session map or global one in zkDB.
|
long |
createSession(int sessionTimeout) |
void |
dumpSessions(PrintWriter pwriter)
Text dump of session information, suitable for debugging.
|
long |
getLocalSessionCount()
If this session tracker supports local sessions, return how many.
|
Map<Long,Set<Long>> |
getSessionExpiryMap()
Returns a mapping from time to session IDs of sessions expiring at that time.
|
int |
getSessionTimeout(long sessionId) |
static long |
initializeNextSessionId(long id)
Generates an initial sessionId.
|
boolean |
isLocalSessionsEnabled() |
boolean |
isTrackingSession(long sessionId) |
void |
removeSession(long sessionId) |
void |
run() |
void |
setOwner(long id,
Object owner) |
void |
setSessionClosing(long sessionId)
Mark that the session is in the process of closing.
|
void |
shutdown() |
String |
toString() |
boolean |
touchSession(long sessionId,
int timeout) |
boolean |
trackSession(long id,
int sessionTimeout)
Track the session expire, not add to ZkDb.
|
handleExceptionactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yieldprotected final ConcurrentHashMap<Long,SessionTrackerImpl.SessionImpl> sessionsById
public SessionTrackerImpl(SessionTracker.SessionExpirer expirer, ConcurrentMap<Long,Integer> sessionsWithTimeout, int tickTime, long serverId, ZooKeeperServerListener listener)
public static long initializeNextSessionId(long id)
id - server Idpublic void dumpSessions(PrintWriter pwriter)
SessionTrackerdumpSessions in interface SessionTrackerpwriter - the output writerpublic Map<Long,Set<Long>> getSessionExpiryMap()
getSessionExpiryMap in interface SessionTrackerpublic boolean touchSession(long sessionId,
int timeout)
touchSession in interface SessionTrackerpublic int getSessionTimeout(long sessionId)
public void setSessionClosing(long sessionId)
SessionTrackersetSessionClosing in interface SessionTrackerpublic void removeSession(long sessionId)
removeSession in interface SessionTrackerpublic void shutdown()
shutdown in interface SessionTrackerpublic long createSession(int sessionTimeout)
createSession in interface SessionTrackerpublic boolean trackSession(long id,
int sessionTimeout)
SessionTrackertrackSession in interface SessionTrackerid - sessionIdsessionTimeout - sessionTimeoutpublic boolean commitSession(long id,
int sessionTimeout)
SessionTrackercommitSession in interface SessionTrackerid - sessionIdsessionTimeout - sessionTimeoutpublic boolean isTrackingSession(long sessionId)
isTrackingSession in interface SessionTrackerpublic void checkSession(long sessionId,
Object owner)
throws KeeperException.SessionExpiredException,
KeeperException.SessionMovedException,
KeeperException.UnknownSessionException
SessionTrackercheckSession in interface SessionTrackerKeeperException.SessionExpiredExceptionKeeperException.SessionMovedExceptionKeeperException.UnknownSessionExceptionpublic void setOwner(long id,
Object owner)
throws KeeperException.SessionExpiredException
setOwner in interface SessionTrackerKeeperException.SessionExpiredExceptionpublic void checkGlobalSession(long sessionId,
Object owner)
throws KeeperException.SessionExpiredException,
KeeperException.SessionMovedException
SessionTrackercheckGlobalSession in interface SessionTrackerKeeperException.SessionExpiredExceptionKeeperException.SessionMovedExceptionpublic long getLocalSessionCount()
SessionTrackergetLocalSessionCount in interface SessionTrackerpublic boolean isLocalSessionsEnabled()
isLocalSessionsEnabled in interface SessionTrackerCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.