public final class InProcessTelemetryChannel extends java.lang.Object implements TelemetryChannel
TelemetryChannel
The channel holds two main entities:
A buffer for incoming Telemetry
instances
A transmitter
The buffer is stores incoming telemetry instances. Every new buffer starts a timer.
When the timer expires, or when the buffer is 'full' (whichever happens first), the
transmitter will pick up that buffer and will handle its sending to the server. For example,
a transmitter will be responsible for compressing, sending and activate a policy in case of failures.
The model here is:
Use application threads to populate the buffer
Use channel's threads to send buffers to the server
Created by gupele on 12/17/2014.Constructor and Description |
---|
InProcessTelemetryChannel() |
InProcessTelemetryChannel(java.util.Map<java.lang.String,java.lang.String> namesAndValues)
This Ctor will query the 'namesAndValues' map for data to initialize itself
It will ignore data that is not of its interest, this Ctor is useful for building an instance from configuration
|
InProcessTelemetryChannel(java.lang.String endpointAddress,
boolean developerMode)
Ctor
|
InProcessTelemetryChannel(java.lang.String endpointAddress,
boolean developerMode,
int maxTelemetryBufferCapacity,
int sendIntervalInMillis)
Ctor
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flushes the data that the channel might have internally.
|
boolean |
isDeveloperMode()
Gets value indicating whether this channel is in developer mode.
|
void |
send(Telemetry telemetry)
Sends a Telemetry instance through the channel.
|
void |
setDeveloperMode(boolean developerMode)
Sets value indicating whether this channel is in developer mode.
|
void |
setMaxTelemetriesInBatch(int maxTelemetriesInBatch)
Sets the buffer size
|
void |
setTransmitBufferTimeoutInSeconds(int transmitBufferTimeoutInSeconds)
Sets the time tow wait before flushing the internal buffer
|
void |
stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Stops on going work
|
public InProcessTelemetryChannel()
public InProcessTelemetryChannel(java.lang.String endpointAddress, boolean developerMode)
endpointAddress
- Must be empty string or a valid uri, else an exception will be throwndeveloperMode
- True will behave in a 'non-production' mode to ease the debuggingpublic InProcessTelemetryChannel(java.lang.String endpointAddress, boolean developerMode, int maxTelemetryBufferCapacity, int sendIntervalInMillis)
endpointAddress
- Must be empty string or a valid uri, else an exception will be throwndeveloperMode
- True will behave in a 'non-production' mode to ease the debuggingmaxTelemetryBufferCapacity
- Max number of Telemetries we keep in the buffer, when reached we will send the buffer
Note, value should be between TRANSMIT_BUFFER_MIN_TIMEOUT_IN_MILLIS and TRANSMIT_BUFFER_MAX_TIMEOUT_IN_MILLIS inclusivesendIntervalInMillis
- The maximum number of milliseconds to wait before we send the buffer
Note, value should be between MIN_MAX_TELEMETRY_BUFFER_CAPACITY and MAX_MAX_TELEMETRY_BUFFER_CAPACITY inclusivepublic InProcessTelemetryChannel(java.util.Map<java.lang.String,java.lang.String> namesAndValues)
namesAndValues
- - The data passed as name and value pairspublic boolean isDeveloperMode()
isDeveloperMode
in interface TelemetryChannel
public void setDeveloperMode(boolean developerMode)
setDeveloperMode
in interface TelemetryChannel
developerMode
- True or falsepublic void send(Telemetry telemetry)
send
in interface TelemetryChannel
telemetry
- The Telemetry item to send.public void stop(long timeout, java.util.concurrent.TimeUnit timeUnit)
stop
in interface TelemetryChannel
timeout
- Time to try and stoptimeUnit
- The units of the 'timeout' parameterpublic void flush()
flush
in interface TelemetryChannel
public void setMaxTelemetriesInBatch(int maxTelemetriesInBatch)
maxTelemetriesInBatch
- should be between MIN_MAX_TELEMETRY_BUFFER_CAPACITY
and MAX_MAX_TELEMETRY_BUFFER_CAPACITY inclusive
if the number is lower than the minimum then the minimum will be used
if the number is higher than the maximum then the maximum will be usedpublic void setTransmitBufferTimeoutInSeconds(int transmitBufferTimeoutInSeconds)
transmitBufferTimeoutInSeconds
- should be between MIN_FLUSH_BUFFER_TIMEOUT_IN_SECONDS
and MAX_FLUSH_BUFFER_TIMEOUT_IN_SECONDS inclusive
if the number is lower than the minimum then the minimum will be used
if the number is higher than the maximum then the maximum will be used