E - type of elements in this queuepublic class CoDelBlockingQueue<E extends CDQEntry> extends LinkedBlockingQueue<E>
Implements the CoDel algorithm from RFC 8289 for managing queue congestion and controlling latency through packet dropping. Provides active queue management with automatic dropping when queue delay exceeds configurable thresholds.
Code and comments are derived from RFC 8289 appendix, implementing the standard CoDel algorithm with configurable target delay and interval parameters. Monitors queue sojourn time and drops packets when above target to maintain optimal throughput and latency characteristics.
Input methods are overridden to add timestamps for delay calculation. Output methods implement AQM behavior with comprehensive statistics tracking for performance monitoring.
| Modifier and Type | Field and Description |
|---|---|
static String | PROP_CODEL_INTERVALPROP_CODEL_INTERVAL. |
static String | PROP_CODEL_TARGETPROP_CODEL_TARGET. |
| Constructor and Description |
|---|
CoDelBlockingQueue(I2PAppContext ctx,
String name,
int capacity)Constructs a queue with default CoDel target and interval from properties. |
CoDelBlockingQueue(I2PAppContext ctx,
String name,
int capacity,
int target,
int interval)Constructs a queue with explicit CoDel target and interval. |
| Modifier and Type | Method and Description |
|---|---|
boolean | add(E o)add. |
void | clear()clear. |
void | dispose()Remove this instance from the tuning list. |
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. |
static void | expungeStaleInstances()Remove cleared (GC'd) weak references from the list. |
long | getInterval()Returns the current CoDel interval in ms. |
long | getTarget()Returns the current CoDel target delay in ms. |
boolean | isBacklogged()Has the head of the queue been waiting too long,
or is the queue almost full? |
boolean | offer(E o)offer. |
boolean | offer(E o,
long timeout,
TimeUnit unit)offer. |
E | poll()poll. |
void | put(E o)put. |
void | setInterval(long interval)Sets the current CoDel interval in ms. |
void | setTarget(long target)Sets the current CoDel target delay in ms. |
E | take()take. |
static void | updateAllIntervals(long interval)Update interval on all active CoDelBlockingQueue instances. |
static void | updateAllTargets(long target)Update target on all active CoDelBlockingQueue instances. |
contains, iterator, peek, poll, remainingCapacity, remove, size, spliterator, toArray, toArray, toStringaddAll, element, removecontainsAll, isEmpty, removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, streampublic static final String PROP_CODEL_INTERVAL
public static final String PROP_CODEL_TARGET
public CoDelBlockingQueue(I2PAppContext ctx, String name, int capacity)
ctx - the I2P application contextname - name for this queue instancecapacity - the maximum capacity of the queuepublic CoDelBlockingQueue(I2PAppContext ctx, String name, int capacity, int target, int interval)
ctx - the I2P application contextname - for statscapacity - the maximum capacity of the queuetarget - the targetinterval - how long above target to start dropping (ms)public boolean add(E o)
public void clear()
clear in interface Collection<E extends CDQEntry>clear in class LinkedBlockingQueue<E extends CDQEntry>public void dispose()
public int drainAllTo(Collection<? super E> c)
c - the collection to drain intopublic int drainTo(Collection<? super E> c)
drainTo in interface BlockingQueue<E extends CDQEntry>drainTo in class LinkedBlockingQueue<E extends CDQEntry>public int drainTo(Collection<? super E> c, int maxElements)
drainTo in interface BlockingQueue<E extends CDQEntry>drainTo in class LinkedBlockingQueue<E extends CDQEntry>public static void expungeStaleInstances()
public long getInterval()
public long getTarget()
public boolean isBacklogged()
public boolean offer(E o)
public boolean offer(E o, long timeout, TimeUnit unit) throws InterruptedException
offer in interface BlockingQueue<E extends CDQEntry>offer in class LinkedBlockingQueue<E extends CDQEntry>InterruptedExceptionpublic E poll()
public void put(E o) throws InterruptedException
put in interface BlockingQueue<E extends CDQEntry>put in class LinkedBlockingQueue<E extends CDQEntry>InterruptedExceptionpublic void setInterval(long interval)
interval - the new interval in mspublic void setTarget(long target)
target - the new target delay in mspublic E take() throws InterruptedException
take in interface BlockingQueue<E extends CDQEntry>take in class LinkedBlockingQueue<E extends CDQEntry>InterruptedExceptionpublic static void updateAllIntervals(long interval)
interval - the new interval in mspublic static void updateAllTargets(long target)
target - the new target delay in ms