public class MultithreadedBatch extends AbstractPdbBatch implements PdbBatch
| Modifier and Type | Field and Description |
|---|---|
protected BatchListener |
batchListener
The listener for customized behavior when this batch succeeds or fails to persist data.
|
protected int |
batchSize
The batch size.
|
protected long |
batchTimeoutMs
The batch timeout in milliseconds.
|
protected BlockingQueue<BatchEntry> |
buffer
A buffer of
batch entries. |
protected long |
flushRetryDelayMs
The time interval in milliseconds to wait between batch flush retries.
|
protected long |
lastFlush
Timestamp of the last flush.
|
protected int |
maxFlushRetries
The number of times to retry a batch flush upon failure.
|
protected String |
name
The name of the batch.
|
| Constructor and Description |
|---|
MultithreadedBatch(DatabaseEngine dbEngine,
MultithreadedBatchConfig batchConfig)
Creates a new instance of
MultithreadedBatch. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(BatchEntry batchEntry)
Adds the entry to the batch.
|
void |
close()
Closes this batch.
|
void |
flush()
Flushes the pending batches.
|
CompletableFuture<Void> |
flushAsync()
Flushes the pending batches asynchronously, if the implementation allows it; otherwise, by default, this should
simply call
PdbBatch.flush() and return the future when done. |
add, processBatchprotected final int batchSize
protected final long batchTimeoutMs
protected volatile long lastFlush
protected BlockingQueue<BatchEntry> buffer
batch entries.protected String name
protected final BatchListener batchListener
protected final int maxFlushRetries
protected final long flushRetryDelayMs
@Inject public MultithreadedBatch(DatabaseEngine dbEngine, MultithreadedBatchConfig batchConfig)
MultithreadedBatch.dbEngine - The database engine.batchConfig - The batch configuration.public void close()
close in interface AutoCloseablepublic void add(BatchEntry batchEntry) throws InterruptedException
PdbBatchadd in interface PdbBatchbatchEntry - The batch entry.InterruptedExceptionpublic void flush()
throws ExecutionException,
InterruptedException
PdbBatchflush in interface PdbBatchExecutionExceptionInterruptedExceptionpublic CompletableFuture<Void> flushAsync()
PdbBatchPdbBatch.flush() and return the future when done.flushAsync in interface PdbBatchflushAsync in class AbstractPdbBatchCompletableFuture that completes when the flush action finishes.Copyright © 2023 Feedzai. All rights reserved.