public class SessionTrackerImpl extends ZooKeeperCriticalThread implements SessionTracker
Modifier and Type | Class and Description |
---|---|
static class |
SessionTrackerImpl.SessionImpl |
Thread.State, Thread.UncaughtExceptionHandler
SessionTracker.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 |
---|---|
boolean |
addGlobalSession(long id,
int sessionTimeout)
Add a global session to those being tracked.
|
boolean |
addSession(long id,
int sessionTimeout)
Add a session to those being tracked.
|
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.
|
long |
createSession(int sessionTimeout) |
void |
dumpSessions(PrintWriter pwriter)
Text dump of session information, suitable for debugging.
|
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 |
initializeNextSession(long id)
Generates an initial sessionId.
|
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) |
handleException
activeCount, 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, yield
protected final ConcurrentHashMap<Long,SessionTrackerImpl.SessionImpl> sessionsById
public SessionTrackerImpl(SessionTracker.SessionExpirer expirer, ConcurrentMap<Long,Integer> sessionsWithTimeout, int tickTime, long serverId, ZooKeeperServerListener listener)
public static long initializeNextSession(long id)
public void dumpSessions(PrintWriter pwriter)
SessionTracker
dumpSessions
in interface SessionTracker
pwriter
- the output writerpublic Map<Long,Set<Long>> getSessionExpiryMap()
getSessionExpiryMap
in interface SessionTracker
public boolean touchSession(long sessionId, int timeout)
touchSession
in interface SessionTracker
public int getSessionTimeout(long sessionId)
public void setSessionClosing(long sessionId)
SessionTracker
setSessionClosing
in interface SessionTracker
public void removeSession(long sessionId)
removeSession
in interface SessionTracker
public void shutdown()
shutdown
in interface SessionTracker
public long createSession(int sessionTimeout)
createSession
in interface SessionTracker
public boolean addGlobalSession(long id, int sessionTimeout)
SessionTracker
addGlobalSession
in interface SessionTracker
id
- sessionIdsessionTimeout
- sessionTimeoutpublic boolean addSession(long id, int sessionTimeout)
SessionTracker
addSession
in interface SessionTracker
id
- sessionIdsessionTimeout
- sessionTimeoutpublic boolean isTrackingSession(long sessionId)
isTrackingSession
in interface SessionTracker
public void checkSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException, KeeperException.UnknownSessionException
SessionTracker
checkSession
in interface SessionTracker
KeeperException.SessionExpiredException
KeeperException.SessionMovedException
KeeperException.UnknownSessionException
public void setOwner(long id, Object owner) throws KeeperException.SessionExpiredException
setOwner
in interface SessionTracker
KeeperException.SessionExpiredException
public void checkGlobalSession(long sessionId, Object owner) throws KeeperException.SessionExpiredException, KeeperException.SessionMovedException
SessionTracker
checkGlobalSession
in interface SessionTracker
KeeperException.SessionExpiredException
KeeperException.SessionMovedException
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.