Oracle® Coherence Java API Reference
v3.5

E14977-01

com.tangosol.coherence.servlet
Class SessionHelper.SessionReaperDaemon

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.Daemon
          extended by com.tangosol.util.TaskDaemon
              extended by com.tangosol.coherence.servlet.SessionHelper.SessionReaperDaemon
All Implemented Interfaces:
Guardable, java.lang.Runnable
Enclosing class:
SessionHelper

public class SessionHelper.SessionReaperDaemon
extends TaskDaemon

A daemon thread class that will clean up expired sessions.


Nested Class Summary
 class SessionHelper.SessionReaperDaemon.IncrementalReapTask
          A task that starts a reaping cycle.
 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
 
Constructor Summary
SessionHelper.SessionReaperDaemon(java.lang.String sName, int nPriority)
          Construct a SessionReaperDaemon.
 
Method Summary
 int getEstimatedReaperSessionCount()
          Determine the estimated number of sessions that will be reaped by the reaper when it runs next.
 long getLastReapTime()
          Determine the last time that session reaping started.
 int getTotalReapCycles()
          Determine the total number of reaping cycles that this node has performed.
 void incTotalReapCycles()
          Increment the total number of reaping cycles that this node has performed.
 SessionHelper.SessionReaperDaemon.IncrementalReapTask instantiateIncrementalReapTask(java.util.Iterator iterIds, int cEstimatedSessions)
          Factory method: Instantiate a task that incrementally reaps sessions (checks for and invalidates expired sessions).
 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(java.lang.Throwable e, java.lang.Runnable task)
          Process an exception that is thrown during a task execution.
 void run()
          The task process: Process a portion of the reaping cycle.
 void scheduleTask(java.lang.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 setLastReapTime(long dt)
          Update the last time that session reaping started.
 
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, finishStarting, getConfiguredName, getConfiguredPriority, getGuardContext, getGuardRegisterAction, getMaxWaitMillis, getState, getThread, getThreadContextClassLoader, getWorker, guardIfNeeded, heartbeat, heartbeat, instantiateWorker, isGuarded, isOnWorkerThread, isRunning, isStopping, recover, setConfiguredName, setConfiguredPriority, setContext, setGuardPolicy, setGuardRegisterAction, setThreadContextClassLoader, start, stop, terminate, toStateString
 

Constructor Detail

SessionHelper.SessionReaperDaemon

public SessionHelper.SessionReaperDaemon(java.lang.String sName,
                                         int nPriority)
Construct a SessionReaperDaemon.

Parameters:
sName - the daemon name
nPriority - the daemon priority
Method Detail

scheduleTask

public void scheduleTask(java.lang.Runnable task,
                         long ldt)
Schedule a task to be run at the specified time, or as soon after as possible.

Overrides:
scheduleTask in class TaskDaemon
Parameters:
task - a Runnable object to invoke
ldt - 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 interface java.lang.Runnable
Overrides:
run in class TaskDaemon

onException

protected void onException(java.lang.Throwable e,
                           java.lang.Runnable task)
Process an exception that is thrown during a task execution. The default implementation logs the exception and continues.

Overrides:
onException in class TaskDaemon
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

getLastReapTime

public long getLastReapTime()
Determine the last time that session reaping started.

Returns:
the last time that session reaping started

setLastReapTime

public void setLastReapTime(long dt)
Update the last time that session reaping started.

Parameters:
dt - the last time that session reaping started

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

instantiateStartReapingTask

public SessionHelper.SessionReaperDaemon.StartReapingTask instantiateStartReapingTask()
Factory method: Instantiate a task that starts a reaping cycle.


instantiateIncrementalReapTask

public SessionHelper.SessionReaperDaemon.IncrementalReapTask instantiateIncrementalReapTask(java.util.Iterator iterIds,
                                                                                            int cEstimatedSessions)
Factory method: Instantiate a task that incrementally reaps sessions (checks for and invalidates expired sessions).

Parameters:
iterIds - an iterator of session IDs to check
cEstimatedSessions - the estimated number of session IDs to check

Oracle® Coherence Java API Reference
v3.5

E14977-01

Copyright © 2000, 2009, Oracle. All rights reserved.