|
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.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 | |
private static class |
Scheduler.PeekableFifoQueue
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 | |
private static java.lang.String |
FIBER_NAME
The prefix for the fiber name. |
private java.lang.String |
m_name
The name of this fiber. |
private java.util.Map |
m_queues
The map of queue that contain ready runnable instances. |
private RunnableConsumerThreadPool |
m_runner
The pool of threads that are used to executed the runnable instances scheduled by the class' instance. |
private int |
m_scheduled
The total number of elements currently scheduled. |
private int |
m_status
The status for this fiber. |
private java.lang.Thread |
m_worker
The worker thread that executes this instance. |
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 | |
(package private) |
Scheduler(int maxSize)
Constructs a new instance of the scheduler. |
(package private) |
Scheduler(int maxSize,
float lowMark,
float hiMark)
Constructs a new instance of the scheduler. |
Method Summary | |
java.lang.String |
getName()
Returns the name of this fiber. |
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. |
(package private) 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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String FIBER_NAME
private java.util.Map m_queues
ready runnable
instances.
The queues are mapped according to the interval of scheduling.
private int m_scheduled
private RunnableConsumerThreadPool m_runner
private java.lang.String m_name
private int m_status
private java.lang.Thread m_worker
Constructor Detail |
Scheduler(int maxSize)
maxSize
- The maximum size of the thread pool.Scheduler(int maxSize, float lowMark, float hiMark)
maxSize
- 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 |
void schedule(ReadyRunnable runnable, long interval)
runnable
- The element to run when interval expires.interval
- The interval queue (measured in milliseconds)
to add the runnable to.
java.lang.RuntimeException
- Thrown if an error occurs
adding the element to the queue.public void start()
start
in interface Fiber
java.lang.IllegalStateException
- Thrown if the fiber is
already running.public void stop()
stop
in interface Fiber
java.lang.IllegalStateException
- Throws if the fiber
has never been started.public void pause()
pause
in interface PausableFiber
java.lang.IllegalStateException
- Throws if the operation could
not be completed due to the fiber's state.public void resume()
resume
in interface PausableFiber
java.lang.IllegalStateException
- Throws if the operation could
not be completed due to the fiber's state.public int getStatus()
getStatus
in interface Fiber
public java.lang.String getName()
getName
in interface Fiber
Fiber
.public void run()
run
in interface java.lang.Runnable
|
OpenNMS API 1.1.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |