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 -
Constructor Summary
ConstructorsConstructorDescriptionCallQueueManager(Class<? extends BlockingQueue<E>> backingClass, Class<? extends RpcScheduler> schedulerClass, boolean clientBackOffEnabled, int maxQueueSize, String namespace, Configuration conf) -
Method Summary
Modifier and TypeMethodDescriptionbooleanintdrainTo(Collection<? super E> c) intdrainTo(Collection<? super E> c, int maxElements) static int[]getDefaultQueueCapacityWeights(int priorityLevels) By default, queue capacity is the same for all priority levels.booleanbooleaniterator()booleanInsert e into the backing queue.booleanpeek()poll()voidInsert e into the backing queue or block until we can.intintsize()voidswapQueue(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.take()Retrieve an E from the backing queue or block until we can.Methods inherited from class java.util.AbstractQueue
addAll, clear, element, removeMethods inherited from class java.util.AbstractCollection
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.BlockingQueue
contains, removeMethods inherited from interface java.util.Collection
addAll, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
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
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:
putin interfaceBlockingQueue<E extends Schedulable>- Throws:
InterruptedException
-
add
- Specified by:
addin interfaceBlockingQueue<E extends Schedulable>- Specified by:
addin interfaceCollection<E extends Schedulable>- Specified by:
addin interfaceQueue<E extends Schedulable>- Overrides:
addin classAbstractQueue<E extends Schedulable>
-
offer
Insert e into the backing queue. Return true if e is queued. Return false if the queue is full.- Specified by:
offerin interfaceBlockingQueue<E extends Schedulable>- Specified by:
offerin interfaceQueue<E extends Schedulable>
-
offer
- Specified by:
offerin interfaceBlockingQueue<E extends Schedulable>- Throws:
InterruptedException
-
peek
- Specified by:
peekin interfaceQueue<E extends Schedulable>
-
poll
- Specified by:
pollin interfaceQueue<E extends Schedulable>
-
poll
- Specified by:
pollin interfaceBlockingQueue<E extends Schedulable>- Throws:
InterruptedException
-
take
Retrieve an E from the backing queue or block until we can. Guaranteed to return an element from the current queue.- Specified by:
takein interfaceBlockingQueue<E extends Schedulable>- Throws:
InterruptedException
-
size
public int size()- Specified by:
sizein interfaceCollection<E extends Schedulable>- Specified by:
sizein classAbstractCollection<E extends Schedulable>
-
remainingCapacity
public int remainingCapacity()- Specified by:
remainingCapacityin interfaceBlockingQueue<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
- Specified by:
drainToin interfaceBlockingQueue<E extends Schedulable>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<E extends Schedulable>
-
iterator
- Specified by:
iteratorin interfaceCollection<E extends Schedulable>- Specified by:
iteratorin interfaceIterable<E extends Schedulable>- Specified by:
iteratorin classAbstractCollection<E extends Schedulable>
-