public abstract class AbstractAccumulator<T> extends java.lang.Object implements Accumulator<T>
Modifier | Constructor and Description |
---|---|
protected |
AbstractAccumulator(java.util.Timer timer,
int maxItems,
int maxBatchMillis,
int maxIdleMillis)
Creates an item accumulator capable of triggering on the specified
thresholds.
|
Modifier and Type | Method and Description |
---|---|
void |
add(T item)
Adds an item to the current batch.
|
boolean |
isReady()
Indicates whether the accumulator is ready to process items.
|
int |
maxBatchMillis()
Returns the maximum number of millis allowed to expire since the first
item before processing is triggered.
|
int |
maxIdleMillis()
Returns the maximum number of millis allowed to expire since the last
item arrival before processing is triggered.
|
int |
maxItems()
Returns the maximum number of items allowed to accumulate before
processing is triggered.
|
java.util.Timer |
timer()
Returns the backing timer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
processItems
protected AbstractAccumulator(java.util.Timer timer, int maxItems, int maxBatchMillis, int maxIdleMillis)
timer
- timer to use for scheduling check-pointsmaxItems
- maximum number of items to accumulate before
processing is triggered
NB: It is possible that processItems will contain more than maxItems under high load or if isReady() can return false.
maxBatchMillis
- maximum number of millis allowed since the first
item before processing is triggeredmaxIdleMillis
- maximum number millis between items before
processing is triggeredpublic void add(T item)
Accumulator
add
in interface Accumulator<T>
item
- item to be added to the current batchpublic boolean isReady()
Accumulator
isReady
in interface Accumulator<T>
public java.util.Timer timer()
public int maxItems()
public int maxBatchMillis()
public int maxIdleMillis()