org.opennms.netmgt.linkd.scheduler
Class Scheduler.PeekableFifoQueue

java.lang.Object
  extended by org.opennms.core.queue.FifoQueueImpl
      extended by org.opennms.netmgt.linkd.scheduler.Scheduler.PeekableFifoQueue
All Implemented Interfaces:
org.opennms.core.queue.FifoQueue
Enclosing class:
Scheduler

public static final class Scheduler.PeekableFifoQueue
extends org.opennms.core.queue.FifoQueueImpl

This queue extends the standard FIFO queue instance so that it is possible to peek at an instance without removing it from the queue.


Method Summary
 boolean isEmpty()
          Used to test if the current queue has no stored elements.
 java.lang.Object peek()
          This method allows the caller to peek at the next object that would be returned on a remove call.
 java.lang.Object remove()
          Removes the next element from the queue and returns it to the caller.
 java.lang.Object remove(long timeout)
          Removes the next element from the queue and returns it to the caller.
 
Methods inherited from class org.opennms.core.queue.FifoQueueImpl
add, add, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

peek

public java.lang.Object peek()
                      throws java.lang.InterruptedException,
                             org.opennms.core.queue.FifoQueueException
This method allows the caller to peek at the next object that would be returned on a remove call. If the queue is currently empty then the caller is blocked until an object is put into the queue.

Returns:
The object that would be returned on the next call to remove.
Throws:
java.lang.InterruptedException - Thrown if the thread is interrupted.
org.opennms.core.queue.FifoQueueException - Thrown if an error occurs removing an item from the queue.

remove

public java.lang.Object remove()
                        throws java.lang.InterruptedException,
                               org.opennms.core.queue.FifoQueueException
Removes the next element from the queue and returns it to the caller. If there is no objects available then the caller is blocked until an item is available.

Specified by:
remove in interface org.opennms.core.queue.FifoQueue
Overrides:
remove in class org.opennms.core.queue.FifoQueueImpl
Returns:
The next element in the queue.
Throws:
java.lang.InterruptedException - Thrown if the thread is interrupted.
org.opennms.core.queue.FifoQueueException - Thrown if an error occurs removing an item from the queue.

remove

public java.lang.Object remove(long timeout)
                        throws java.lang.InterruptedException,
                               org.opennms.core.queue.FifoQueueException
Removes the next element from the queue and returns it to the caller. If there is no objects available then the caller is blocked until an item is available. If an object is not available within the time frame specified by timeout.

Specified by:
remove in interface org.opennms.core.queue.FifoQueue
Overrides:
remove in class org.opennms.core.queue.FifoQueueImpl
Parameters:
timeout - The maximum time to wait.
Returns:
The next element in the queue.
Throws:
java.lang.InterruptedException - Thrown if the thread is interrupted.
org.opennms.core.queue.FifoQueueException - Thrown if an error occurs removing an item from the queue.

isEmpty

public boolean isEmpty()
Used to test if the current queue has no stored elements.

Specified by:
isEmpty in interface org.opennms.core.queue.FifoQueue
Overrides:
isEmpty in class org.opennms.core.queue.FifoQueueImpl
Returns:
True if the queue is empty.


Copyright © 2007. All Rights Reserved.