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>

- Type Parameters:
    `E` - type of elements in this queue, extending `CDPQEntry`
  All Implemented Interfaces:
    Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>

      public class CoDelPriorityBlockingQueue<E extends CDPQEntry>
      extends PriBlockingQueue<E>

  CoDel (Controlled Delay) implementation with priority-based queue management.

  Extends CoDelBlockingQueue to add priority-based dropping functionality. Implements enhanced CoDel algorithm with configurable priority thresholds and per-priority statistics.

  Provides priority-aware packet dropping where higher priority packets are protected from dropping during congestion events. Includes comprehensive statistics tracking and performance monitoring for different priority levels.

  Input methods are overridden to add timestamps for delay calculation. Output methods implement AQM behavior with enhanced statistics tracking for priority-based operations.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static AtomicLong` | `__id` debugging
    `static int` | `DONT_DROP_PRIORITY` if priority is >= this, never drop
    `static int` | `MIN_PRIORITY`
    `static String` | `PROP_CODEL_INTERVAL`
    `static String` | `PROP_CODEL_TARGET`

    - ### Fields inherited from class net.i2p.router.util.PriBlockingQueue

      `_context, _log, _name, DEFAULT_BACKLOG_SIZE, DEFAULT_MAX_SIZE, PROP_BACKLOG_SIZE, PROP_MAX_SIZE, RATES`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CoDelPriorityBlockingQueue(I2PAppContext ctx, String name, int initialCapacity)`
    `CoDelPriorityBlockingQueue(I2PAppContext ctx, String name, int initialCapacity, int target, int interval)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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)` Assigns a unique sequence number to the element to maintain FIFO ordering among elements of the same priority.

    - ### Methods inherited from class net.i2p.router.util.PriBlockingQueue

      `offer`

    - ### Methods inherited from class java.util.concurrent.PriorityBlockingQueue

      `add, comparator, contains, iterator, offer, peek, poll, put, remainingCapacity, remove, size, spliterator, 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, parallelStream, removeAll, removeIf, retainAll, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

- - ### Field Detail

    - #### __id

          static final AtomicLong __id

      debugging

    - #### DONT_DROP_PRIORITY

          public static final int DONT_DROP_PRIORITY

      if priority is >= this, never drop
      See Also:
        Constant Field Values

    - #### MIN_PRIORITY

          public static final int MIN_PRIORITY

      See Also:
        Constant Field Values

    - #### PROP_CODEL_INTERVAL

          public static final String PROP_CODEL_INTERVAL

      See Also:
        Constant Field Values

    - #### PROP_CODEL_TARGET

          public static final String PROP_CODEL_TARGET

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CoDelPriorityBlockingQueue

          public CoDelPriorityBlockingQueue(I2PAppContext ctx,
                                            String name,
                                            int initialCapacity)

    - #### CoDelPriorityBlockingQueue

          public CoDelPriorityBlockingQueue(I2PAppContext ctx,
                                            String name,
                                            int initialCapacity,
                                            int target,
                                            int interval)

      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>`

    - #### drainAllTo

          public int drainAllTo(Collection<? super E> c)

      Drains all, without updating stats or dropping.

    - #### 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>`

    - #### 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>`
      Returns:
        true if queue size is above backlog size threshold, false otherwise

    - #### poll

          public E poll()

      Specified by:
        `poll` in interface `Queue<E extends CDPQEntry>`
      Overrides:
        `poll` 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`

    - #### timestamp

          protected void timestamp(E o)

      Description copied from class: `PriBlockingQueue`
      Assigns a unique sequence number to the element to maintain FIFO ordering among elements of the same priority.
      Overrides:
        `timestamp` in class `PriBlockingQueue<E extends CDPQEntry>`
      Parameters:
        `o` - the element to timestamp