org.apache.zookeeper.server
Class SessionTrackerImpl

java.lang.Object
  extended by java.lang.Thread
      extended by org.apache.zookeeper.server.SessionTrackerImpl
All Implemented Interfaces:
Runnable, SessionTracker

public class SessionTrackerImpl
extends Thread
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
static class SessionTrackerImpl.SessionImpl
           
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.server.SessionTracker
SessionTracker.Session, SessionTracker.SessionExpirer
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SessionTrackerImpl(SessionTracker.SessionExpirer expirer, ConcurrentHashMap<Long,Integer> sessionsWithTimeout, int tickTime, long sid)
           
 
Method Summary
 void addSession(long id, int sessionTimeout)
           
 void checkSession(long sessionId, Object owner)
           
 long createSession(int sessionTimeout)
           
 void dumpSessions(PrintWriter pwriter)
          Text dump of session information, suitable for debugging.
static long initializeNextSession(long id)
           
 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)
           
 
Methods inherited from class java.lang.Thread
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionTrackerImpl

public SessionTrackerImpl(SessionTracker.SessionExpirer expirer,
                          ConcurrentHashMap<Long,Integer> sessionsWithTimeout,
                          int tickTime,
                          long sid)
Method Detail

initializeNextSession

public static long initializeNextSession(long id)

dumpSessions

public void dumpSessions(PrintWriter pwriter)
Description copied from interface: SessionTracker
Text dump of session information, suitable for debugging.

Specified by:
dumpSessions in interface SessionTracker
Parameters:
pwriter - the output writer

toString

public String toString()
Overrides:
toString in class Thread

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

touchSession

public boolean touchSession(long sessionId,
                            int timeout)
Specified by:
touchSession in interface SessionTracker
Returns:
false if session is no longer active

setSessionClosing

public void setSessionClosing(long sessionId)
Description copied from interface: SessionTracker
Mark that the session is in the process of closing.

Specified by:
setSessionClosing in interface SessionTracker

removeSession

public void removeSession(long sessionId)
Specified by:
removeSession in interface SessionTracker

shutdown

public void shutdown()
Specified by:
shutdown in interface SessionTracker

createSession

public long createSession(int sessionTimeout)
Specified by:
createSession in interface SessionTracker

addSession

public void addSession(long id,
                       int sessionTimeout)
Specified by:
addSession in interface SessionTracker

checkSession

public void checkSession(long sessionId,
                         Object owner)
                  throws KeeperException.SessionExpiredException,
                         KeeperException.SessionMovedException
Specified by:
checkSession in interface SessionTracker
Throws:
KeeperException.SessionExpiredException
KeeperException.SessionMovedException

setOwner

public void setOwner(long id,
                     Object owner)
              throws KeeperException.SessionExpiredException
Specified by:
setOwner in interface SessionTracker
Throws:
KeeperException.SessionExpiredException


Copyright © 2011 The Apache Software Foundation