Class DefaultBatch
- java.lang.Object
-
- com.feedzai.commons.sql.abstraction.batch.AbstractBatch
-
- com.feedzai.commons.sql.abstraction.batch.DefaultBatch
-
- All Implemented Interfaces:
Runnable
public class DefaultBatch extends AbstractBatch
The default batch implementation. Behind the scenes, it will periodically flush pending statements. It has auto recovery and will never thrown any exception.- Since:
- 2.0.0
- Author:
- Rui Vilao (rui.vilao@feedzai.com)
- See Also:
AbstractBatch
-
-
Field Summary
-
Fields inherited from class com.feedzai.commons.sql.abstraction.batch.AbstractBatch
batch, batchListener, batchSize, batchTimeout, buffer, de, DEFAULT_RETRY_INTERVAL, dev, flushRetryDelay, lastFlush, logger, maxAwaitTimeShutdown, maxFlushRetries, name, NO_RETRY, salt, scheduler
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)Creates a new instance ofDefaultBatch.protectedDefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener)Creates a new instance ofDefaultBatch.protectedDefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener, int maxFlushRetries, long flushRetryDelay)Creates a new instance ofDefaultBatch.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DefaultBatchcreate(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)Creates a new instance ofDefaultBatch.static DefaultBatchcreate(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, FailureListener listener)Deprecated.static DefaultBatchcreate(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, FailureListener listener, int maxFlushRetries, long flushRetryDelay)Deprecated.static DefaultBatchcreate(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener)Creates a new instance ofDefaultBatchwith aBatchListener.static DefaultBatchcreate(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener, int maxFlushRetries, long flushRetryDelay)Creates a new instance ofDefaultBatchwith aBatchListener.-
Methods inherited from class com.feedzai.commons.sql.abstraction.batch.AbstractBatch
add, add, convertToBatchListener, destroy, flush, flush, onFlushFailure, onFlushSuccess, run, start
-
-
-
-
Constructor Detail
-
DefaultBatch
protected DefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)
Creates a new instance ofDefaultBatch.- Parameters:
de- The database engine reference.name- The batch name.batchSize- The batch size.batchTimeout- The timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.
-
DefaultBatch
protected DefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener)
Creates a new instance ofDefaultBatch.- Parameters:
de- The database engine reference.name- The batch name.batchSize- The batch size.batchTimeout- The timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails or succeeds to persist at least one data row.
-
DefaultBatch
protected DefaultBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener, int maxFlushRetries, long flushRetryDelay)
Creates a new instance ofDefaultBatch.- Parameters:
de- The database engine reference.name- The batch name.batchSize- The batch size.batchTimeout- The timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails or succeeds to persist at least one data row.maxFlushRetries- The number of times to retry a batch flush upon failure. Defaults to 0. When set to 0, no retries will be attempted.flushRetryDelay- The time interval (milliseconds) to wait between batch flush retries. Defaults to 300L.- Since:
- 2.1.12
-
-
Method Detail
-
create
public static DefaultBatch create(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)
Creates a new instance of
DefaultBatch.Starts the timertask.
- Parameters:
de- The database engine.name- The batch name.batchSize- The batch size.batchTimeout- The batch timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.- Returns:
- The Batch.
-
create
@Deprecated public static DefaultBatch create(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, FailureListener listener)
Deprecated.Creates a new instance of
DefaultBatchwith aFailureListener.Starts the timertask.
- Parameters:
de- The database engine.name- The batch name.batchSize- The batch size.batchTimeout- The batch timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails to persist at least one data row.- Returns:
- The Batch.
- Since:
- 2.1.11
-
create
@Deprecated public static DefaultBatch create(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, FailureListener listener, int maxFlushRetries, long flushRetryDelay)
Deprecated.Creates a new instance of
DefaultBatchwith aFailureListener.Starts the timertask.
- Parameters:
de- The database engine.name- The batch name.batchSize- The batch size.batchTimeout- The batch timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails to persist at least one data row.maxFlushRetries- The number of times to retry a batch flush upon failure. Defaults to 0. When set to 0, no retries will be attempted.flushRetryDelay- The time interval (milliseconds) to wait between batch flush retries. Defaults to 300L.- Returns:
- The Batch.
- Since:
- 2.1.12
-
create
public static DefaultBatch create(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener)
Creates a new instance of
DefaultBatchwith aBatchListener.Starts the timertask.
- Parameters:
de- The database engine.name- The batch name.batchSize- The batch size.batchTimeout- The batch timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails to persist at least one data row.- Returns:
- The Batch.
- Since:
- 2.8.1
-
create
public static DefaultBatch create(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown, BatchListener listener, int maxFlushRetries, long flushRetryDelay)
Creates a new instance of
DefaultBatchwith aBatchListener.Starts the timertask.
- Parameters:
de- The database engine.name- The batch name.batchSize- The batch size.batchTimeout- The batch timeout.maxAwaitTimeShutdown- The maximum await time for the batch to shutdown.listener- The listener that will be invoked when batch fails to persist at least one data row.maxFlushRetries- The number of times to retry a batch flush upon failure. Defaults to 0. When set to 0, no retries will be attempted.flushRetryDelay- The time interval (milliseconds) to wait between batch flush retries. Defaults to 300L.- Returns:
- The Batch.
- Since:
- 2.8.1
-
-