|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractQueue<E> org.apache.synapse.commons.executors.MultiPriorityBlockingQueue<E>
E
- E should implement the Importance interface.public class MultiPriorityBlockingQueue<E>
This queue implements the BlockingQueue interface. The element should implement the Importance interface.
Internally Queue is implemented as a set of multiple queues corresponding to some fixed priorities. When inserting an element, it will be put in to one of these queues depending on its importance.
Constructor Summary | |
---|---|
MultiPriorityBlockingQueue(List<InternalQueue<E>> queues,
boolean isFixedQueues,
NextQueueAlgorithm<E> algorithm)
Create a queue with the given queues. |
Method Summary | ||
---|---|---|
void |
clear()
|
|
boolean |
contains(Object o)
|
|
int |
drainTo(Collection<? super E> c)
We always give high priority to highest priority elements. |
|
int |
drainTo(Collection<? super E> c,
int maxElements)
We always give high priority to highest priotiry elements. |
|
NextQueueAlgorithm<E> |
getNextQueueAlgorithm()
|
|
List<InternalQueue<E>> |
getQueues()
|
|
boolean |
isEmpty()
|
|
boolean |
isFixedSizeQueues()
|
|
Iterator<E> |
iterator()
|
|
boolean |
offer(E e)
Add the element if space available in the internal queue corresponding to the priority of the object. |
|
boolean |
offer(E e,
long timeout,
TimeUnit unit)
Try to add the element within the given time period. |
|
E |
peek()
|
|
E |
poll()
Block indefinitely until a object is available for retrieval. |
|
E |
poll(long timeout,
TimeUnit unit)
Get the element from the top of the queue. |
|
void |
put(E e)
Put the specified value in to the queue. |
|
int |
remainingCapacity()
|
|
boolean |
remove(Object o)
|
|
int |
size()
|
|
E |
take()
Get an element. |
|
Object[] |
toArray()
|
|
|
toArray(T[] a)
|
|
String |
toString()
|
Methods inherited from class java.util.AbstractQueue |
---|
add, addAll, element, remove |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll, removeAll, retainAll |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.concurrent.BlockingQueue |
---|
add |
Methods inherited from interface java.util.Queue |
---|
element, remove |
Methods inherited from interface java.util.Collection |
---|
addAll, containsAll, equals, hashCode, removeAll, retainAll |
Constructor Detail |
---|
public MultiPriorityBlockingQueue(List<InternalQueue<E>> queues, boolean isFixedQueues, NextQueueAlgorithm<E> algorithm)
This method will create a Queue that accepts objects with only the priorities specified. If a object is submitted with a different priority it will result in an IllegalArgumentException. If the algorithm is null, this queue will use the PRRNextQueueAlgorithm.
queues
- list of InternalQueue to be usedisFixedQueues
- weather fixed size queues are usedalgorithm
- algorithm for calculating next queueMethod Detail |
---|
public void put(E e) throws InterruptedException
put
in interface BlockingQueue<E>
e
- object that implements the Importance interface
InterruptedException
public boolean offer(E e)
offer
in interface BlockingQueue<E>
offer
in interface Queue<E>
e
- element to be added
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<E>
e
- element to be addedtimeout
- time to wait if space not availableunit
- time unit
InterruptedException
- if the thread is interruptedpublic E take() throws InterruptedException
take
in interface BlockingQueue<E>
InterruptedException
- if the thread is interruptedpublic E poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<E>
timeout
- waiting time for element to be availableunit
- time unit
InterruptedException
public int drainTo(Collection<? super E> c)
drainTo
in interface BlockingQueue<E>
c
- collection to drain the items
public int drainTo(Collection<? super E> c, int maxElements)
drainTo
in interface BlockingQueue<E>
c
- collection to drain the itemdmaxElements
- maximum elements to copy
public E poll()
poll
in interface Queue<E>
public int remainingCapacity()
remainingCapacity
in interface BlockingQueue<E>
public E peek()
peek
in interface Queue<E>
public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in class AbstractCollection<E>
public int size()
size
in interface Collection<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in class AbstractCollection<E>
public boolean remove(Object o)
remove
in interface Collection<E>
remove
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
public void clear()
clear
in interface Collection<E>
clear
in class AbstractQueue<E>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public Object[] toArray()
toArray
in interface Collection<E>
toArray
in class AbstractCollection<E>
public List<InternalQueue<E>> getQueues()
public NextQueueAlgorithm<E> getNextQueueAlgorithm()
public boolean isFixedSizeQueues()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |