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 class
SessionHelper.SessionReaperDaemon.IncrementalReapTask
class
SessionHelper.SessionReaperDaemon.StartReapingTask
A 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 long
getAverageReapDuration()
Gets the average reap duration since the statistics was reset.long
getAverageReapedSessions()
Gets the average number of reaped sessions in a reap cycle since the statistics was reset.long
getAverageReapQueueWaitDuration()
Return the average number of milliseconds reap tasks wait in the queue prior to running.int
getEstimatedReaperSessionCount()
Determine the estimated number of sessions that will be reaped by the reaper when it runs next.long
getLastReapDuration()
Gets the duration for the last reap cycle.long
getLastReapQueueWaitDuration()
Return the time the last reap task spent in the queue prior to running.long
getLastReapTime()
Determine the last time that session reaping started.long
getMaxReapDuration()
Gets the maximum reap duration since the statistics was reset.long
getMaxReapedSessions()
Gets the maximum number of sessions reaped in a reap cycle since the statistics was reset.long
getMaxReapQueueWaitDuration()
Return the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset.long
getNextReapTime()
Gets the start time for the next reap cycle.long
getReapedSessions()
Gets the number of sessions that were reaped during the last reap cycle.int
getTotalReapCycles()
Determine the total number of reaping cycles that this node has performed.long
getTotalReapedSessions()
Gets the number of sessions that were reaped since the statistics was reset.void
incTotalReapCycles()
Increment the total number of reaping cycles that this node has performed.SessionHelper.SessionReaperDaemon.StartReapingTask
instantiateStartReapingTask()
Factory method: Instantiate a task that starts a reaping cycle.protected boolean
isFullReapDue()
Determine if this node should run a full reaper scan.protected void
onException(Throwable e, Runnable task)
Process an exception that is thrown during a task execution.void
resetStatistics()
Resets the statistics held by this object.void
run()
The task process: Process a portion of the reaping cycle.void
scheduleTask(Runnable task, long ldt)
Schedule a task to be run at the specified time, or as soon after as possible.void
setEstimatedReaperSessionCount(int c)
Update the estimated number of sessions that will be reaped by the reaper when it runs next.void
setLastReapDuration(long time)
Sets the duration for the last reap cycle.void
setLastReapQueueWaitDuration(long time)
Sets the duration the last reap task spent in the queue prior to running.void
setLastReapTime(long dt)
Update the last time that session reaping started.void
setNextReapTime(long d)
Sets the start time for the next reap cycle.void
setReapedSessions(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:
scheduleTask
in 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:
run
in interfaceRunnable
- Overrides:
run
in 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:
onException
in 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:
setLastReapQueueWaitDuration
in 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:
getLastReapQueueWaitDuration
in 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:
getAverageReapQueueWaitDuration
in interfaceSessionReaperStatistics
- Returns:
- the average number of milliseconds reap tasks wait in the queue.
-
getMaxReapQueueWaitDuration
public long getMaxReapQueueWaitDuration()
Description copied from interface:SessionReaperStatistics
Return the max time in milliseconds a reap task has spent in the queue prior to running since the statistics were last reset.- Specified by:
getMaxReapQueueWaitDuration
in 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:
getLastReapDuration
in interfaceSessionReaperStatistics
- Returns:
- The duration in milliseconds.
-
setLastReapDuration
public void setLastReapDuration(long time)
Sets the duration for the last reap cycle.- Specified by:
setLastReapDuration
in 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:
getReapedSessions
in 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:
setReapedSessions
in 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:
getTotalReapedSessions
in interfaceSessionReaperStatistics
- Returns:
- The number of sessions.
-
getLastReapTime
public long getLastReapTime()
Determine the last time that session reaping started.- Specified by:
getLastReapTime
in 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:
setLastReapTime
in 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:
getNextReapTime
in 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:
setNextReapTime
in 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:
getAverageReapDuration
in 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:
getAverageReapedSessions
in interfaceSessionReaperStatistics
- Returns:
- The average number of reaped sessions.
-
getMaxReapDuration
public long getMaxReapDuration()
Gets the maximum reap duration since the statistics was reset.- Specified by:
getMaxReapDuration
in 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:
getMaxReapedSessions
in interfaceSessionReaperStatistics
- Returns:
- The max number of sessions reaped.
-
resetStatistics
public void resetStatistics()
Resets the statistics held by this object.- Specified by:
resetStatistics
in interfaceSessionReaperStatistics
-
instantiateStartReapingTask
public SessionHelper.SessionReaperDaemon.StartReapingTask instantiateStartReapingTask()
Factory method: Instantiate a task that starts a reaping cycle.- Returns:
- the instantiated StartReapingTask
-
-