Class ChunkedBulkSender

java.lang.Object
ai.attackframework.tools.burp.utils.opensearch.ChunkedBulkSender

public final class ChunkedBulkSender extends Object
Sends traffic documents to OpenSearch using a chunked POST to the standard Bulk API.

Drains from a queue and writes NDJSON (action line + doc line per document) directly into the request body stream. Avoids building a full batch list and full BulkRequest in memory. Uses only the production Bulk API (POST /<index>/_bulk); not the experimental Streaming Bulk API. Thread-safe for concurrent calls; each call performs one bulk request. Used only by the traffic export path.

See Also:
  • Method Details

    • push

      public static ChunkedBulkSender.Result push(String baseUrl, String indexName, BlockingQueue<Map<String,Object>> queue, int maxBatch, long maxBytes, long maxWaitMs)
      Performs one chunked bulk index request: drains from the queue (respecting batch limits), writes NDJSON to POST &lt;baseUrl&gt;/&lt;indexName&gt;/_bulk, parses the response.

      Documents are prepared with the shared export-ID path before writing. Batch is limited by maxBatch doc count, maxBytes estimated payload size, and maxWaitMs time. If no document is available within the first maxWaitMs, returns a result with zero attempted count (no request is sent).

      Parameters:
      baseUrl - OpenSearch base URL (e.g. https://opensearch.url:9200)
      indexName - target index name (e.g. attackframework-tool-burp-traffic)
      queue - source of documents; each element is a Map to index
      maxBatch - maximum documents per bulk request
      maxBytes - maximum estimated payload bytes per bulk request
      maxWaitMs - maximum time to wait for the first document before sending
      Returns:
      result with success and attempted counts; never null