|
OpenNMS API 1.1.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opennms.core.queue.FifoQueueImpl
org.opennms.core.concurrent.RunnableConsumerThreadPool.SizingFifoQueue
This class is used to create a queue that auto adjust the number of threads in the pool. Each time an addition or removal of queue elements occur the pool will be adjusted. This will cause some synchronization overhead, but it should be correct implementation.
To avoid the condition of toggleing a single thread the lo and hi water marks should have a large cushion between them.
| Field Summary | |
private boolean |
m_isClosed
Determines if the queue is open or closed. |
| Fields inherited from class org.opennms.core.queue.FifoQueueImpl |
|
| Constructor Summary | |
private |
RunnableConsumerThreadPool.SizingFifoQueue()
|
| Method Summary | |
void |
add(java.lang.Object element)
Inserts a new element into the queue. |
boolean |
add(java.lang.Object element,
long timeout)
Inserts a new element into the queue. |
private void |
adjust()
Adjust the size of the thread pool based on the ratio of queue elements to threads. |
void |
close()
Closes a currently open queue. |
boolean |
isClosed()
Returns true if the queue is currently closed. |
boolean |
isOpen()
Returns true if the queue is currently open. |
void |
open()
Ensures that the queue is open and new elements can be added to the queue. |
java.lang.Object |
remove()
Removes the oldest element from the queue. |
java.lang.Object |
remove(long timeout)
Removes the next element from the queue if one becomes available before the timeout expires. |
| Methods inherited from class org.opennms.core.queue.FifoQueueImpl |
isEmpty, size |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opennms.core.queue.FifoQueue |
isEmpty, size |
| Field Detail |
private volatile boolean m_isClosed
| Constructor Detail |
private RunnableConsumerThreadPool.SizingFifoQueue()
| Method Detail |
private void adjust()
public boolean isOpen()
isOpen in interface ClosableFifoQueuepublic boolean isClosed()
isClosed in interface ClosableFifoQueue
public void close()
throws FifoQueueException
close in interface ClosableFifoQueueFifoQueueException - Thrown
if an error occurs closing the queue.
public void open()
throws FifoQueueException
open in interface ClosableFifoQueueFifoQueueException - Thrown
if an error occurs opening the queue.
public void add(java.lang.Object element)
throws FifoQueueException,
java.lang.InterruptedException
add in interface FifoQueueadd in class FifoQueueImplelement - The object to append to the queue.
FifoQueueException - Thrown if
a queue error occurs.
java.lang.InterruptedException - Thrown if the thread
is interrupted.
public boolean add(java.lang.Object element,
long timeout)
throws FifoQueueException,
java.lang.InterruptedException
timeout expires, then a false value is returned
to the caller.
add in interface FifoQueueadd in class FifoQueueImplelement - The object to append to the queue.timeout - The time to wait on the insertion to succeed.
FifoQueueException - Thrown if
a queue error occurs.
java.lang.InterruptedException - Thrown if the thread
is interrupted.
public java.lang.Object remove()
throws FifoQueueException,
java.lang.InterruptedException
remove in interface FifoQueueremove in class FifoQueueImplFifoQueueException - Thrown if
a queue error occurs.
java.lang.InterruptedException - Thrown if the thread
is interrupted.
public java.lang.Object remove(long timeout)
throws FifoQueueException,
java.lang.InterruptedException
null reference is returned to
the caller.
remove in interface FifoQueueremove in class FifoQueueImpltimeout - The time to wait on an object to be available.
null if
one is not available.
FifoQueueException - Thrown if
a queue error occurs.
java.lang.InterruptedException - Thrown if the thread
is interrupted.
|
OpenNMS API 1.1.4 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||