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_COUNTER
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanup()
Does any necessary cleanup after dispatcher thread has been terminated.protected Task
createAliveTask
(Session session, long interval) Creates a keep alive task.protected ExecutorService
Creates the executor service.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, 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, 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, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, 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 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:DefaultTaskDispatcher
Does any necessary cleanup after dispatcher thread has been terminated.- Overrides:
cleanup
in classDefaultTaskDispatcher
-
run
public void run()- Specified by:
run
in interfaceRunnable
- Overrides:
run
in 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
-