Class RetryQueue
java.lang.Object
ai.attackframework.tools.burp.utils.opensearch.RetryQueue
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanallEmpty()Returns true if all known queues are empty.longbytesEstimate(String indexName) Returns the approximate total bytes of documents currently queued for the given index.voidclearAll()Clears all queued retry documents across all indexes.booleanReturns true if the queue for the given index is empty or absent.booleanOffers a single document to the queue for the given index.intOffers multiple documents to the queue for the given index.longoldestEnqueuedAtMs(String indexName) Returns the enqueue timestamp (epoch ms) of the oldest queued document for the given index, or-1when the queue is empty or absent.Removes up to maxSize documents from the queue for the given index.intReturns the current number of documents queued for the given index.intReturns total number of queued documents across all indexes (for logging).
-
Constructor Details
-
RetryQueue
public RetryQueue(int maxSizePerIndex)
-
-
Method Details
-
offer
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
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 namedocuments- documents to retry later- Returns:
- number of documents actually accepted (0 to documents.size())
-
pollBatch
Removes up to maxSize documents from the queue for the given index.- Parameters:
indexName- full index namemaxSize- maximum number of documents to poll- Returns:
- list of documents (may be empty, never null)
-
size
Returns the current number of documents queued for the given index. -
oldestEnqueuedAtMs
Returns the enqueue timestamp (epoch ms) of the oldest queued document for the given index, or-1when 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
Returns true if the queue for the given index is empty or absent. -
bytesEstimate
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. Returns0when 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.
-