Class MemoryBoundLinkedBlockingQueue<T>
- java.lang.Object
-
- org.apache.druid.java.util.common.MemoryBoundLinkedBlockingQueue<T>
-
public class MemoryBoundLinkedBlockingQueue<T> extends Object
Similar to LinkedBlockingQueue but can be bounded by the total byte size of the items present in the queue rather than number of items.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMemoryBoundLinkedBlockingQueue.ObjectContainer<T>
-
Constructor Summary
Constructors Constructor Description MemoryBoundLinkedBlockingQueue(long memoryBound)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longbyteSize()intdrain(Collection<? super MemoryBoundLinkedBlockingQueue.ObjectContainer<T>> buffer, int bytesToDrain, long timeout, TimeUnit unit)Drain up to specified bytes worth of items from the queue into the provided buffer.booleanoffer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item)booleanoffer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item, long timeout, TimeUnit unit)longremainingCapacity()intsize()Stream<MemoryBoundLinkedBlockingQueue.ObjectContainer<T>>stream()MemoryBoundLinkedBlockingQueue.ObjectContainer<T>take()
-
-
-
Method Detail
-
offer
public boolean offer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item)
-
offer
public boolean offer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item, long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
take
public MemoryBoundLinkedBlockingQueue.ObjectContainer<T> take() throws InterruptedException
- Throws:
InterruptedException
-
stream
public Stream<MemoryBoundLinkedBlockingQueue.ObjectContainer<T>> stream()
-
drain
public int drain(Collection<? super MemoryBoundLinkedBlockingQueue.ObjectContainer<T>> buffer, int bytesToDrain, long timeout, TimeUnit unit) throws InterruptedException
Drain up to specified bytes worth of items from the queue into the provided buffer. At least one record is drained from the queue, regardless of the value of bytes specified.- Parameters:
buffer- The buffer to drain queue items into.bytesToDrain- The amount of bytes to drain from the queuetimeout- The maximum time allowed to drain the queueunit- The time unit of the timeout.- Returns:
- The number of items drained from the queue.
- Throws:
InterruptedException
-
size
public int size()
-
byteSize
public long byteSize()
-
remainingCapacity
public long remainingCapacity()
-
-