public abstract class InMemoryRecordBuffer extends AbstractRecordBuffer
RecordBuffer which stores the records in memory until such time in which they're to be flushed.
This class already contains an implementation of the
flush(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter) method which can be manually invoked or
can be automatically invoked when the buffer is full. However, implementations must override the
doFlush(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter, com.google.common.collect.Multimap)
method to implement the actual flushing logic| Constructor and Description |
|---|
InMemoryRecordBuffer(String name,
int size) |
| Modifier and Type | Method and Description |
|---|---|
int |
add(BatchJobInstanceAdapter jobInstance,
BatchTransactionContext ctx,
Record record)
buffers the given
Record for the given BatchJobInstanceAdapter |
protected abstract void |
doFlush(BatchJobInstanceAdapter jobInstance,
com.google.common.collect.Multimap<BatchTransactionContext,Record> records)
Implement this logic to perform specific flushing logic
|
void |
flush(BatchJobInstanceAdapter jobInstance)
Flushes the buffered
Records for the given
BatchJobInstanceAdapter. |
void |
flushAndForget(BatchJobInstanceAdapter jobInstance)
|
void |
forget(BatchJobInstanceAdapter jobInstance)
Releases all tracking information for the given
BatchJobInstanceAdapter |
protected Object |
getHolderLock() |
long |
size(BatchJobInstanceAdapter jobInstance)
Returns how many records are buffered for the given
BatchJobInstanceAdapter |
add, getNamepublic InMemoryRecordBuffer(String name, int size)
protected abstract void doFlush(BatchJobInstanceAdapter jobInstance, com.google.common.collect.Multimap<BatchTransactionContext,Record> records)
jobInstance - a BatchJobInstanceAdapterrecords - a Multimap relating a
BatchTransactionContext to its
corresponding buffered Recordspublic void flush(BatchJobInstanceAdapter jobInstance)
Records for the given
BatchJobInstanceAdapter.
Use this method when you want to flush the info but you still expect more records from the same job instance to come. In this
way, you flush the records but you avoid constantly recreating the internal tracking information.
This is a thread-safe operation.jobInstance - the BatchJobInstanceAdapter which records you want
flushedpublic void flushAndForget(BatchJobInstanceAdapter jobInstance)
flush(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter) followed by a
forget(com.mulesoft.mule.runtime.module.batch.engine.BatchJobInstanceAdapter).
You MUST use this method when you know that the given jobInstance will no longer be executed in order to avoid a
memory leak on its tracking information
This is NOT a thread-safe operation. You must be careful to not have several threads invoking this method at the same
time for the same BatchJobInstanceAdapterjobInstance - a BatchJobInstanceAdapter which you no longer need
to trackpublic void forget(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdapterjobInstance - a BatchJobInstanceAdapter which you no longer need
to trackprotected Object getHolderLock()
public int add(BatchJobInstanceAdapter jobInstance, BatchTransactionContext ctx, Record record)
Record for the given BatchJobInstanceAdapterjobInstance - a BatchJobInstanceAdapterrecord - a BatchJobInstanceAdapterpublic long size(BatchJobInstanceAdapter jobInstance)
BatchJobInstanceAdapterjobInstance - a BatchJobInstanceAdapterCopyright © 2006–2022 MuleSoft, Inc.. All rights reserved.