java.lang.Object
java.lang.Thread
org.tentackle.task.DefaultTaskDispatcher
org.tentackle.session.SessionKeepAliveDaemon
- All Implemented Interfaces:
Runnable,Killable,Supervisable,Terminatable,TaskDispatcher
A task dispatcher to keep sessions alive.
- Author:
- harald
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class org.tentackle.task.DefaultTaskDispatcher
INSTANCE_COUNTERFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanup()Does any necessary cleanup after dispatcher thread has been terminated.protected TaskcreateAliveTask(Session session, long interval) Creates a keep alive task.protected ExecutorServiceCreates the executor service.Gets the executor service.voidkeepAliveIntervalChanged(Session session) Handles the change of a keep alive interval of a session.voidremoveAliveTask(Session session) Removes the task for given session.voidrun()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, getWaitInterval, interrupt, isDead, isInstanceOfTaskPending, isKilled, isQueueEmpty, isTaskDispatcherThread, isTaskPending, isTerminationRequested, isUsingMutexLocking, kill, lock, lockInternal, nextTask, removeTask, removeTaskListener, requestTermination, setDead, setDeadInterval, setShutdownIdleTimeout, setSleepInterval, setUsingMutexLocking, setWaitInterval, sleepForInterval, startedAt, terminate, terminatedAt, toDiagnosticString, unlock, unlockInternal, waitForTaskMethods 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yieldMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tentackle.daemon.Supervisable
getNameMethods inherited from interface org.tentackle.task.TaskDispatcher
isAlive, start
-
Constructor Details
-
SessionKeepAliveDaemon
public SessionKeepAliveDaemon(long minAliveInterval) Creates the daemon.- Parameters:
minAliveInterval- the minimum alive interval
-
-
Method Details
-
cleanup
protected void cleanup()Description copied from class:DefaultTaskDispatcherDoes any necessary cleanup after dispatcher thread has been terminated.- Overrides:
cleanupin classDefaultTaskDispatcher
-
run
public void run()- Specified by:
runin interfaceRunnable- Overrides:
runin classDefaultTaskDispatcher
-
keepAliveIntervalChanged
Handles the change of a keep alive interval of a session.- Parameters:
session- the session
-
removeAliveTask
Removes the task for given session.- Parameters:
session- the session
-
getExecutorService
Gets the executor service.- Returns:
- the executor service
-
createExecutorService
Creates the executor service.- Returns:
- the executor service
-
createAliveTask
Creates a keep alive task.- Parameters:
session- the sessioninterval- the keep-alive interval in milliseconds- Returns:
- the created task
-