Class DefaultWaterMarkQueue<T>
java.lang.Object
org.apache.axis2.transport.base.threads.watermark.DefaultWaterMarkQueue<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Iterable<T>,Collection<T>,BlockingQueue<T>,Queue<T>,WaterMarkQueue<T>
A Default implementation for WaterMarkQueue interface. The implementation uses an
ArrayBlockingQueue up to water mark. Then it uses a LinkedBlockingQueue or
ArrayBlocking queue from the water mark point. The LinkedBlockingQueue is used if a queue
size is specified other than the waterMark.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultWaterMarkQueue(int waterMark) Create aWaterMarkQueuewith a waterMark.DefaultWaterMarkQueue(int waterMark, int size) Create aWaterMarkQueuewith a waterMark. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> ts) voidclear()booleanbooleancontainsAll(Collection<?> objects) intdrainTo(Collection<? super T> objects) intdrainTo(Collection<? super T> objects, int i) element()booleanisEmpty()iterator()booleanbooleanbooleanofferAfter(T t) Offer the element after the water mark.peek()poll()voidintremove()booleanbooleanremoveAll(Collection<?> objects) booleanretainAll(Collection<?> objects) intsize()take()Object[]toArray()<T> T[]toArray(T[] ts) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Constructor Details
-
DefaultWaterMarkQueue
public DefaultWaterMarkQueue(int waterMark) Create aWaterMarkQueuewith a waterMark. The queue will first fill up to waterMark. These items will be inserted in to anArrayBlockingQueue. After this anLinkedBlockingQueuewill be used without a bound.- Parameters:
waterMark- the waterMark of the queue
-
DefaultWaterMarkQueue
public DefaultWaterMarkQueue(int waterMark, int size) Create aWaterMarkQueuewith a waterMark. The queue will first fill up to waterMark. These items will be inserted in to anArrayBlockingQueue. After this anLinkedBlockingQueuewill be used with capacitysize - waterMark.- Parameters:
waterMark- the waterMark of the queuesize- the size of the queue
-
-
Method Details
-
add
- Specified by:
addin interfaceBlockingQueue<T>- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceQueue<T>
-
offer
-
remove
-
poll
-
element
-
peek
-
put
- Specified by:
putin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
offer
- Specified by:
offerin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
take
- Specified by:
takein interfaceBlockingQueue<T>- Throws:
InterruptedException
-
poll
- Specified by:
pollin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<T>
-
remove
- Specified by:
removein interfaceBlockingQueue<T>- Specified by:
removein interfaceCollection<T>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>
-
addAll
- Specified by:
addAllin interfaceCollection<T>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T>
-
size
public int size()- Specified by:
sizein interfaceCollection<T>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T>
-
contains
- Specified by:
containsin interfaceBlockingQueue<T>- Specified by:
containsin interfaceCollection<T>
-
iterator
-
toArray
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public <T> T[] toArray(T[] ts) - Specified by:
toArrayin interfaceCollection<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<T>
-
offerAfter
Description copied from interface:WaterMarkQueueOffer the element after the water mark.- Specified by:
offerAfterin interfaceWaterMarkQueue<T>- Parameters:
t- object to be inserted- Returns:
- true if the insert is successful
-