|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.code.rees.scope.util.monitor.ScheduledExecutorTimeoutMonitor<T>
public class ScheduledExecutorTimeoutMonitor<T extends Timeoutable<T>>
An implementation of the TimeoutMonitor that makes use of a ScheduledExecutorService.
Cache's tasks and will add them to a new ScheduledExecutorService after serialization in order
to continue monitoring in cases such as cluster replication.
Of note: this class depends on being given a new scheduler after serialization, is does not
create its own schedulers. Likewise, it must be given an instance when it is first created as well.
| Field Summary | |
|---|---|
static long |
MONITORING_DELAY
the delay between adding a Timeoutable to the scheduler and the time of the first check of the Timeoutable's remaining time |
protected long |
monitoringFrequency
|
protected Map<String,ScheduledFuture<?>> |
scheduledFutures
|
protected ScheduledExecutorService |
scheduler
|
protected SchedulerProvider |
schedulerProvider
|
protected Map<String,TimeoutRunner<T>> |
timeoutRunners
|
| Fields inherited from interface com.google.code.rees.scope.util.monitor.TimeoutMonitor |
|---|
DEFAULT_MONITOR_FREQUENCY |
| Constructor Summary | |
|---|---|
protected |
ScheduledExecutorTimeoutMonitor()
|
| Method Summary | ||
|---|---|---|
void |
addTimeoutable(T timeoutable)
Adds the Timeoutable to this monitor |
|
void |
destroy()
Destroys this monitor, stopping its background thread and clearing its Timeoutable cache. |
|
void |
init()
Initializes this monitor, beginning a background thread for monitoring its Timeoutables. |
|
void |
onTimeout(T timeoutable)
Called when the given Timeoutable's timeout method is called. |
|
void |
removeTimeoutable(T timeoutable)
Removes this Timeoutable from this monitor |
|
void |
setMonitoringFrequency(long frequencyMillis)
The frequency, in milliseconds, that this monitor will check its Timeoutables for their remaining times. |
|
void |
setSchedulerProvider(SchedulerProvider schedulerProvider)
sets the scheduler to be used |
|
static
|
spawnInstance(SchedulerProvider scheduler,
long monitoringFrequency)
used to create an instance |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final long MONITORING_DELAY
protected Map<String,TimeoutRunner<T extends Timeoutable<T>>> timeoutRunners
protected transient Map<String,ScheduledFuture<?>> scheduledFutures
protected transient ScheduledExecutorService scheduler
protected long monitoringFrequency
protected SchedulerProvider schedulerProvider
| Constructor Detail |
|---|
protected ScheduledExecutorTimeoutMonitor()
| Method Detail |
|---|
public void setMonitoringFrequency(long frequencyMillis)
Timeoutables for their remaining times.
It should be noted that the frequency is guaranteed to not be less the the given time, but it
may incrementally exceed the given time as more Timeoutables are added. This is due
to the time required to check each of the Timeoutables.
setMonitoringFrequency in interface TimeoutMonitor<T extends Timeoutable<T>>public void setSchedulerProvider(SchedulerProvider schedulerProvider)
public void init()
Timeoutables.
init in interface TimeoutMonitor<T extends Timeoutable<T>>public void destroy()
Timeoutable cache.
destroy in interface TimeoutMonitor<T extends Timeoutable<T>>public void addTimeoutable(T timeoutable)
Timeoutable to this monitor
addTimeoutable in interface TimeoutMonitor<T extends Timeoutable<T>>public void removeTimeoutable(T timeoutable)
Timeoutable from this monitor
removeTimeoutable in interface TimeoutMonitor<T extends Timeoutable<T>>public void onTimeout(T timeoutable)
Timeoutable's timeout method is called.
onTimeout in interface TimeoutListener<T extends Timeoutable<T>>
public static <TT extends Timeoutable<TT>> ScheduledExecutorTimeoutMonitor<TT> spawnInstance(SchedulerProvider scheduler,
long monitoringFrequency)
TT - scheduler - monitoringFrequency -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||