Class QOSBasedQueue<T extends QOSBasedRequestRunnable>

  • Type Parameters:
    T -
    All Implemented Interfaces:
    SimpleQueue<T>

    public class QOSBasedQueue<T extends QOSBasedRequestRunnable>
    extends AbstractQOSBasedQueue<T>
    Implementation of SimpleQueue. 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.
    • 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.