Class TrafficExportQueue

java.lang.Object
ai.attackframework.tools.burp.sinks.TrafficExportQueue

public final class TrafficExportQueue extends Object
Bounded queue for traffic documents so the HTTP thread can enqueue and return immediately.

A dedicated worker thread drains the queue and pushes via the OpenSearch Bulk API using chunked request body (NDJSON written incrementally; no full batch list in memory). When full, the oldest document is dropped (backpressure). Batches are limited by count (BatchSizeController), payload size (BulkPayloadEstimator, 5 MB cap), and time (flush after 100 ms). Used only by the traffic export path.

  • Method Details

    • getCurrentSize

      public static int getCurrentSize()
      Returns the current number of documents in the traffic export queue.
      Returns:
      number of documents currently queued (for stats and tool index)
    • getCurrentSpillSize

      public static int getCurrentSpillSize()
      Returns current spill queue depth for StatsPanel observability.
    • getCurrentSpillBytes

      public static long getCurrentSpillBytes()
      Returns current spill queue bytes for StatsPanel observability.
    • getCurrentSpillOldestAgeMs

      public static long getCurrentSpillOldestAgeMs()
      Returns oldest spill age in milliseconds (0 when no spilled docs).
    • getRecoveredSpillCount

      public static long getRecoveredSpillCount()
      Returns startup-recovered spill document count.
    • getSpillDirectoryPath

      public static String getSpillDirectoryPath()
      Returns spill directory path for diagnostics.
    • offer

      public static void offer(Map<String,Object> document)
      Offers a traffic document to the queue. Non-blocking.

      If the queue is full, the document is first spilled to disk. Only when spill rejects it does this path fall back to drop-oldest behavior and record a drop in ExportStats. Starts the drain worker on first use. Thread-safe.

      Parameters:
      document - the document to enqueue; null is ignored
    • clearPendingWork

      public static void clearPendingWork()
      Clears in-memory and spilled traffic backlog.

      Used when export is intentionally stopped or a Start attempt fails, so queued traffic does not resume behind a stopped UI.