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

public final class RetryQueue extends Object
Per-index bounded queues for failed OpenSearch index operations. When a push fails, documents can be offered to the queue; a drain thread later retries them. When the queue is full, new documents are rejected.

Each queued document is wrapped with its enqueue timestamp so callers can observe the age of the oldest retry-pending document per index.

  • Constructor Summary

    Constructors
    Constructor
    Description
    RetryQueue(int maxSizePerIndex)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if all known queues are empty.
    long
    bytesEstimate(String indexName)
    Returns the approximate total bytes of documents currently queued for the given index.
    void
    Clears all queued retry documents across all indexes.
    boolean
    isEmpty(String indexName)
    Returns true if the queue for the given index is empty or absent.
    boolean
    offer(String indexName, Map<String,Object> document)
    Offers a single document to the queue for the given index.
    int
    offerAll(String indexName, List<Map<String,Object>> documents)
    Offers multiple documents to the queue for the given index.
    long
    Returns the enqueue timestamp (epoch ms) of the oldest queued document for the given index, or -1 when the queue is empty or absent.
    pollBatch(String indexName, int maxSize)
    Removes up to maxSize documents from the queue for the given index.
    int
    size(String indexName)
    Returns the current number of documents queued for the given index.
    int
    Returns total number of queued documents across all indexes (for logging).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RetryQueue

      public RetryQueue(int maxSizePerIndex)
  • Method Details

    • offer

      public boolean offer(String indexName, Map<String,Object> document)
      Offers a single document to the queue for the given index.
      Parameters:
      indexName - full index name (e.g. attackframework-tool-burp-traffic)
      document - document to retry later
      Returns:
      true if accepted, false if queue full
    • offerAll

      public int offerAll(String indexName, List<Map<String,Object>> documents)
      Offers multiple documents to the queue for the given index. Stops at first failure (queue full); earlier docs may have been added.
      Parameters:
      indexName - full index name
      documents - documents to retry later
      Returns:
      number of documents actually accepted (0 to documents.size())
    • pollBatch

      public List<Map<String,Object>> pollBatch(String indexName, int maxSize)
      Removes up to maxSize documents from the queue for the given index.
      Parameters:
      indexName - full index name
      maxSize - maximum number of documents to poll
      Returns:
      list of documents (may be empty, never null)
    • size

      public int size(String indexName)
      Returns the current number of documents queued for the given index.
    • oldestEnqueuedAtMs

      public long oldestEnqueuedAtMs(String indexName)
      Returns the enqueue timestamp (epoch ms) of the oldest queued document for the given index, or -1 when the queue is empty or absent.

      Uses a non-blocking Queue.peek() so reads are cheap and safe from any thread; the returned value is a snapshot and may change immediately after reading.

    • isEmpty

      public boolean isEmpty(String indexName)
      Returns true if the queue for the given index is empty or absent.
    • bytesEstimate

      public long bytesEstimate(String indexName)
      Returns the approximate total bytes of documents currently queued for the given index.

      Computed on demand by iterating a snapshot of the queue and summing BulkPayloadEstimator.estimateBytes(Map). Intended for low-frequency callers (StatsPanel refresh) because it is O(N) in queue depth. Returns 0 when the queue is empty or absent.

    • allEmpty

      public boolean allEmpty()
      Returns true if all known queues are empty.
    • totalSize

      public int totalSize()
      Returns total number of queued documents across all indexes (for logging).
    • clearAll

      public void clearAll()
      Clears all queued retry documents across all indexes.