public abstract class AbstractBatch extends Object implements Runnable
onFlushFailure(BatchEntry[])
.Modifier and Type | Field and Description |
---|---|
protected int |
batch
The batch at the present moment.
|
protected int |
batchSize
The batchSize.
|
protected long |
batchTimeout
The batch timeout.
|
protected LinkedList<BatchEntry> |
buffer
EntityEntry buffer.
|
protected DatabaseEngine |
de
The database engine.
|
protected static org.slf4j.Marker |
dev
The dev Marker.
|
protected long |
lastFlush
Timestamp of the last flush.
|
protected org.slf4j.Logger |
logger
The logger.
|
protected long |
maxAwaitTimeShutdown
The maximum await time to wait for the batch to shutdown.
|
protected String |
name
The name of the batch.
|
protected static int |
salt
Salt to avoid erroneous flushes.
|
protected ScheduledExecutorService |
scheduler
The Timer that runs this task.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractBatch(DatabaseEngine de,
int batchSize,
long batchTimeout,
long maxAwaitTimeShutdown)
Creates a new instance of
AbstractBatch . |
protected |
AbstractBatch(DatabaseEngine de,
String name,
int batchSize,
long batchTimeout,
long maxAwaitTimeShutdown)
Creates a new instance of
AbstractBatch . |
Modifier and Type | Method and Description |
---|---|
void |
add(BatchEntry batchEntry)
Adds the fields to the batch.
|
void |
add(String entityName,
EntityEntry ee)
Adds the fields to the batch.
|
void |
destroy()
Destroys this batch.
|
void |
flush()
Flushes the pending batches.
|
void |
onFlushFailure(BatchEntry[] entries)
Notifies about the pending entries on flush failure.
|
void |
run() |
protected void |
start()
Starts the timer task.
|
protected final org.slf4j.Logger logger
protected static final org.slf4j.Marker dev
protected static final int salt
protected final DatabaseEngine de
protected final long maxAwaitTimeShutdown
protected ScheduledExecutorService scheduler
protected final int batchSize
protected final long batchTimeout
protected int batch
protected long lastFlush
protected LinkedList<BatchEntry> buffer
protected String name
protected AbstractBatch(DatabaseEngine de, String name, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)
AbstractBatch
.de
- The database engine.name
- The batch name (null or empty names are allowed, falling back to "Anonymous Batch").batchSize
- The batch size.batchTimeout
- The batch timeout.maxAwaitTimeShutdown
- The maximum await time for the batch to shutdown.protected AbstractBatch(DatabaseEngine de, int batchSize, long batchTimeout, long maxAwaitTimeShutdown)
AbstractBatch
.de
- The database engine.batchSize
- The batch size.batchTimeout
- The batch timeout.protected void start()
public void destroy()
public void add(BatchEntry batchEntry) throws DatabaseEngineException
batchEntry
- The batch entry.DatabaseEngineException
- If an error with the database occurs.public void add(String entityName, EntityEntry ee) throws DatabaseEngineException
entityName
- The table name.ee
- The entity entry.DatabaseEngineException
- If an error with the database occurs.public void flush()
public void onFlushFailure(BatchEntry[] entries)
entries
- The entries that are pending to be persisted.Copyright © 2014 Feedzai. All Rights Reserved.