Package com.seeq.link.sdk.utilities
Class BatchSizeHelper
java.lang.Object
com.seeq.link.sdk.utilities.BatchSizeHelper
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
ConstructorsConstructorDescriptionBatchSizeHelper
(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 TypeMethodDescriptionint
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
start()
Called to signal that a batch has started processing.void
stop()
Called to signal that a batch has stopped processing.void
stop
(int actualSize) Called to signal that a batch has stopped processing.
-
Constructor Details
-
BatchSizeHelper
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
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
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
-