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 anArrayBlockingQueue
up to water mark. Then it uses aLinkedBlockingQueue
or 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 aWaterMarkQueue
with a waterMark.DefaultWaterMarkQueue(int waterMark, int size)
Create aWaterMarkQueue
with a waterMark.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T t)
boolean
addAll(Collection<? extends T> ts)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> objects)
int
drainTo(Collection<? super T> objects)
int
drainTo(Collection<? super T> objects, int i)
T
element()
boolean
isEmpty()
Iterator<T>
iterator()
boolean
offer(T t)
boolean
offer(T t, long l, TimeUnit timeUnit)
boolean
offerAfter(T t)
Offer the element after the water mark.T
peek()
T
poll()
T
poll(long l, TimeUnit timeUnit)
void
put(T t)
int
remainingCapacity()
T
remove()
boolean
remove(Object o)
boolean
removeAll(Collection<?> objects)
boolean
retainAll(Collection<?> objects)
int
size()
T
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, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Constructor Detail
-
DefaultWaterMarkQueue
public DefaultWaterMarkQueue(int waterMark)
Create aWaterMarkQueue
with a waterMark. The queue will first fill up to waterMark. These items will be inserted in to anArrayBlockingQueue
. After this anLinkedBlockingQueue
will be used without a bound.- Parameters:
waterMark
- the waterMark of the queue
-
DefaultWaterMarkQueue
public DefaultWaterMarkQueue(int waterMark, int size)
Create aWaterMarkQueue
with a waterMark. The queue will first fill up to waterMark. These items will be inserted in to anArrayBlockingQueue
. After this anLinkedBlockingQueue
will 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:
add
in interfaceBlockingQueue<T>
- Specified by:
add
in interfaceCollection<T>
- Specified by:
add
in interfaceQueue<T>
-
offer
public boolean offer(T t)
-
put
public void put(T t) throws InterruptedException
- Specified by:
put
in interfaceBlockingQueue<T>
- Throws:
InterruptedException
-
offer
public boolean offer(T t, long l, TimeUnit timeUnit) throws InterruptedException
- Specified by:
offer
in interfaceBlockingQueue<T>
- Throws:
InterruptedException
-
take
public T take() throws InterruptedException
- Specified by:
take
in interfaceBlockingQueue<T>
- Throws:
InterruptedException
-
poll
public T poll(long l, TimeUnit timeUnit) throws InterruptedException
- Specified by:
poll
in interfaceBlockingQueue<T>
- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity
in interfaceBlockingQueue<T>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceBlockingQueue<T>
- Specified by:
remove
in interfaceCollection<T>
-
containsAll
public boolean containsAll(Collection<?> objects)
- Specified by:
containsAll
in interfaceCollection<T>
-
addAll
public boolean addAll(Collection<? extends T> ts)
- Specified by:
addAll
in interfaceCollection<T>
-
removeAll
public boolean removeAll(Collection<?> objects)
- Specified by:
removeAll
in interfaceCollection<T>
-
retainAll
public boolean retainAll(Collection<?> objects)
- Specified by:
retainAll
in interfaceCollection<T>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<T>
-
size
public int size()
- Specified by:
size
in interfaceCollection<T>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<T>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceBlockingQueue<T>
- Specified by:
contains
in interfaceCollection<T>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<T>
-
toArray
public <T> T[] toArray(T[] ts)
- Specified by:
toArray
in interfaceCollection<T>
-
drainTo
public int drainTo(Collection<? super T> objects)
- Specified by:
drainTo
in interfaceBlockingQueue<T>
-
drainTo
public int drainTo(Collection<? super T> objects, int i)
- Specified by:
drainTo
in interfaceBlockingQueue<T>
-
offerAfter
public boolean offerAfter(T t)
Description copied from interface:WaterMarkQueue
Offer the element after the water mark.- Specified by:
offerAfter
in interfaceWaterMarkQueue<T>
- Parameters:
t
- object to be inserted- Returns:
- true if the insert is successful
-
-