Module org.elasticsearch.server
Class SizeBlockingQueue<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
org.elasticsearch.common.util.concurrent.SizeBlockingQueue<E>
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,BlockingQueue<E>
,Queue<E>
A size based queue wrapping another blocking queue to provide (somewhat relaxed) capacity checks.
Mainly makes sense to use with blocking queues that are unbounded to provide the ability to do
capacity verification.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
boolean
boolean
containsAll
(Collection<?> c) int
drainTo
(Collection<? super E> c) int
drainTo
(Collection<? super E> c, int maxElements) void
Forces adding an element to the queue, without doing size checks.iterator()
boolean
boolean
peek()
poll()
void
int
boolean
int
size()
take()
Object[]
toArray()
<T> T[]
toArray
(T[] a) Methods inherited from class java.util.AbstractCollection
isEmpty, removeAll, retainAll, toString
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.Collection
addAll, clear, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray
-
Constructor Details
-
SizeBlockingQueue
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in classAbstractCollection<E>
-
capacity
public int capacity() -
iterator
- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in classAbstractCollection<E>
-
peek
-
poll
-
poll
- Specified by:
poll
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
remove
- Specified by:
remove
in interfaceBlockingQueue<E>
- Specified by:
remove
in interfaceCollection<E>
- Overrides:
remove
in classAbstractCollection<E>
-
forcePut
Forces adding an element to the queue, without doing size checks.- Throws:
InterruptedException
-
offer
-
offer
- Specified by:
offer
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
put
- Specified by:
put
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
take
- Specified by:
take
in interfaceBlockingQueue<E>
- Throws:
InterruptedException
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacity
in interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<E>
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceBlockingQueue<E>
- Specified by:
contains
in interfaceCollection<E>
- Overrides:
contains
in classAbstractCollection<E>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-