Package net.i2p.router.util
Class CoDelPriorityBlockingQueue<E extends CDPQEntry>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractQueue<E>
java.util.concurrent.PriorityBlockingQueue<E>
net.i2p.router.util.PriBlockingQueue<E>
net.i2p.router.util.CoDelPriorityBlockingQueue<E>
- All Implemented Interfaces:
Serializable
,Iterable<E>
,Collection<E>
,BlockingQueue<E>
,Queue<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:
-
Field Summary
Modifier and TypeFieldDescription(package private) static final AtomicLong
debuggingstatic final int
if priority is >= this, never dropstatic final int
Fields inherited from class net.i2p.router.util.PriBlockingQueue
_context, _log, _name, BACKLOG_SIZE, MAX_SIZE, RATES
-
Constructor Summary
ConstructorDescriptionCoDelPriorityBlockingQueue
(I2PAppContext ctx, String name, int initialCapacity) CoDelPriorityBlockingQueue
(I2PAppContext ctx, String name, int initialCapacity, int target, int interval) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
Has the head of the queue been waiting too long, or is the queue too big?poll()
take()
protected void
Methods inherited from class net.i2p.router.util.PriBlockingQueue
add, offer, offer, put
Methods inherited from class java.util.concurrent.PriorityBlockingQueue
comparator, contains, forEach, iterator, peek, poll, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, toArray, toArray, toString
Methods inherited from class java.util.AbstractQueue
addAll, element, remove
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty
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
-
__id
debugging -
MIN_PRIORITY
public static final int MIN_PRIORITY- See Also:
-
DONT_DROP_PRIORITY
public static final int DONT_DROP_PRIORITYif priority is >= this, never drop- See Also:
-
-
Constructor Details
-
CoDelPriorityBlockingQueue
- Parameters:
name
- for stats
-
CoDelPriorityBlockingQueue
public CoDelPriorityBlockingQueue(I2PAppContext ctx, String name, int initialCapacity, int target, int interval) - Parameters:
name
- for stats
-
-
Method Details
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E extends CDPQEntry>
- Overrides:
clear
in classPriorityBlockingQueue<E extends CDPQEntry>
-
take
- Specified by:
take
in interfaceBlockingQueue<E extends CDPQEntry>
- Overrides:
take
in classPriorityBlockingQueue<E extends CDPQEntry>
- Throws:
InterruptedException
-
poll
-
drainTo
Updates stats and possibly drops while draining.- Specified by:
drainTo
in interfaceBlockingQueue<E extends CDPQEntry>
- Overrides:
drainTo
in classPriorityBlockingQueue<E extends CDPQEntry>
-
drainTo
Updates stats and possibly drops while draining.- Specified by:
drainTo
in interfaceBlockingQueue<E extends CDPQEntry>
- Overrides:
drainTo
in classPriorityBlockingQueue<E extends CDPQEntry>
-
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 too big?- Overrides:
isBacklogged
in classPriBlockingQueue<E extends CDPQEntry>
-
timestamp
- Overrides:
timestamp
in classPriBlockingQueue<E extends CDPQEntry>
-