|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.core.concurrent.RunnableConsumerThreadPool
Nested Class Summary | |
private class |
RunnableConsumerThreadPool.FiberThreadImpl
This class implements the Fiber
interface on top of a Java Thread instance. |
static interface |
RunnableConsumerThreadPool.RunnableCompletionListener
This interface is used to define a listener for the thread pool that is notified when an enqueued runnable completes. |
static interface |
RunnableConsumerThreadPool.RunnableErrorListener
This interface is used to define a listerer for the thread pool that is notified if an error occurs processing a runnable. |
private class |
RunnableConsumerThreadPool.SizingFifoQueue
This class is used to create a queue that auto adjust the number of threads in the pool. |
Field Summary | |
private java.util.List |
m_completedListeners
The set of listeners to call when a Runnable completes successfully. |
private RunnableConsumerThreadPool.SizingFifoQueue |
m_delegateQ
The queue where runnable objects are added. |
private java.util.List |
m_errorListeners
The set of listeners to call when a Runnable fails to complete successfully. |
private Fiber[] |
m_fibers
The list of running fibers in the pool. |
private float |
m_hiRatio
The high water mark ratio for the pool. |
private java.lang.String |
m_log4jPrefix
The log4j prefix used when starting up a new fiber! |
private float |
m_loRatio
The low water mark ratio for the pool. |
private int |
m_maxSize
The maximum size for the thread pool. |
private java.lang.String |
m_poolName
The name of the pool. |
private int |
m_poolStatus
The pool status |
private java.lang.ThreadGroup |
m_tGroup
The thread group that all pool threads belong to. |
Fields inherited from interface org.opennms.core.fiber.Fiber |
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED |
Constructor Summary | |
RunnableConsumerThreadPool(java.lang.String name,
float loMark,
float hiMark,
int max)
Constructs a new instance of the thread pool class. |
Method Summary | |
void |
addCompletionListener(RunnableConsumerThreadPool.RunnableCompletionListener listener)
Adds a listener that is notified upon completion of each runnable. |
void |
addErrorListener(RunnableConsumerThreadPool.RunnableErrorListener listener)
Adds a listener that is notified of error from any runnable. |
java.lang.String |
getName()
Returns the name of the thread pool. |
FifoQueue |
getRunQueue()
Returns the input queue where Runnable objects
are enqueued. |
int |
getStatus()
Returns the current status of the fiber. |
private int |
livingFiberCount()
Returns the current number of living fibers in the pool. |
void |
removeCompletionListener(RunnableConsumerThreadPool.RunnableCompletionListener listener)
Removes a previous register listener. |
void |
removeErrorListener(RunnableConsumerThreadPool.RunnableErrorListener listener)
Removes a previous register listener. |
void |
start()
Starts the thread pool. |
void |
stop()
Begins the shutdown process of the thread pool. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private RunnableConsumerThreadPool.SizingFifoQueue m_delegateQ
private Fiber[] m_fibers
private java.lang.String m_poolName
private float m_hiRatio
private float m_loRatio
private int m_maxSize
private java.lang.String m_log4jPrefix
private int m_poolStatus
private java.util.List m_completedListeners
private java.lang.ThreadGroup m_tGroup
private java.util.List m_errorListeners
Constructor Detail |
public RunnableConsumerThreadPool(java.lang.String name, float loMark, float hiMark, int max)
Constructs a new instance of the thread pool class. The thread pool
consumes Runnable
instances from the input
queue, calling the run
method as they are consumed.
The size of the thread pool is controlled by the low and high water marks, each water mark being the ratio of queue elements to threads. As the ratio grows past the high water mark more threads are added, up to the maximum amount. As the ratio drops past the low water mark the number of threads are reduced.
name
- The name of the thread pool.loMark
- The lower ratio used to mark thread reduction.hiMark
- The high ration used to mark thread production.max
- The maximum number of threads in the pool.
java.lang.IllegalArgumentException
- Thrown if the low or high marks are invalid, or the
maximum number of threads is invalid.Method Detail |
private int livingFiberCount()
public FifoQueue getRunQueue()
Runnable
objects
are enqueued. Each runnable object will be executed in the order that it
is entered.
public void start()
start
in interface Fiber
public void stop()
stop
in interface Fiber
public int getStatus()
getStatus
in interface Fiber
public java.lang.String getName()
getName
in interface Fiber
public void addCompletionListener(RunnableConsumerThreadPool.RunnableCompletionListener listener)
listener
- The listener notified on runnable completion.public void removeCompletionListener(RunnableConsumerThreadPool.RunnableCompletionListener listener)
listener
- The listener to remove from notification.public void addErrorListener(RunnableConsumerThreadPool.RunnableErrorListener listener)
listener
- The listener notified on runnable completion.public void removeErrorListener(RunnableConsumerThreadPool.RunnableErrorListener listener)
listener
- The listener to remove from notification.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |