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>
public class DefaultWaterMarkQueue<T> extends Object implements WaterMarkQueue<T>
A Default implementation for WaterMarkQueue interface. The implementation uses anArrayBlockingQueueup to water mark. Then it uses aLinkedBlockingQueueor ArrayBlocking queue from the water mark point. The LinkedBlockingQueue is used if a queue size is specified other than the waterMark.
-
-
Constructor Summary
Constructors Constructor Description DefaultWaterMarkQueue(int waterMark)Create aWaterMarkQueuewith a waterMark.DefaultWaterMarkQueue(int waterMark, int size)Create aWaterMarkQueuewith a waterMark.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T t)booleanaddAll(Collection<? extends T> ts)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> objects)intdrainTo(Collection<? super T> objects)intdrainTo(Collection<? super T> objects, int i)Telement()booleanisEmpty()Iterator<T>iterator()booleanoffer(T t)booleanoffer(T t, long l, TimeUnit timeUnit)booleanofferAfter(T t)Offer the element after the water mark.Tpeek()Tpoll()Tpoll(long l, TimeUnit timeUnit)voidput(T t)intremainingCapacity()Tremove()booleanremove(Object o)booleanremoveAll(Collection<?> objects)booleanretainAll(Collection<?> objects)intsize()Ttake()Object[]toArray()<T> T[]toArray(T[] ts)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
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 Detail
-
add
public boolean add(T t)
- Specified by:
addin interfaceBlockingQueue<T>- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceQueue<T>
-
offer
public boolean offer(T t)
-
put
public void put(T t) throws InterruptedException
- Specified by:
putin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
offer
public boolean offer(T t, long l, TimeUnit timeUnit) throws InterruptedException
- Specified by:
offerin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
take
public T take() throws InterruptedException
- Specified by:
takein interfaceBlockingQueue<T>- Throws:
InterruptedException
-
poll
public T poll(long l, TimeUnit timeUnit) throws InterruptedException
- Specified by:
pollin interfaceBlockingQueue<T>- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacityin interfaceBlockingQueue<T>
-
remove
public boolean remove(Object o)
- Specified by:
removein interfaceBlockingQueue<T>- Specified by:
removein interfaceCollection<T>
-
containsAll
public boolean containsAll(Collection<?> objects)
- Specified by:
containsAllin interfaceCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> ts)
- Specified by:
addAllin interfaceCollection<T>
-
removeAll
public boolean removeAll(Collection<?> objects)
- Specified by:
removeAllin interfaceCollection<T>
-
retainAll
public boolean retainAll(Collection<?> objects)
- 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
public boolean contains(Object o)
- Specified by:
containsin interfaceBlockingQueue<T>- Specified by:
containsin interfaceCollection<T>
-
toArray
public Object[] toArray()
- Specified by:
toArrayin interfaceCollection<T>
-
toArray
public <T> T[] toArray(T[] ts)
- Specified by:
toArrayin interfaceCollection<T>
-
drainTo
public int drainTo(Collection<? super T> objects)
- Specified by:
drainToin interfaceBlockingQueue<T>
-
drainTo
public int drainTo(Collection<? super T> objects, int i)
- Specified by:
drainToin interfaceBlockingQueue<T>
-
offerAfter
public boolean offerAfter(T t)
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
-
-