BatchPolicy

public class BatchPolicy extends Object

Policy for flushing batched requests.

The trigger for uploading a batch of requests is by either the number of requests or the timeout, whichever comes first. For example, if the batch delay time has expired without the batch size being reached, or if the batch size number of documents is reached before the delay time expires, then the batch upload is triggered.

Nested Class Summary

class BatchPolicy.Builder Builder object for creating an instance of BatchRequest

Public Method Summary

static BatchPolicy
fromConfiguration()
Creates a batch policy from configuration file parameters.
int
getBatchConnectTimeoutSeconds()
Gets connect timeout in seconds for BatchRequest execution.
int
getBatchReadTimeoutSeconds()
Gets read timeout in seconds for BatchRequest execution.
int
getMaxActiveBatches()
Gets maximum number of allowed active batch requests under processing at a given instance.
int
getMaxBatchDelay()
Gets maximum batch auto flush delay.
TimeUnit
getMaxBatchDelayUnit()
Gets TimeUnit for batch auto flush delay.
int
getMaxBatchSize()
Gets maximum number of requests allowed in single batch request.
int
getQueueLength()
Gets total number of requests allowed to be batched before blocking batching of additional requests.
boolean
isFlushOnShutdown()
Gets flag indicating if already enqueued requests would be executed once shutdown is initiated or already enqueued requests would be marked as cancelled.

Inherited Method Summary

Public Methods

public static BatchPolicy fromConfiguration ()

Creates a batch policy from configuration file parameters.

The configuration file should have parameters in the format of:

  • batch.flushOnShutdown = true to flush batched request during service shutdown
  • batch.batchSize = 10 number of requests to batch together
  • batch.maxBatchDelaySeconds = 5 number of seconds to wait before batched requests are flushed automatically
  • batch.maxQueueLength = 1000 maximum number of requests in batch queue for execution
  • batch.maxActiveBatches = 20 number of allowable concurrently executing batches
  • batch.readTimeoutSeconds = 120 read timeout in seconds for batch request
  • batch.connectTimeoutSeconds = 120 connect timeout in seconds for batch request

public int getBatchConnectTimeoutSeconds ()

Gets connect timeout in seconds for BatchRequest execution.

Returns

public int getBatchReadTimeoutSeconds ()

Gets read timeout in seconds for BatchRequest execution.

Returns

public int getMaxActiveBatches ()

Gets maximum number of allowed active batch requests under processing at a given instance.

Returns
  • Maximum number of allowed active batch requests under processing at a given instance.

public int getMaxBatchDelay ()

Gets maximum batch auto flush delay.

Returns
  • maximum duration to wait before auto flushing batch.

public TimeUnit getMaxBatchDelayUnit ()

Gets TimeUnit for batch auto flush delay.

Returns

public int getMaxBatchSize ()

Gets maximum number of requests allowed in single batch request.

Returns
  • maximum number of requests allowed in single batch request

public int getQueueLength ()

Gets total number of requests allowed to be batched before blocking batching of additional requests.

Returns
  • Total number of requests allowed to be batched before blocking batching of additional requests.

public boolean isFlushOnShutdown ()

Gets flag indicating if already enqueued requests would be executed once shutdown is initiated or already enqueued requests would be marked as cancelled.

Returns
  • true implies already enqueued requests would be executed once shutdown is initiated, false implies already enqueued requests would be marked as cancelled.