Package com.linkedin.alpini.base.queuing
Class QOSBasedMultiQueue<T extends QOSBasedRequestRunnable>
- java.lang.Object
-
- com.linkedin.alpini.base.queuing.AbstractQOS
-
- com.linkedin.alpini.base.queuing.AbstractQOSBasedQueue<T>
-
- com.linkedin.alpini.base.queuing.QOSBasedMultiQueue<T>
-
- All Implemented Interfaces:
SimpleQueue<T>
public class QOSBasedMultiQueue<T extends QOSBasedRequestRunnable> extends AbstractQOSBasedQueue<T>
A fair multi-queue based upon a ring topology. For each queue name, a separate queue exists and is inserted into the ring. Reading items from this queue involves examining each queue in order around the ring. The ring only grows in size but that is okay since the number of possible queues is a finite low number.
-
-
Field Summary
-
Fields inherited from class com.linkedin.alpini.base.queuing.AbstractQOS
_allocationTotal, _log, _qosBasedAllocations
-
-
Constructor Summary
Constructors Constructor Description QOSBasedMultiQueue()
QOSBasedMultiQueue(int maxPerQueue, int hardMaxPerQueue, java.util.Map<QOS,java.lang.Integer> qosBasedAllocations)
QOSBasedMultiQueue(int maxPerQueue, 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)
protected int
getMaxPerQueue(QOS qos)
Returns a queue limit for a specifiedQOS
.protected com.linkedin.alpini.base.queuing.QOSBasedMultiQueue.RingEntry
getRingEntry(java.lang.String queueName)
Returns the ring entry forqueueName
or creates a new ring entry as required.boolean
isEmpty()
Checks if queue is empty.protected AbstractQOSBasedQueue<T>
newQOSBasedQueue()
Creates a QOS based queue for a ring element.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
-
QOSBasedMultiQueue
public QOSBasedMultiQueue()
-
QOSBasedMultiQueue
public QOSBasedMultiQueue(int maxPerQueue, java.util.Map<QOS,java.lang.Integer> qosBasedAllocations)
-
QOSBasedMultiQueue
public QOSBasedMultiQueue(int maxPerQueue, int hardMaxPerQueue, java.util.Map<QOS,java.lang.Integer> qosBasedAllocations)
-
-
Method Detail
-
getMaxPerQueue
protected int getMaxPerQueue(QOS qos)
Returns a queue limit for a specifiedQOS
.- Parameters:
qos
- QOS.- Returns:
- limit.
-
newQOSBasedQueue
protected AbstractQOSBasedQueue<T> newQOSBasedQueue()
Creates a QOS based queue for a ring element. One of these is used per named queue. By default, this instantiates an instance ofQOSBasedQueue
.- Returns:
AbstractQOSBasedQueue
instance.
-
getRingEntry
protected com.linkedin.alpini.base.queuing.QOSBasedMultiQueue.RingEntry getRingEntry(java.lang.String queueName)
Returns the ring entry forqueueName
or creates a new ring entry as required.- Parameters:
queueName
- name of ring entry- Returns:
- ring entry.
-
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.
-
-