net.i2p.router.util
Class CoDelPriorityBlockingQueue<E extends CDPQEntry>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractQueue<E>
          extended by java.util.concurrent.PriorityBlockingQueue<E>
              extended by net.i2p.router.util.PriBlockingQueue<E>
                  extended by net.i2p.router.util.CoDelPriorityBlockingQueue<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>

public class CoDelPriorityBlockingQueue<E extends CDPQEntry>
extends PriBlockingQueue<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
(package private) static AtomicLong __id
          debugging
static int DONT_DROP_PRIORITY
          if priority is >= this, never drop
static int MIN_PRIORITY
           
 
Fields inherited from class net.i2p.router.util.PriBlockingQueue
BACKLOG_SIZE
 
Constructor Summary
CoDelPriorityBlockingQueue(I2PAppContext ctx, String name, int initialCapacity)
           
 
Method Summary
 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 too big?
 E poll()
           
 E take()
           
protected  void timestamp(E o)
           
 
Methods inherited from class net.i2p.router.util.PriBlockingQueue
add, offer, offer, put
 
Methods inherited from class java.util.concurrent.PriorityBlockingQueue
comparator, contains, iterator, peek, poll, remainingCapacity, remove, size, toArray, toArray, toString
 
Methods inherited from class java.util.AbstractQueue
addAll, element, remove
 
Methods inherited from class java.util.AbstractCollection
containsAll, isEmpty, removeAll, retainAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Queue
element, remove
 
Methods inherited from interface java.util.Collection
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll
 

Field Detail

__id

static final AtomicLong __id
debugging


MIN_PRIORITY

public static final int MIN_PRIORITY
See Also:
Constant Field Values

DONT_DROP_PRIORITY

public static final int DONT_DROP_PRIORITY
if priority is >= this, never drop

See Also:
Constant Field Values
Constructor Detail

CoDelPriorityBlockingQueue

public CoDelPriorityBlockingQueue(I2PAppContext ctx,
                                  String name,
                                  int initialCapacity)
Parameters:
name - for stats
Method Detail

clear

public void clear()
Specified by:
clear in interface Collection<E extends CDPQEntry>
Overrides:
clear in class PriorityBlockingQueue<E extends CDPQEntry>

take

public E take()
                         throws InterruptedException
Specified by:
take in interface BlockingQueue<E extends CDPQEntry>
Overrides:
take in class PriorityBlockingQueue<E extends CDPQEntry>
Throws:
InterruptedException

poll

public E poll()
Specified by:
poll in interface Queue<E extends CDPQEntry>
Overrides:
poll in class PriorityBlockingQueue<E extends CDPQEntry>

drainTo

public int drainTo(Collection<? super E> c)
Updates stats and possibly drops while draining.

Specified by:
drainTo in interface BlockingQueue<E extends CDPQEntry>
Overrides:
drainTo in class PriorityBlockingQueue<E extends CDPQEntry>

drainTo

public int drainTo(Collection<? super E> c,
                   int maxElements)
Updates stats and possibly drops while draining.

Specified by:
drainTo in interface BlockingQueue<E extends CDPQEntry>
Overrides:
drainTo in class PriorityBlockingQueue<E extends CDPQEntry>

drainAllTo

public int drainAllTo(Collection<? super E> c)
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 class PriBlockingQueue<E extends CDPQEntry>

timestamp

protected void timestamp(E o)
Overrides:
timestamp in class PriBlockingQueue<E extends CDPQEntry>