|
OpenNMS API 1.1.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.poller.PollableServiceProxy
A proxy to a PollableService which acts as a surrogate for rescheduling purposes. This was created as a temporary fix to allow us to schedule a PollableService for a sooner execution, despite the fact that it is already scheduled for a later time. At the time we created this class, the Scheduler did not provide any means to cancel or reschedule an element on its queue. Therefore, this workaround became necessary.
In order to use this class, create an instance of it with the desired PollableService and the timestamp at which you want it to run. Once you have the instance, you can schedule it with the Scheduler, since it is of type ReadyRunnable.
Each time it runs, it will reschedule itself at the interval currently valid for the PollableService it contains. Once it catches up to the originally scheduled time for its PollableService, it will politely quit rescheduling itself. Assuming that the scheduler was the only object that was keeping a reference to this proxy, it should be noticed by the garbage collector next time runs.
PollableService
,
Scheduler
Field Summary | |
private long |
_scheduledRuntime
the time (in milliseconds) after which this proxy is supposed to run |
private PollableService |
_service
interface that this service belongs to |
Constructor Summary | |
(package private) |
PollableServiceProxy(PollableService psvc,
long runAt)
Constructs a new instance of a proxy object that proxies for the specified pollable service. |
Method Summary | |
private long |
getScheduledRuntime()
Returns the time (in milliseconds) at which this Proxy is scheduled to run. |
boolean |
isReady()
Returns true if this proxy wants to be run. |
void |
run()
This is the main method of the class. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private PollableService _service
private long _scheduledRuntime
Constructor Detail |
PollableServiceProxy(PollableService psvc, long runAt)
psvc
- The PollableService to be proxied.runAt
- The timestamp after which this proxy should run.Method Detail |
public boolean isReady()
isReady
in interface ReadyRunnable
public void run()
This is the main method of the class.
It passes a run() call through to the PollableService that it proxies, and then makes a rescheduling decision on its behalf. If it encounters an inability to finish processing on run() (such as a node lock unavailable or an interrupted thread) it will reschedule itself to retry at 10 seconds.
run
in interface java.lang.Runnable
private long getScheduledRuntime()
|
OpenNMS API 1.1.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |