Class BatchSizeHelper

java.lang.Object
com.seeq.link.sdk.utilities.BatchSizeHelper

public class BatchSizeHelper extends Object
Monitors the time it takes to process a batch (via the Start() and Stop() methods) and recommends a new batch size based on preferences for MaximumDuration.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BatchSizeHelper(int initialSize, int maximumSize, Duration maximumDuration)
    Creates a new BatchSizeHelper with specified constraints.
    BatchSizeHelper(int initialSize, Duration maximumDuration)
    Creates a new BatchSizeHelper with specified constraints.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The current recommended batch size given the history of time taken to process a batch.
    The amount of time the last batch took to process.
    double
    The rate of items processed in the last batch.
    void
    Called to signal that a batch has started processing.
    void
    Called to signal that a batch has stopped processing.
    void
    stop(int actualSize)
    Called to signal that a batch has stopped processing.

    Methods inherited from class java.lang.Object

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

    • BatchSizeHelper

      public BatchSizeHelper(int initialSize, Duration maximumDuration)
      Creates a new BatchSizeHelper with specified constraints.
      Parameters:
      initialSize - The initial value for the recommended batch size.
      maximumDuration - The maximum duration for processing that the caller wants a single batch to take.
    • BatchSizeHelper

      public BatchSizeHelper(int initialSize, int maximumSize, Duration maximumDuration)
      Creates a new BatchSizeHelper with specified constraints.
      Parameters:
      initialSize - The initial value for the recommended batch size.
      maximumSize - The maximum value that can be recommended as a batch size.
      maximumDuration - The maximum duration for processing that the caller wants a single batch to take.
  • Method Details

    • start

      public void start()
      Called to signal that a batch has started processing.
    • stop

      public void stop()
      Called to signal that a batch has stopped processing. A new BatchSize will be calculated during this call. This overload should be called if the actual number of items returned in a batch never varies until the final call.
    • stop

      public void stop(int actualSize)
      Called to signal that a batch has stopped processing. A new BatchSize will be calculated during this call.
      Parameters:
      actualSize - The number of items in the batch, which may differ from the recommended size
    • getBatchSize

      public int getBatchSize()
      The current recommended batch size given the history of time taken to process a batch.
      Returns:
      current recommended batch size
    • getLastDuration

      public Duration getLastDuration()
      The amount of time the last batch took to process.
      Returns:
      time the last batch took to process
    • getLastItemsPerSecond

      public double getLastItemsPerSecond()
      The rate of items processed in the last batch.
      Returns:
      rate of items processed in the last batch