Class 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
    • Constructor Detail

      • DefaultBatch

        protected DefaultBatch​(DatabaseEngine de,
                               String name,
                               int batchSize,
                               long batchTimeout,
                               long maxAwaitTimeShutdown)
        Creates a new instance of DefaultBatch.
        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 of DefaultBatch.
        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 of DefaultBatch.
        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,
                                          int maxFlushRetries,
                                          long flushRetryDelay)

        Creates a new instance of DefaultBatch with a FailureListener.

        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 DefaultBatch with a BatchListener.

        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 DefaultBatch with a BatchListener.

        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