|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opennms.netmgt.linkd.scheduler.Scheduler
public class Scheduler
This class implements a simple scheduler to ensure the polling occurs at the expected intervals. The scheduler employees a dynamic thread pool that adjust to the load until a maximum thread count is reached.
| Nested Class Summary | |
|---|---|
static class |
Scheduler.PeekableFifoQueue<T>
This queue extends the standard FIFO queue instance so that it is possible to peek at an instance without removing it from the queue. |
| Field Summary | |
|---|---|
Map<Long,Scheduler.PeekableFifoQueue<ReadyRunnable>> |
m_queues
The map of queue that contain ready runnable
instances. |
RunnableConsumerThreadPool |
m_runner
The pool of threads that are used to executed the runnable instances scheduled by the class' instance. |
int |
m_scheduled
The total number of elements currently scheduled. |
int |
m_status
The status for this fiber. |
| Fields inherited from interface org.opennms.core.fiber.PausableFiber |
|---|
PAUSE_PENDING, PAUSED, RESUME_PENDING |
| Fields inherited from interface org.opennms.core.fiber.Fiber |
|---|
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED |
| Constructor Summary | |
|---|---|
Scheduler(String parent,
int maxSize)
Constructs a new instance of the scheduler. |
|
Scheduler(String parent,
int maxSize,
float lowMark,
float hiMark)
Constructs a new instance of the scheduler. |
|
| Method Summary | |
|---|---|
long |
getCurrentTime()
This returns the current time for the scheduler |
String |
getName()
Returns the name of this fiber. |
ReadyRunnable |
getReadyRunnable(ReadyRunnable runnable)
This method is used to get a ready runnable in the system. |
ReadyRunnable |
getReadyRunnable(ReadyRunnable runnable,
long interval)
|
int |
getStatus()
Returns the current of this fiber. |
void |
pause()
Pauses the scheduler if it is current running. |
void |
resume()
Resumes the scheduler if it has been paused. |
void |
run()
The main method of the scheduler. |
void |
schedule(long interval,
ReadyRunnable runnable)
This method is used to schedule a ready runnable in the system. |
void |
schedule(ReadyRunnable runnable,
long interval)
This method is used to schedule a ready runnable in the system. |
void |
start()
Starts the fiber. |
void |
stop()
Stops the fiber. |
void |
unschedule(ReadyRunnable runnable)
This method is used to unschedule a ready runnable in the system. |
void |
unschedule(ReadyRunnable runnable,
long interval)
This method is used to unschedule a ready runnable in the system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Map<Long,Scheduler.PeekableFifoQueue<ReadyRunnable>> m_queues
ready runnable
instances. The queues are mapped according to the interval of scheduling.
public int m_scheduled
public RunnableConsumerThreadPool m_runner
public int m_status
| Constructor Detail |
|---|
public Scheduler(String parent,
int maxSize)
parent - String prepended to "Scheduler" to create fiber namemaxSize - The maximum size of the thread pool.
public Scheduler(String parent,
int maxSize,
float lowMark,
float hiMark)
parent - String prepended to "Scheduler" to create fiber namemaxSize - The maximum size of the thread pool.lowMark - The low water mark ratios of thread size to threads when
threads are stopped.hiMark - The high water mark ratio of thread size to threads when
threads are started.| Method Detail |
|---|
public void schedule(ReadyRunnable runnable,
long interval)
runnable - The element to run when interval expires.interval - The queue to add the runnable to.
RuntimeException - Thrown if an error occurs adding the element to the queue.
public void schedule(long interval,
ReadyRunnable runnable)
schedule in interface ScheduleTimerinterval - The queue to add the runnable to.runnable - The element to run when interval expires.
RuntimeException - Thrown if an error occurs adding the element to the queue.public void unschedule(ReadyRunnable runnable)
runnable - The element to remove from queue intervals.
public void unschedule(ReadyRunnable runnable,
long interval)
interval - The queue to add the runnable to.runnable - The element to remove.public ReadyRunnable getReadyRunnable(ReadyRunnable runnable)
runnable - The element to get from queues interval.
public ReadyRunnable getReadyRunnable(ReadyRunnable runnable,
long interval)
public long getCurrentTime()
getCurrentTime in interface Timerpublic void start()
start in interface FiberIllegalStateException - Thrown if the fiber is already running.public void stop()
stop in interface FiberIllegalStateException - Throws if the fiber has never been started.public void pause()
pause in interface PausableFiberIllegalStateException - Throws if the operation could not be completed due to the
fiber's state.public void resume()
resume in interface PausableFiberIllegalStateException - Throws if the operation could not be completed due to the
fiber's state.public int getStatus()
getStatus in interface Fiberpublic String getName()
getName in interface Fiberpublic void run()
run in interface Runnable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||