Class MemoryBoundLinkedBlockingQueue<T>
java.lang.Object
org.apache.druid.java.util.common.MemoryBoundLinkedBlockingQueue<T>
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongbyteSize()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.booleanbooleanoffer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item, long timeout, TimeUnit unit) longintsize()stream()take()
-
Constructor Details
-
MemoryBoundLinkedBlockingQueue
public MemoryBoundLinkedBlockingQueue(long memoryBound)
-
-
Method Details
-
offer
-
offer
public boolean offer(MemoryBoundLinkedBlockingQueue.ObjectContainer<T> item, long timeout, TimeUnit unit) throws InterruptedException - Throws:
InterruptedException
-
take
- Throws:
InterruptedException
-
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()
-