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
Modifier and TypeFieldDescriptionprivate int
private int
private long
private AtomicBoolean
private double
private int
private long
private LongAdder
private LongAdder
private LinkedBlockingDeque<CallRunner>
private AtomicBoolean
-
Constructor Summary
ConstructorDescriptionAdaptiveLifoCoDelCallQueue
(int capacity, int targetDelay, int interval, double lifoThreshold, LongAdder numGeneralCallsDropped, LongAdder numLifoModeSwitches) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(CallRunner callRunner) boolean
addAll
(Collection<? extends CallRunner> c) void
clear()
boolean
boolean
containsAll
(Collection<?> c) int
drainTo
(Collection<? super CallRunner> c) int
drainTo
(Collection<? super CallRunner> c, int maxElements) element()
boolean
isEmpty()
iterator()
private boolean
needToDrop
(CallRunner callRunner) boolean
offer
(CallRunner callRunner) boolean
offer
(CallRunner callRunner, long timeout, TimeUnit unit) peek()
poll()
void
put
(CallRunner callRunner) int
remove()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
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()
void
updateTunables
(int newCodelTargetDelay, int newCodelInterval, double newLifoThreshold) Update tunables.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream
-
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:
take
in interfaceBlockingQueue<CallRunner>
- Returns:
- the head of this queue
- Throws:
InterruptedException
- if interrupted while waiting
-
poll
- Specified by:
poll
in 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:
offer
in interfaceBlockingQueue<CallRunner>
- Specified by:
offer
in interfaceQueue<CallRunner>
-
size
- Specified by:
size
in interfaceCollection<CallRunner>
-
toString
-
poll
- Specified by:
poll
in interfaceBlockingQueue<CallRunner>
- Throws:
InterruptedException
-
peek
- Specified by:
peek
in interfaceQueue<CallRunner>
-
remove
- Specified by:
remove
in interfaceBlockingQueue<CallRunner>
- Specified by:
remove
in interfaceCollection<CallRunner>
-
contains
- Specified by:
contains
in interfaceBlockingQueue<CallRunner>
- Specified by:
contains
in interfaceCollection<CallRunner>
-
toArray
- Specified by:
toArray
in interfaceCollection<CallRunner>
-
toArray
- Specified by:
toArray
in interfaceCollection<CallRunner>
-
clear
- Specified by:
clear
in interfaceCollection<CallRunner>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<CallRunner>
-
drainTo
- Specified by:
drainTo
in interfaceBlockingQueue<CallRunner>
-
iterator
- Specified by:
iterator
in interfaceCollection<CallRunner>
- Specified by:
iterator
in interfaceIterable<CallRunner>
-
add
- Specified by:
add
in interfaceBlockingQueue<CallRunner>
- Specified by:
add
in interfaceCollection<CallRunner>
- Specified by:
add
in interfaceQueue<CallRunner>
-
remove
- Specified by:
remove
in interfaceQueue<CallRunner>
-
element
- Specified by:
element
in interfaceQueue<CallRunner>
-
addAll
- Specified by:
addAll
in interfaceCollection<CallRunner>
-
isEmpty
- Specified by:
isEmpty
in interfaceCollection<CallRunner>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<CallRunner>
-
removeAll
- Specified by:
removeAll
in interfaceCollection<CallRunner>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<CallRunner>
-
remainingCapacity
- Specified by:
remainingCapacity
in interfaceBlockingQueue<CallRunner>
-
put
- Specified by:
put
in interfaceBlockingQueue<CallRunner>
- Throws:
InterruptedException
-
offer
public boolean offer(CallRunner callRunner, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
offer
in interfaceBlockingQueue<CallRunner>
- Throws:
InterruptedException
-