Class BatchSizeController

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

public final class BatchSizeController extends Object
Single shared controller for batch size (doc count per OpenSearch bulk request). Grows on success (with smoothing) and shrinks on failure; used by all reporters and IndexingRetryCoordinator. Bounds are fixed in code; effective range is driven only by success/failure observations. Thread-safe.
  • Constructor Details

    • BatchSizeController

      public BatchSizeController()
      Constructs the controller. Instance is set by getInstance() or by tests via setInstance(BatchSizeController).
  • Method Details

    • getInstance

      public static BatchSizeController getInstance()
    • getCurrentBatchSize

      public int getCurrentBatchSize()
      Returns the current batch size (doc count) to use for the next bulk request.
    • recordSuccess

      public void recordSuccess(int docsSent)
      Call after a bulk request fully succeeded. May increase batch size (with smoothing).
      Parameters:
      docsSent - number of documents successfully sent in this bulk
    • recordFailure

      public void recordFailure(int attemptedDocs)
      Call after a bulk request failed (full failure, 429, timeout, or partial success). Decreases batch size.
      Parameters:
      attemptedDocs - number of documents that were in the failed bulk
    • recordPartialSuccess

      public void recordPartialSuccess(int successCount, int total)
      Optional: treat partial success as failure for scaling (conservative).
      Parameters:
      successCount - number of docs that succeeded
      total - total docs in the bulk
    • setOnChangeListener

      public void setOnChangeListener(Consumer<Integer> listener)
      Registers a listener called when the batch size changes (for StatsPanel refresh and tool index). Invoked from the thread that called recordSuccess(int) or recordFailure(int).