Class SessionTrackerImpl

  • All Implemented Interfaces:
    java.lang.Runnable, SessionTracker
    Direct Known Subclasses:
    LocalSessionTracker

    public class SessionTrackerImpl
    extends ZooKeeperCriticalThread
    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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.ConcurrentHashMap<java.lang.Long,​SessionTrackerImpl.SessionImpl> sessionsById  
      protected java.util.concurrent.ConcurrentMap<java.lang.Long,​java.lang.Integer> sessionsWithTimeout  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void checkGlobalSession​(long sessionId, java.lang.Object owner)
      Strictly check that a given session is a global session or not
      void checkSession​(long sessionId, java.lang.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​(java.io.PrintWriter pwriter)
      Text dump of session information, suitable for debugging.
      long getLocalSessionCount()
      If this session tracker supports local sessions, return how many.
      java.util.Map<java.lang.Long,​java.util.Set<java.lang.Long>> getSessionExpiryMap()
      Returns a mapping from time to session IDs of sessions expiring at that time.
      int getSessionTimeout​(long sessionId)  
      java.util.Set<java.lang.Long> globalSessions()
      Get a set of global session IDs
      static long initializeNextSessionId​(long id)
      Generates an initial sessionId.
      boolean isLocalSessionsEnabled()  
      boolean isTrackingSession​(long sessionId)  
      java.util.Set<java.lang.Long> localSessions()
      Get a set of local session IDs
      void removeSession​(long sessionId)  
      void run()  
      void setOwner​(long id, java.lang.Object owner)  
      void setSessionClosing​(long sessionId)
      Mark that the session is in the process of closing.
      void shutdown()  
      java.lang.String toString()  
      boolean touchSession​(long sessionId, int timeout)  
      boolean trackSession​(long id, int sessionTimeout)
      Track the session expire, not add to ZkDb.
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait