public class BatchEmitter extends java.lang.Object implements Emitter, java.io.Closeable
Constructor and Description |
---|
BatchEmitter(NetworkConfiguration networkConfig)
Creates a BatchEmitter instance using a NetworkConfiguration.
|
BatchEmitter(NetworkConfiguration networkConfig,
EmitterConfiguration emitterConfig)
Creates a BatchEmitter object from configuration objects.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(TrackerPayload payload)
Adds a TrackerPayload to the EventStore buffer.
|
void |
close()
Attempt to send all remaining events, then shut down the ExecutorService.
|
void |
flushBuffer()
Forces all the payloads currently in the buffer to be sent immediately, as a single request.
|
int |
getBatchSize()
Gets the Emitter batchSize
|
java.util.List<TrackerPayload> |
getBuffer()
Returns a List of Payloads that are in the buffer.
|
protected boolean |
isSuccessfulSend(int code)
Checks whether the response code was a success or not.
|
void |
setBatchSize(int batchSize)
Customize the emitter batch size to any valid integer greater than zero.
|
protected boolean |
shouldRetry(int code) |
public BatchEmitter(NetworkConfiguration networkConfig, EmitterConfiguration emitterConfig)
networkConfig
- a NetworkConfiguration objectemitterConfig
- an EmitterConfiguration objectpublic BatchEmitter(NetworkConfiguration networkConfig)
networkConfig
- a NetworkConfiguration objectpublic boolean add(TrackerPayload payload)
Implementation note: As a side effect it triggers an Emitter thread to emit a batch of events.
public void flushBuffer()
flushBuffer
in interface Emitter
public java.util.List<TrackerPayload> getBuffer()
public void setBatchSize(int batchSize)
setBatchSize
in interface Emitter
batchSize
- number of events to send in one requestpublic int getBatchSize()
getBatchSize
in interface Emitter
protected boolean isSuccessfulSend(int code)
code
- the response codeprotected boolean shouldRetry(int code)
public void close()
Implementation note: Be aware that calling `close()` has a side-effect of shutting down the Emitter ScheduledExecutorService.