Class TrafficExportQueue
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 Summary
Modifier and TypeMethodDescriptionstatic voidClears in-memory and spilled traffic backlog.static longReturns the approximate total bytes of documents currently held in the in-memory queue.static intReturns the current number of documents in the traffic export queue.static longReturns current spill queue bytes for StatsPanel observability.static longReturns oldest spill age in milliseconds (0 when no spilled docs).static intReturns current spill queue depth for StatsPanel observability.static longReturns startup-recovered spill document count.static StringReturns spill directory path for diagnostics.static voidOffers a traffic document to the queue.static voidInterrupts and joins the drain worker so the extension unloads cleanly.
-
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 Exporter-index observability)
-
getCurrentBytesEstimate
public static long getCurrentBytesEstimate()Returns the approximate total bytes of documents currently held in the in-memory queue.Computed on demand by iterating a snapshot of the queue and summing
BulkPayloadEstimator.estimateBytes(Map). Intended for low-frequency callers (StatsPanel refresh). Does not include spilled documents; those are already tracked as bytes bygetCurrentSpillBytes(). -
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
Returns spill directory path for diagnostics. -
offer
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;nullis 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.
-
stopWorker
public static void stopWorker()Interrupts and joins the drain worker so the extension unloads cleanly.Safe to call from any thread and safe to call more than once. Resets the start flag so the next
offer(Map)lazily starts a fresh worker. Delegates termination toWorkersso shutdown semantics match every other extension-owned worker; if the worker does not exit withinWORKER_SHUTDOWN_TIMEOUT_MSmilliseconds, the current thread's interrupt flag is restored and the method returns.
-