public final class TelemetryBuffer
extends java.lang.Object
Telemetry
It is responsible for managing the buffers. Once a new buffer is created it will schedule a call to
pick up the buffer.
If the buffer is full before the timeout expired, it will initiate a 'send now' activity to send the buffer asap.
The class is responsible for handing the corner cases that might rise
Created by gupele on 12/17/2014.| Constructor and Description |
|---|
TelemetryBuffer(TelemetriesTransmitter sender,
int maxTelemetriesInBatch,
int transmitBufferTimeoutInSeconds)
The constructor needs to get the 'sender' we work with
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(java.lang.String telemetry)
The method will add the incoming
Telemetry to its internal container of Telemetries
If that is the first instance in the container, we schedule a 'pick-up' in a configurable amount of time
If by adding that item we exceeded the maximum number of instances, we trigger a send request now. |
int |
getMaxTelemetriesInBatch()
Gets the maximum number of telemetries in a batch
|
int |
getTransmitBufferTimeoutInSeconds()
Gets the transmit buffer timeout in seconds
|
void |
setMaxTelemetriesInBatch(int maxTelemetriesInBatch)
Sets the maximum number of telemetries in a batch
|
void |
setTransmitBufferTimeoutInSeconds(int transmitBufferTimeoutInSeconds)
Sets the transmit buffer timeout in seconds
|
public TelemetryBuffer(TelemetriesTransmitter sender, int maxTelemetriesInBatch, int transmitBufferTimeoutInSeconds)
sender - The sender object for transmitting the telemetriesmaxTelemetriesInBatch - The maximum number of telemetries in a batchtransmitBufferTimeoutInSeconds - The transmit buffer timeout in secondspublic void setMaxTelemetriesInBatch(int maxTelemetriesInBatch)
maxTelemetriesInBatch - The max amount of Telemetries that are allowed in a batch.public int getMaxTelemetriesInBatch()
public void setTransmitBufferTimeoutInSeconds(int transmitBufferTimeoutInSeconds)
transmitBufferTimeoutInSeconds - The amount of time to wait before sending the buffer.public int getTransmitBufferTimeoutInSeconds()
public void add(java.lang.String telemetry)
Telemetry to its internal container of Telemetries
If that is the first instance in the container, we schedule a 'pick-up' in a configurable amount of time
If by adding that item we exceeded the maximum number of instances, we trigger a send request now.
Note that a lock is used to make sure we avoid race conditions and to make sure that we cleanly
move from a ready to send buffer to a new onetelemetry - The Telemetry to add to the buffer.