org.apache.oozie.util
Class PriorityDelayQueue.QueueElement<E>

java.lang.Object
  extended by org.apache.oozie.util.PriorityDelayQueue.QueueElement<E>
All Implemented Interfaces:
Comparable<Delayed>, Delayed
Enclosing class:
PriorityDelayQueue<E>

public static class PriorityDelayQueue.QueueElement<E>
extends Object
implements Delayed

Element wrapper required by the queue.

This wrapper keeps track of the priority and the age of a queue element.


Constructor Summary
PriorityDelayQueue.QueueElement(E element)
          Create an Element wrapper with no delay and minimum priority.
PriorityDelayQueue.QueueElement(E element, int priority, long delay, TimeUnit unit)
          Create an Element wrapper.
 
Method Summary
 int compareTo(Delayed o)
          Compare the age of this wrapper element with another.
 long getDelay(TimeUnit unit)
          Return the delay of the element.
 E getElement()
          Return the element from the wrapper.
 int getPriority()
          Return the priority of the element.
 void setDelay(long delay, TimeUnit unit)
          Set the delay of the element.
 String toString()
          Return the string representation of the wrapper element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PriorityDelayQueue.QueueElement

public PriorityDelayQueue.QueueElement(E element,
                                       int priority,
                                       long delay,
                                       TimeUnit unit)
Create an Element wrapper.

Parameters:
element - element.
priority - priority of the element.
delay - delay of the element.
unit - time unit of the delay.
Throws:
IllegalArgumentException - if the element is NULL, the priority is negative or if the delay is negative.

PriorityDelayQueue.QueueElement

public PriorityDelayQueue.QueueElement(E element)
Create an Element wrapper with no delay and minimum priority.

Parameters:
element - element.
Method Detail

getElement

public E getElement()
Return the element from the wrapper.

Returns:
the element.

getPriority

public int getPriority()
Return the priority of the element.

Returns:
the priority of the element.

setDelay

public void setDelay(long delay,
                     TimeUnit unit)
Set the delay of the element.

Parameters:
delay - delay of the element.
unit - time unit of the delay.

getDelay

public long getDelay(TimeUnit unit)
Return the delay of the element.

Specified by:
getDelay in interface Delayed
Parameters:
unit - time unit of the delay.
Returns:
the delay in the specified time unit.

compareTo

public int compareTo(Delayed o)
Compare the age of this wrapper element with another. The priority is not used for the comparision.

Specified by:
compareTo in interface Comparable<Delayed>
Parameters:
o - the other wrapper element to compare with.
Returns:
less than zero if this wrapper is older, zero if both wrapper elements have the same age, greater than zero if the parameter wrapper element is older.

toString

public String toString()
Return the string representation of the wrapper element.

Overrides:
toString in class Object
Returns:
the string representation of the wrapper element.


Copyright © 2013 Apache Software Foundation. All Rights Reserved.