public abstract class AbstractEventBatcher<E> extends Object
Modifier | Constructor and Description |
---|---|
protected |
AbstractEventBatcher(int maxEvents,
long maxMs,
long idleMs,
Timer timer)
Creates an event batcher.
|
Modifier and Type | Method and Description |
---|---|
long |
idleMs()
Returns the maximum number of milliseconds from the most recent event
that can expire before the batch is finalized and processed.
|
int |
maxEvents()
Returns the maximum number of events to be batched.
|
long |
maxMs()
Returns the maximum number of milliseconds from the first event in the
batch that can expire before the batch is finalized and processed.
|
protected abstract void |
processBatch(List<E> batch)
Processes the given batch of events.
|
void |
submit(E event)
Submits the given event.
|
Timer |
timer()
Returns the backing timer used to enforce maxMs and idleMs times.
|
protected AbstractEventBatcher(int maxEvents, long maxMs, long idleMs, Timer timer)
maxEvents
- maximum number of events that should be batchedmaxMs
- maximum number of millis since arrival of the first eventidleMs
- maximum number of millis since arrival of the most recent
eventtimer
- timer to be usedprotected abstract void processBatch(List<E> batch)
batch
- ordered batch of eventspublic void submit(E event)
event
- event to be addedpublic int maxEvents()
public long maxMs()
public long idleMs()
public Timer timer()
Copyright © 2015. All Rights Reserved.