Package com.linkedin.alpini.base.queuing
Class QOSBasedQueue<T extends QOSBasedRequestRunnable>
- java.lang.Object
-
- com.linkedin.alpini.base.queuing.AbstractQOS
-
- com.linkedin.alpini.base.queuing.AbstractQOSBasedQueue<T>
-
- com.linkedin.alpini.base.queuing.QOSBasedQueue<T>
-
- Type Parameters:
T
-
- All Implemented Interfaces:
SimpleQueue<T>
public class QOSBasedQueue<T extends QOSBasedRequestRunnable> extends AbstractQOSBasedQueue<T>
Implementation ofSimpleQueue
. Internally, it maintains separate queues for each QOS level and responds to poll() or peek() requests from any one of the queues (probabilistically). Addition to this queue, causes the element to be queued together with elements of the same QOS type. Each sub-queue can be configured with a "percentage-slice" i.e. the fraction of poll()/peek() requests that must delegate to it. For e.g. the default slices are "HIGH-80%, NORMAL-15%, LOW-5%". This means that LOW QOS requests will be dequeued at most 5% of the time. Thus a large volume of LOW QOS requests cannot affect higher QOS level, and it also means that higher QOS requests cannot starve lower QOS requests.
-
-
Field Summary
-
Fields inherited from class com.linkedin.alpini.base.queuing.AbstractQOS
_allocationTotal, _log, _qosBasedAllocations
-
-
Constructor Summary
Constructors Constructor Description QOSBasedQueue()
QOSBasedQueue(java.util.Map<QOS,java.lang.Integer> qosBasedAllocations)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T e)
boolean
isEmpty()
Checks if queue is empty.int
size()
-
Methods inherited from class com.linkedin.alpini.base.queuing.AbstractQOSBasedQueue
getQOS, getQueueName, poll
-
Methods inherited from class com.linkedin.alpini.base.queuing.AbstractQOS
getDefaultQOSAllocation, getQueuePollOrder
-
-
-
-
Constructor Detail
-
QOSBasedQueue
public QOSBasedQueue()
-
QOSBasedQueue
public QOSBasedQueue(java.util.Map<QOS,java.lang.Integer> qosBasedAllocations)
-
-
Method Detail
-
add
public boolean add(@Nonnull T e)
- See Also:
Queue.add(Object)
-
size
public int size()
- See Also:
Collection.size()
-
isEmpty
public boolean isEmpty()
Description copied from interface:SimpleQueue
Checks if queue is empty.- Returns:
true
if Queue contains no elements,false
otherwise.
-
-