Class SessionKeepAliveDaemon

  • All Implemented Interfaces:
    java.lang.Runnable, org.tentackle.daemon.Killable, org.tentackle.daemon.Supervisable, org.tentackle.daemon.Terminatable, org.tentackle.task.TaskDispatcher

    public class SessionKeepAliveDaemon
    extends org.tentackle.task.DefaultTaskDispatcher
    A task dispatcher to keep sessions alive.
    Author:
    harald
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class org.tentackle.task.DefaultTaskDispatcher

        INSTANCE_COUNTER
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionKeepAliveDaemon​(long minAliveInterval)
      Creates the daemon.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void cleanup()  
      protected org.tentackle.task.Task createAliveTask​(Session session, long interval)
      Creates a keep alive task.
      protected java.util.concurrent.ExecutorService createExecutorService()
      Creates the executor service.
      java.util.concurrent.ExecutorService getExecutorService()
      Gets the executor service.
      void keepAliveIntervalChanged​(Session session)
      Handles the change of a keep alive interval of a session.
      void removeAliveTask​(Session session)
      Removes the task for given session.
      void run()  
      • Methods inherited from class org.tentackle.task.DefaultTaskDispatcher

        addTask, addTaskAndWait, addTaskListener, assertAlive, assertIntervalsInRange, assertNotAlive, assertNotKilled, createLock, executeTask, fireCompleted, fireStarted, getAllTasks, getDeadInterval, getQueueSize, getShutdownIdleTimeout, getSleepInterval, getTask, getTerminationCause, interrupt, isDead, isInstanceOfTaskPending, isKilled, isQueueEmpty, isTaskDispatcherThread, isTaskPending, isTerminationRequested, isUsingMutexLocking, kill, lock, lockInternal, nextTask, removeTask, removeTaskListener, requestTermination, setDead, setDeadInterval, setShutdownIdleTimeout, setSleepInterval, setUsingMutexLocking, sleepForInterval, startedAt, terminate, terminatedAt, toDiagnosticString, unlock, unlockInternal, waitForTask
      • 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, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.tentackle.daemon.Supervisable

        getName
      • Methods inherited from interface org.tentackle.task.TaskDispatcher

        isAlive, start
    • Constructor Detail

      • SessionKeepAliveDaemon

        public SessionKeepAliveDaemon​(long minAliveInterval)
        Creates the daemon.
        Parameters:
        minAliveInterval - the minimum alive interval
    • Method Detail

      • cleanup

        protected void cleanup()
        Overrides:
        cleanup in class org.tentackle.task.DefaultTaskDispatcher
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class org.tentackle.task.DefaultTaskDispatcher
      • keepAliveIntervalChanged

        public void keepAliveIntervalChanged​(Session session)
        Handles the change of a keep alive interval of a session.
        Parameters:
        session - the session
      • removeAliveTask

        public void removeAliveTask​(Session session)
        Removes the task for given session.
        Parameters:
        session - the session
      • getExecutorService

        public java.util.concurrent.ExecutorService getExecutorService()
        Gets the executor service.
        Returns:
        the executor service
      • createExecutorService

        protected java.util.concurrent.ExecutorService createExecutorService()
        Creates the executor service.
        Returns:
        the executor service
      • createAliveTask

        protected org.tentackle.task.Task createAliveTask​(Session session,
                                                          long interval)
        Creates a keep alive task.
        Parameters:
        session - the session
        interval - the keep-alive interval in milliseconds
        Returns:
        the created task