Package net.i2p.router.util
Class CoDelBlockingQueue<E extends CDQEntry>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.LinkedBlockingQueue<E>
net.i2p.router.util.CoDelBlockingQueue<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,BlockingQueue<E>
,Queue<E>
public class CoDelBlockingQueue<E extends CDQEntry> extends LinkedBlockingQueue<E>
CoDel implementation of Active Queue Management.
Ref: http://queue.acm.org/detail.cfm?id=2209336
Ref: http://queue.acm.org/appendices/codel.html
Code and comments are directly from appendix above, apparently public domain.
Input: add(), offer(), and put() are overridden to add a timestamp.
Output : take(), poll(), and drainTo() are overridden to implement AQM and drop entries
if necessary. peek(), and remove() are NOT overridden, and do
NOT implement AQM or update stats.
- Since:
- 0.9.3
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description static String
PROP_CODEL_INTERVAL
static String
PROP_CODEL_TARGET
-
Constructor Summary
Constructors Constructor Description CoDelBlockingQueue(I2PAppContext ctx, String name, int capacity)
Target 15, interval 100CoDelBlockingQueue(I2PAppContext ctx, String name, int capacity, int target, int interval)
-
Method Summary
Modifier and Type Method Description boolean
add(E o)
void
clear()
int
drainAllTo(Collection<? super E> c)
Drains all, without updating stats or dropping.int
drainTo(Collection<? super E> c)
Updates stats and possibly drops while draining.int
drainTo(Collection<? super E> c, int maxElements)
Updates stats and possibly drops while draining.boolean
isBacklogged()
Has the head of the queue been waiting too long, or is the queue almost full?boolean
offer(E o)
boolean
offer(E o, long timeout, TimeUnit unit)
E
poll()
void
put(E o)
E
take()
Methods inherited from class java.util.concurrent.LinkedBlockingQueue
contains, forEach, iterator, peek, poll, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, 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.Collection
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, stream, toArray
-
Field Details
-
PROP_CODEL_TARGET
- See Also:
- Constant Field Values
-
PROP_CODEL_INTERVAL
- See Also:
- Constant Field Values
-
-
Constructor Details
-
CoDelBlockingQueue
Target 15, interval 100- Parameters:
name
- for stats
-
CoDelBlockingQueue
- Parameters:
target
- the target max latency (ms)interval
- how long above target to start dropping (ms)name
- for stats- Since:
- 0.9.50
-
-
Method Details
-
add
-
offer
-
offer
- Specified by:
offer
in interfaceBlockingQueue<E extends CDQEntry>
- Overrides:
offer
in classLinkedBlockingQueue<E extends CDQEntry>
- Throws:
InterruptedException
-
put
- Specified by:
put
in interfaceBlockingQueue<E extends CDQEntry>
- Overrides:
put
in classLinkedBlockingQueue<E extends CDQEntry>
- Throws:
InterruptedException
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E extends CDQEntry>
- Overrides:
clear
in classLinkedBlockingQueue<E extends CDQEntry>
-
take
- Specified by:
take
in interfaceBlockingQueue<E extends CDQEntry>
- Overrides:
take
in classLinkedBlockingQueue<E extends CDQEntry>
- Throws:
InterruptedException
-
poll
-
drainTo
Updates stats and possibly drops while draining.- Specified by:
drainTo
in interfaceBlockingQueue<E extends CDQEntry>
- Overrides:
drainTo
in classLinkedBlockingQueue<E extends CDQEntry>
-
drainTo
Updates stats and possibly drops while draining.- Specified by:
drainTo
in interfaceBlockingQueue<E extends CDQEntry>
- Overrides:
drainTo
in classLinkedBlockingQueue<E extends CDQEntry>
-
drainAllTo
Drains all, without updating stats or dropping. -
isBacklogged
public boolean isBacklogged()Has the head of the queue been waiting too long, or is the queue almost full?
-