@InterfaceAudience.Private public class AdaptiveLifoCoDelCallQueue extends Object implements BlockingQueue<CallRunner>
BlockingQueue
interface to be compatible with RpcExecutor
.
Currently uses milliseconds internally, need to look into whether we should use
nanoseconds for timeInterval and minDelay.Modifier and Type | Field and Description |
---|---|
private int |
codelInterval |
private int |
codelTargetDelay |
private long |
intervalTime |
private AtomicBoolean |
isOverloaded |
private double |
lifoThreshold |
private int |
maxCapacity |
private long |
minDelay |
private LongAdder |
numGeneralCallsDropped |
private LongAdder |
numLifoModeSwitches |
private LinkedBlockingDeque<CallRunner> |
queue |
private AtomicBoolean |
resetDelay |
Constructor and Description |
---|
AdaptiveLifoCoDelCallQueue(int capacity,
int targetDelay,
int interval,
double lifoThreshold,
LongAdder numGeneralCallsDropped,
LongAdder numLifoModeSwitches) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(CallRunner callRunner) |
boolean |
addAll(Collection<? extends CallRunner> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
int |
drainTo(Collection<? super CallRunner> c) |
int |
drainTo(Collection<? super CallRunner> c,
int maxElements) |
CallRunner |
element() |
boolean |
isEmpty() |
Iterator<CallRunner> |
iterator() |
private boolean |
needToDrop(CallRunner callRunner) |
boolean |
offer(CallRunner callRunner) |
boolean |
offer(CallRunner callRunner,
long timeout,
TimeUnit unit) |
CallRunner |
peek() |
CallRunner |
poll() |
CallRunner |
poll(long timeout,
TimeUnit unit) |
void |
put(CallRunner callRunner) |
int |
remainingCapacity() |
CallRunner |
remove() |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
int |
size() |
CallRunner |
take()
Behaves as
LinkedBlockingQueue.take() , except it will silently
skip all calls which it thinks should be dropped. |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
String |
toString() |
void |
updateTunables(int newCodelTargetDelay,
int newCodelInterval,
double newLifoThreshold)
Update tunables.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
private LinkedBlockingDeque<CallRunner> queue
private int maxCapacity
private LongAdder numGeneralCallsDropped
private LongAdder numLifoModeSwitches
private volatile int codelTargetDelay
private volatile int codelInterval
private volatile double lifoThreshold
private volatile long minDelay
private volatile long intervalTime
private AtomicBoolean resetDelay
private AtomicBoolean isOverloaded
public AdaptiveLifoCoDelCallQueue(int capacity, int targetDelay, int interval, double lifoThreshold, LongAdder numGeneralCallsDropped, LongAdder numLifoModeSwitches)
public void updateTunables(int newCodelTargetDelay, int newCodelInterval, double newLifoThreshold)
newCodelTargetDelay
- new CoDel target delaynewCodelInterval
- new CoDel intervalnewLifoThreshold
- new Adaptive Lifo thresholdpublic CallRunner take() throws InterruptedException
LinkedBlockingQueue.take()
, except it will silently
skip all calls which it thinks should be dropped.take
in interface BlockingQueue<CallRunner>
InterruptedException
- if interrupted while waitingpublic CallRunner poll()
poll
in interface Queue<CallRunner>
private boolean needToDrop(CallRunner callRunner)
callRunner
- to validatepublic boolean offer(CallRunner callRunner)
offer
in interface BlockingQueue<CallRunner>
offer
in interface Queue<CallRunner>
public int size()
size
in interface Collection<CallRunner>
public CallRunner poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingQueue<CallRunner>
InterruptedException
public CallRunner peek()
peek
in interface Queue<CallRunner>
public boolean remove(Object o)
remove
in interface Collection<CallRunner>
remove
in interface BlockingQueue<CallRunner>
public boolean contains(Object o)
contains
in interface Collection<CallRunner>
contains
in interface BlockingQueue<CallRunner>
public Object[] toArray()
toArray
in interface Collection<CallRunner>
public <T> T[] toArray(T[] a)
toArray
in interface Collection<CallRunner>
public void clear()
clear
in interface Collection<CallRunner>
public int drainTo(Collection<? super CallRunner> c)
drainTo
in interface BlockingQueue<CallRunner>
public int drainTo(Collection<? super CallRunner> c, int maxElements)
drainTo
in interface BlockingQueue<CallRunner>
public Iterator<CallRunner> iterator()
iterator
in interface Iterable<CallRunner>
iterator
in interface Collection<CallRunner>
public boolean add(CallRunner callRunner)
add
in interface Collection<CallRunner>
add
in interface BlockingQueue<CallRunner>
add
in interface Queue<CallRunner>
public CallRunner remove()
remove
in interface Queue<CallRunner>
public CallRunner element()
element
in interface Queue<CallRunner>
public boolean addAll(Collection<? extends CallRunner> c)
addAll
in interface Collection<CallRunner>
public boolean isEmpty()
isEmpty
in interface Collection<CallRunner>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<CallRunner>
public boolean removeAll(Collection<?> c)
removeAll
in interface Collection<CallRunner>
public boolean retainAll(Collection<?> c)
retainAll
in interface Collection<CallRunner>
public int remainingCapacity()
remainingCapacity
in interface BlockingQueue<CallRunner>
public void put(CallRunner callRunner) throws InterruptedException
put
in interface BlockingQueue<CallRunner>
InterruptedException
public boolean offer(CallRunner callRunner, long timeout, TimeUnit unit) throws InterruptedException
offer
in interface BlockingQueue<CallRunner>
InterruptedException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.