Package com.tangosol.coherence.servlet
Class SessionHelper.SessionReaperDaemon
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.Daemon
-
- com.tangosol.util.TaskDaemon
-
- com.tangosol.coherence.servlet.SessionHelper.SessionReaperDaemon
-
- All Implemented Interfaces:
SessionReaperStatistics,Guardable,Runnable
- Enclosing class:
- SessionHelper
public class SessionHelper.SessionReaperDaemon extends TaskDaemon implements SessionReaperStatistics
A daemon thread class that will clean up expired sessions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSessionHelper.SessionReaperDaemon.IncrementalReapTaskclassSessionHelper.SessionReaperDaemon.StartReapingTaskA task that starts a reaping cycle.-
Nested classes/interfaces inherited from class com.tangosol.util.TaskDaemon
TaskDaemon.PeriodicTask
-
Nested classes/interfaces inherited from class com.tangosol.util.Daemon
Daemon.DaemonWorker
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Constructor Summary
Constructors Constructor Description SessionReaperDaemon(String sName, int nPriority)Construct a SessionReaperDaemon.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetAverageReapDuration()Gets the average reap duration since the statistics was reset.longgetAverageReapedSessions()Gets the average number of reaped sessions in a reap cycle since the statistics was reset.longgetAverageReapQueueWaitDuration()Return the average number of milliseconds reap tasks wait in the queue prior to running.intgetEstimatedReaperSessionCount()Determine the estimated number of sessions that will be reaped by the reaper when it runs next.longgetLastReapDuration()Gets the duration for the last reap cycle.longgetLastReapQueueWaitDuration()Return the time the last reap task spent in the queue prior to running.longgetLastReapTime()Determine the last time that session reaping started.longgetMaxReapDuration()Gets the maximum reap duration since the statistics was reset.longgetMaxReapedSessions()Gets the maximum number of sessions reaped in a reap cycle since the statistics was reset.longgetMaxReapQueueWaitDuration()Return the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset.longgetNextReapTime()Gets the start time for the next reap cycle.longgetReapedSessions()Gets the number of sessions that were reaped during the last reap cycle.intgetTotalReapCycles()Determine the total number of reaping cycles that this node has performed.longgetTotalReapedSessions()Gets the number of sessions that were reaped since the statistics was reset.voidincTotalReapCycles()Increment the total number of reaping cycles that this node has performed.SessionHelper.SessionReaperDaemon.StartReapingTaskinstantiateStartReapingTask()Factory method: Instantiate a task that starts a reaping cycle.protected booleanisFullReapDue()Determine if this node should run a full reaper scan.protected voidonException(Throwable e, Runnable task)Process an exception that is thrown during a task execution.voidresetStatistics()Resets the statistics held by this object.voidrun()The task process: Process a portion of the reaping cycle.voidscheduleTask(Runnable task, long ldt)Schedule a task to be run at the specified time, or as soon after as possible.voidsetEstimatedReaperSessionCount(int c)Update the estimated number of sessions that will be reaped by the reaper when it runs next.voidsetLastReapDuration(long time)Sets the duration for the last reap cycle.voidsetLastReapQueueWaitDuration(long time)Sets the duration the last reap task spent in the queue prior to running.voidsetLastReapTime(long dt)Update the last time that session reaping started.voidsetNextReapTime(long d)Sets the start time for the next reap cycle.voidsetReapedSessions(long l)Sets the number of sessions that were reaped during the last reap cycle.-
Methods inherited from class com.tangosol.util.TaskDaemon
executePeriodicTask, executeTask, getDescription, getIdleTimeout, getMostRecentTaskTime, getTasks, instantiatePeriodicTask, isFinishing, run, schedulePeriodicTask, setFinishing, setIdleTimeout, stop, takeNextRipeTask, toString, updateMostRecentTaskTime
-
Methods inherited from class com.tangosol.util.Daemon
changeState, configureWorker, ensureThreadGroup, finishStarting, finishStopping, getConfiguredName, getConfiguredPriority, getContext, getGuardRegisterAction, getMaxWaitMillis, getState, getThread, getThreadContextClassLoader, getWorker, guardIfNeeded, heartbeat, heartbeat, instantiateWorker, isGuarded, isOnWorkerThread, isRunning, isStopping, recover, setConfiguredName, setConfiguredPriority, setContext, setGuardPolicy, setGuardRegisterAction, setThreadContextClassLoader, shutdown, start, stop, terminate, toStateString
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
-
-
-
Constructor Detail
-
SessionReaperDaemon
public SessionReaperDaemon(String sName, int nPriority)
Construct a SessionReaperDaemon.- Parameters:
sName- the daemon namenPriority- the daemon priority
-
-
Method Detail
-
scheduleTask
public void scheduleTask(Runnable task, long ldt)
Schedule a task to be run at the specified time, or as soon after as possible.- Overrides:
scheduleTaskin classTaskDaemon- Parameters:
task- a Runnable object to invokeldt- a datetime value at which to run the task
-
run
public void run()
The task process: Process a portion of the reaping cycle.- Specified by:
runin interfaceRunnable- Overrides:
runin classTaskDaemon
-
onException
protected void onException(Throwable e, Runnable task)
Process an exception that is thrown during a task execution. The default implementation logs the exception and continues.- Overrides:
onExceptionin classTaskDaemon- Parameters:
e- Throwable object (a RuntimeException or an Error)task- the task that caused the exception
-
getEstimatedReaperSessionCount
public int getEstimatedReaperSessionCount()
Determine the estimated number of sessions that will be reaped by the reaper when it runs next.- Returns:
- an estimate of the number of sessions to reap (if it cannot be determined exactly)
-
setEstimatedReaperSessionCount
public void setEstimatedReaperSessionCount(int c)
Update the estimated number of sessions that will be reaped by the reaper when it runs next.- Parameters:
c- the number of sessions that were reaped by the previous reap cycle
-
getTotalReapCycles
public int getTotalReapCycles()
Determine the total number of reaping cycles that this node has performed.- Returns:
- the total number of reaping cycles that this node has performed
-
incTotalReapCycles
public void incTotalReapCycles()
Increment the total number of reaping cycles that this node has performed.
-
isFullReapDue
protected boolean isFullReapDue()
Determine if this node should run a full reaper scan. This method is only utilized if reaping is cluster-coordinated.- Returns:
- true if a reaper scan is due and this node has been selected to perform it
-
setLastReapQueueWaitDuration
public void setLastReapQueueWaitDuration(long time)
Sets the duration the last reap task spent in the queue prior to running.- Specified by:
setLastReapQueueWaitDurationin interfaceSessionReaperStatistics- Parameters:
time- the duration in milliseconds
-
getLastReapQueueWaitDuration
public long getLastReapQueueWaitDuration()
Return the time the last reap task spent in the queue prior to running.- Specified by:
getLastReapQueueWaitDurationin interfaceSessionReaperStatistics- Returns:
- the time the last reap task spent in the queue prior to running.
-
getAverageReapQueueWaitDuration
public long getAverageReapQueueWaitDuration()
Return the average number of milliseconds reap tasks wait in the queue prior to running.- Specified by:
getAverageReapQueueWaitDurationin interfaceSessionReaperStatistics- Returns:
- the average number of milliseconds reap tasks wait in the queue.
-
getMaxReapQueueWaitDuration
public long getMaxReapQueueWaitDuration()
Description copied from interface:SessionReaperStatisticsReturn the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset.- Specified by:
getMaxReapQueueWaitDurationin interfaceSessionReaperStatistics- Returns:
- the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset
-
getLastReapDuration
public long getLastReapDuration()
Gets the duration for the last reap cycle.- Specified by:
getLastReapDurationin interfaceSessionReaperStatistics- Returns:
- The duration in milliseconds.
-
setLastReapDuration
public void setLastReapDuration(long time)
Sets the duration for the last reap cycle.- Specified by:
setLastReapDurationin interfaceSessionReaperStatistics- Parameters:
time- The duration in milliseconds.
-
getReapedSessions
public long getReapedSessions()
Gets the number of sessions that were reaped during the last reap cycle.- Specified by:
getReapedSessionsin interfaceSessionReaperStatistics- Returns:
- The number of sessions.
-
setReapedSessions
public void setReapedSessions(long l)
Sets the number of sessions that were reaped during the last reap cycle.- Specified by:
setReapedSessionsin interfaceSessionReaperStatistics- Parameters:
l- The number of sessions.
-
getTotalReapedSessions
public long getTotalReapedSessions()
Gets the number of sessions that were reaped since the statistics was reset. Note! This attribute doesn't have a setter since it is derived from the ReapedSession attr.- Specified by:
getTotalReapedSessionsin interfaceSessionReaperStatistics- Returns:
- The number of sessions.
-
getLastReapTime
public long getLastReapTime()
Determine the last time that session reaping started.- Specified by:
getLastReapTimein interfaceSessionReaperStatistics- Returns:
- the last time that session reaping started
-
setLastReapTime
public void setLastReapTime(long dt)
Update the last time that session reaping started.- Specified by:
setLastReapTimein interfaceSessionReaperStatistics- Parameters:
dt- the last time that session reaping started
-
getNextReapTime
public long getNextReapTime()
Gets the start time for the next reap cycle.- Specified by:
getNextReapTimein interfaceSessionReaperStatistics- Returns:
- The time in milliseconds when the next reap cycle is schedule to start.
-
setNextReapTime
public void setNextReapTime(long d)
Sets the start time for the next reap cycle.- Specified by:
setNextReapTimein interfaceSessionReaperStatistics- Parameters:
d- The time in milliseconds when the next reap cycle is schedule to start.
-
getAverageReapDuration
public long getAverageReapDuration()
Gets the average reap duration since the statistics was reset.- Specified by:
getAverageReapDurationin interfaceSessionReaperStatistics- Returns:
- The average reap duration.
-
getAverageReapedSessions
public long getAverageReapedSessions()
Gets the average number of reaped sessions in a reap cycle since the statistics was reset.- Specified by:
getAverageReapedSessionsin interfaceSessionReaperStatistics- Returns:
- The average number of reaped sessions.
-
getMaxReapDuration
public long getMaxReapDuration()
Gets the maximum reap duration since the statistics was reset.- Specified by:
getMaxReapDurationin interfaceSessionReaperStatistics- Returns:
- The max reap duration.
-
getMaxReapedSessions
public long getMaxReapedSessions()
Gets the maximum number of sessions reaped in a reap cycle since the statistics was reset.- Specified by:
getMaxReapedSessionsin interfaceSessionReaperStatistics- Returns:
- The max number of sessions reaped.
-
resetStatistics
public void resetStatistics()
Resets the statistics held by this object.- Specified by:
resetStatisticsin interfaceSessionReaperStatistics
-
instantiateStartReapingTask
public SessionHelper.SessionReaperDaemon.StartReapingTask instantiateStartReapingTask()
Factory method: Instantiate a task that starts a reaping cycle.- Returns:
- the instantiated StartReapingTask
-
-