Package org.apache.hadoop.hbase.ipc
Class AdaptiveLifoCoDelCallQueue
java.lang.Object
org.apache.hadoop.hbase.ipc.AdaptiveLifoCoDelCallQueue
- All Implemented Interfaces:
Iterable<CallRunner>,Collection<CallRunner>,BlockingQueue<CallRunner>,Queue<CallRunner>
@Private
public class AdaptiveLifoCoDelCallQueue
extends Object
implements BlockingQueue<CallRunner>
Adaptive LIFO blocking queue utilizing CoDel algorithm to prevent queue overloading. Implementing
BlockingQueue interface to be compatible with RpcExecutor. Currently uses
milliseconds internally, need to look into whether we should use nanoseconds for timeInterval and
minDelay.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate intprivate longprivate AtomicBooleanprivate doubleprivate intprivate longprivate LongAdderprivate LongAdderprivate LinkedBlockingDeque<CallRunner>private AtomicBoolean -
Constructor Summary
ConstructorsConstructorDescriptionAdaptiveLifoCoDelCallQueue(int capacity, int targetDelay, int interval, double lifoThreshold, LongAdder numGeneralCallsDropped, LongAdder numLifoModeSwitches) -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(CallRunner callRunner) booleanaddAll(Collection<? extends CallRunner> c) voidclear()booleanbooleancontainsAll(Collection<?> c) intdrainTo(Collection<? super CallRunner> c) intdrainTo(Collection<? super CallRunner> c, int maxElements) element()booleanisEmpty()iterator()private booleanneedToDrop(CallRunner callRunner) booleanoffer(CallRunner callRunner) booleanoffer(CallRunner callRunner, long timeout, TimeUnit unit) peek()poll()voidput(CallRunner callRunner) intremove()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()take()Behaves asLinkedBlockingQueue.take(), except it will silently skip all calls which it thinks should be dropped.Object[]toArray()<T> T[]toArray(T[] a) toString()voidupdateTunables(int newCodelTargetDelay, int newCodelInterval, double newLifoThreshold) Update tunables.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
Field Details
-
queue
-
maxCapacity
-
numGeneralCallsDropped
-
numLifoModeSwitches
-
codelTargetDelay
-
codelInterval
-
lifoThreshold
-
minDelay
-
intervalTime
-
resetDelay
-
isOverloaded
-
-
Constructor Details
-
AdaptiveLifoCoDelCallQueue
public AdaptiveLifoCoDelCallQueue(int capacity, int targetDelay, int interval, double lifoThreshold, LongAdder numGeneralCallsDropped, LongAdder numLifoModeSwitches)
-
-
Method Details
-
updateTunables
Update tunables.- Parameters:
newCodelTargetDelay- new CoDel target delaynewCodelInterval- new CoDel intervalnewLifoThreshold- new Adaptive Lifo threshold
-
take
Behaves asLinkedBlockingQueue.take(), except it will silently skip all calls which it thinks should be dropped.- Specified by:
takein interfaceBlockingQueue<CallRunner>- Returns:
- the head of this queue
- Throws:
InterruptedException- if interrupted while waiting
-
poll
- Specified by:
pollin interfaceQueue<CallRunner>
-
needToDrop
- Parameters:
callRunner- to validate- Returns:
- true if this call needs to be skipped based on call timestamp and internal queue state (deemed overloaded).
-
offer
- Specified by:
offerin interfaceBlockingQueue<CallRunner>- Specified by:
offerin interfaceQueue<CallRunner>
-
size
- Specified by:
sizein interfaceCollection<CallRunner>
-
toString
-
poll
- Specified by:
pollin interfaceBlockingQueue<CallRunner>- Throws:
InterruptedException
-
peek
- Specified by:
peekin interfaceQueue<CallRunner>
-
remove
- Specified by:
removein interfaceBlockingQueue<CallRunner>- Specified by:
removein interfaceCollection<CallRunner>
-
contains
- Specified by:
containsin interfaceBlockingQueue<CallRunner>- Specified by:
containsin interfaceCollection<CallRunner>
-
toArray
- Specified by:
toArrayin interfaceCollection<CallRunner>
-
toArray
- Specified by:
toArrayin interfaceCollection<CallRunner>
-
clear
- Specified by:
clearin interfaceCollection<CallRunner>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<CallRunner>
-
drainTo
- Specified by:
drainToin interfaceBlockingQueue<CallRunner>
-
iterator
- Specified by:
iteratorin interfaceCollection<CallRunner>- Specified by:
iteratorin interfaceIterable<CallRunner>
-
add
- Specified by:
addin interfaceBlockingQueue<CallRunner>- Specified by:
addin interfaceCollection<CallRunner>- Specified by:
addin interfaceQueue<CallRunner>
-
remove
- Specified by:
removein interfaceQueue<CallRunner>
-
element
- Specified by:
elementin interfaceQueue<CallRunner>
-
addAll
- Specified by:
addAllin interfaceCollection<CallRunner>
-
isEmpty
- Specified by:
isEmptyin interfaceCollection<CallRunner>
-
containsAll
- Specified by:
containsAllin interfaceCollection<CallRunner>
-
removeAll
- Specified by:
removeAllin interfaceCollection<CallRunner>
-
retainAll
- Specified by:
retainAllin interfaceCollection<CallRunner>
-
remainingCapacity
- Specified by:
remainingCapacityin interfaceBlockingQueue<CallRunner>
-
put
- Specified by:
putin interfaceBlockingQueue<CallRunner>- Throws:
InterruptedException
-
offer
public boolean offer(CallRunner callRunner, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
offerin interfaceBlockingQueue<CallRunner>- Throws:
InterruptedException
-