CallQueueManager (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.ipc, class: CallQueueManager

Package org.apache.hadoop.ipc

# Class CallQueueManager<E extends Schedulable>

java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
org.apache.hadoop.ipc.CallQueueManager<E>

All Implemented Interfaces:
  `Iterable<E>`, `Collection<E>`, `BlockingQueue<E>`, `Queue<E>`

public class CallQueueManager<E extends Schedulable> extends AbstractQueue<E> implements BlockingQueue<E>
Abstracts queue operations for different blocking queues.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CallQueueManager(Class<? extends BlockingQueue<E>> backingClass, Class<? extends RpcScheduler> schedulerClass, boolean clientBackOffEnabled, int maxQueueSize, String namespace, Configuration conf)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `add(E e)`
  `int`
  `drainTo(Collection<? super E> c)`
  `int`
  `drainTo(Collection<? super E> c, int maxElements)`
  `static int[]`
  `getDefaultQueueCapacityWeights(int priorityLevels)`
  By default, queue capacity is the same for all priority levels.
  `boolean`
  `isServerFailOverEnabled()`
  `boolean`
  `isServerFailOverEnabledByQueue()`
  `Iterator<E>`
  `iterator()`
  `boolean`
  `offer(E e)`
  Insert e into the backing queue.
  `boolean`
  `offer(E e, long timeout, TimeUnit unit)`
  `E`
  `peek()`
  `E`
  `poll()`
  `E`
  `poll(long timeout, TimeUnit unit)`
  `void`
  `put(E e)`
  Insert e into the backing queue or block until we can.
  `int`
  `remainingCapacity()`
  `int`
  `size()`
  `void`
  `swapQueue(Class<? extends RpcScheduler> schedulerClass, Class<? extends BlockingQueue<E>> queueClassToUse, int maxSize, String ns, Configuration conf)`
  Replaces active queue with the newly requested one and transfers all calls to the newQ before returning.
  `E`
  `take()`
  Retrieve an E from the backing queue or block until we can.

  ### Methods inherited from class java.util.AbstractQueue

  `addAll, clear, element, remove`

  ### Methods inherited from class java.util.AbstractCollection

  `contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.util.concurrent.BlockingQueue

  `contains, remove`

  ### Methods inherited from interface java.util.Collection

  `addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### Methods inherited from interface java.util.Queue

  `element, remove`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### CallQueueManager

    public CallQueueManager(Class<? extends BlockingQueue<E>> backingClass, Class<? extends RpcScheduler> schedulerClass, boolean clientBackOffEnabled, int maxQueueSize, String namespace, Configuration conf)

- ## Method Details

  - ### isServerFailOverEnabled

    @VisibleForTesting public boolean isServerFailOverEnabled()

  - ### isServerFailOverEnabledByQueue

    @VisibleForTesting public boolean isServerFailOverEnabledByQueue()

  - ### put

    public void put(E e) throws InterruptedException
    Insert e into the backing queue or block until we can. If client backoff is enabled this method behaves like add which throws if the queue overflows. If we block and the queue changes on us, we will insert while the queue is drained.
    Specified by:
      `put` in interface `BlockingQueue<E extends Schedulable>`
    Throws:
      `InterruptedException`

  - ### add

    public boolean add(E e)
    Specified by:
      `add` in interface `BlockingQueue<E extends Schedulable>`
    Specified by:
      `add` in interface `Collection<E extends Schedulable>`
    Specified by:
      `add` in interface `Queue<E extends Schedulable>`
    Overrides:
      `add` in class `AbstractQueue<E extends Schedulable>`

  - ### offer

    public boolean offer(E e)
    Insert e into the backing queue. Return true if e is queued. Return false if the queue is full.
    Specified by:
      `offer` in interface `BlockingQueue<E extends Schedulable>`
    Specified by:
      `offer` in interface `Queue<E extends Schedulable>`

  - ### offer

    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException
    Specified by:
      `offer` in interface `BlockingQueue<E extends Schedulable>`
    Throws:
      `InterruptedException`

  - ### peek

    public E peek()
    Specified by:
      `peek` in interface `Queue<E extends Schedulable>`

  - ### poll

    public E poll()
    Specified by:
      `poll` in interface `Queue<E extends Schedulable>`

  - ### poll

    public E poll(long timeout, TimeUnit unit) throws InterruptedException
    Specified by:
      `poll` in interface `BlockingQueue<E extends Schedulable>`
    Throws:
      `InterruptedException`

  - ### take

    public E take() throws InterruptedException
    Retrieve an E from the backing queue or block until we can. Guaranteed to return an element from the current queue.
    Specified by:
      `take` in interface `BlockingQueue<E extends Schedulable>`
    Throws:
      `InterruptedException`

  - ### size

    public int size()
    Specified by:
      `size` in interface `Collection<E extends Schedulable>`
    Specified by:
      `size` in class `AbstractCollection<E extends Schedulable>`

  - ### remainingCapacity

    public int remainingCapacity()
    Specified by:
      `remainingCapacity` in interface `BlockingQueue<E extends Schedulable>`

  - ### getDefaultQueueCapacityWeights

    public static int[] getDefaultQueueCapacityWeights(int priorityLevels)
    By default, queue capacity is the same for all priority levels.
    Parameters:
      `priorityLevels` - number of levels
    Returns:
      default weights

  - ### swapQueue

    public void swapQueue(Class<? extends RpcScheduler> schedulerClass, Class<? extends BlockingQueue<E>> queueClassToUse, int maxSize, String ns, Configuration conf)
    Replaces active queue with the newly requested one and transfers all calls to the newQ before returning.
    Parameters:
      `schedulerClass` - input schedulerClass.
      `queueClassToUse` - input queueClassToUse.
      `maxSize` - input maxSize.
      `ns` - input ns.
      `conf` - input configuration.

  - ### drainTo

    public int drainTo(Collection<? super E> c)
    Specified by:
      `drainTo` in interface `BlockingQueue<E extends Schedulable>`

  - ### drainTo

    public int drainTo(Collection<? super E> c, int maxElements)
    Specified by:
      `drainTo` in interface `BlockingQueue<E extends Schedulable>`

  - ### iterator

    public Iterator<E> iterator()
    Specified by:
      `iterator` in interface `Collection<E extends Schedulable>`
    Specified by:
      `iterator` in interface `Iterable<E extends Schedulable>`
    Specified by:
      `iterator` in class `AbstractCollection<E extends Schedulable>`