T - The type of the telemetry being stored in the buffer.public abstract class TelemetryChannelBase<T> extends java.lang.Object implements TelemetryChannel
| Constructor and Description |
|---|
TelemetryChannelBase() |
TelemetryChannelBase(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
|
TelemetryChannelBase(java.lang.String endpointAddress,
boolean developerMode,
int maxTelemetryBufferCapacity,
int sendIntervalInMillis)
Ctor
|
TelemetryChannelBase(java.lang.String endpointAddress,
java.lang.String maxTransmissionStorageCapacity,
boolean developerMode,
int maxTelemetryBufferCapacity,
int sendIntervalInMillis,
boolean throttling,
int maxInstantRetries) |
| Modifier and Type | Method and Description |
|---|---|
protected LimitsEnforcer |
createDefaultMaxTelemetryBufferCapacityEnforcer(java.lang.Integer currentValue) |
protected LimitsEnforcer |
createDefaultSendIntervalInSecondsEnforcer(java.lang.Integer currentValue) |
protected abstract TransmitterFactory<T> |
createTransmitterFactory() |
protected abstract boolean |
doSend(Telemetry telemetry) |
void |
flush()
Flushes the data that the channel might have internally.
|
protected TransmitterFactory<T> |
getTransmitterFactory() |
protected void |
initialize(java.lang.String endpointAddress,
java.lang.String maxTransmissionStorageCapacity,
boolean developerMode,
LimitsEnforcer maxTelemetryBufferCapacityEnforcer,
LimitsEnforcer sendIntervalInSeconds,
boolean throttling,
int maxInstantRetry) |
boolean |
isDeveloperMode()
Gets value indicating whether this channel is in developer mode.
|
protected void |
makeSureEndpointAddressIsValid(java.lang.String endpointAddress)
The method will throw IllegalArgumentException if the endpointAddress is not
a valid URI.
|
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 |
setSampler(TelemetrySampler telemetrySampler)
Sets an optional Sampler that can sample out telemetries Currently, we don't
allow to replace a valid telemtry sampler.
|
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 static final int DEFAULT_MAX_INSTANT_RETRY
public static final int DEFAULT_MAX_TELEMETRY_BUFFER_CAPACITY
public static final int DEFAULT_FLUSH_BUFFER_TIMEOUT_IN_SECONDS
public static final int MIN_MAX_TELEMETRY_BUFFER_CAPACITY
public static final int MAX_MAX_TELEMETRY_BUFFER_CAPACITY
public static final int MIN_FLUSH_BUFFER_TIMEOUT_IN_SECONDS
public static final int MAX_FLUSH_BUFFER_TIMEOUT_IN_SECONDS
public static final java.lang.String DEVELOPER_MODE_SYSTEM_PROPRETY_NAME
public static final java.lang.String MAX_TELEMETRY_BUFFER_CAPACITY_NAME
public static final java.lang.String INSTANT_RETRY_NAME
public static final java.lang.String FLUSH_BUFFER_TIMEOUT_IN_SECONDS_NAME
public static final java.lang.String DEVELOPER_MODE_NAME
public static final java.lang.String ENDPOINT_ADDRESS_NAME
public static final java.lang.String MAX_TRANSMISSION_STORAGE_CAPACITY_NAME
public static final int LOG_TELEMETRY_ITEMS_MODULUS
public static final java.lang.String THROTTLING_ENABLED_NAME
protected boolean stopped
protected boolean isInitailized
protected TelemetriesTransmitter<T> telemetriesTransmitter
protected TelemetrySampler telemetrySampler
protected TelemetryBuffer<T> telemetryBuffer
public TelemetryChannelBase()
public TelemetryChannelBase(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 TelemetryChannelBase(java.lang.String endpointAddress,
java.lang.String maxTransmissionStorageCapacity,
boolean developerMode,
int maxTelemetryBufferCapacity,
int sendIntervalInMillis,
boolean throttling,
int maxInstantRetries)
public TelemetryChannelBase(java.util.Map<java.lang.String,java.lang.String> namesAndValues)
namesAndValues - - The data passed as name and value pairsprotected void initialize(java.lang.String endpointAddress,
java.lang.String maxTransmissionStorageCapacity,
boolean developerMode,
LimitsEnforcer maxTelemetryBufferCapacityEnforcer,
LimitsEnforcer sendIntervalInSeconds,
boolean throttling,
int maxInstantRetry)
protected TransmitterFactory<T> getTransmitterFactory()
public boolean isDeveloperMode()
isDeveloperMode in interface TelemetryChannelpublic void setDeveloperMode(boolean developerMode)
setDeveloperMode in interface TelemetryChanneldeveloperMode - true or falsepublic void stop(long timeout,
java.util.concurrent.TimeUnit timeUnit)
stop in interface TelemetryChanneltimeout - Time to try and stoptimeUnit - The units of the 'timeout' parameterpublic 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 usedpublic 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 flush()
flush in interface TelemetryChannelpublic void setSampler(TelemetrySampler telemetrySampler)
setSampler in interface TelemetryChanneltelemetrySampler - - The samplerpublic void send(Telemetry telemetry)
send in interface TelemetryChanneltelemetry - The Telemetry item to send.protected abstract boolean doSend(Telemetry telemetry)
telemetry - protected abstract TransmitterFactory<T> createTransmitterFactory()
protected LimitsEnforcer createDefaultMaxTelemetryBufferCapacityEnforcer(java.lang.Integer currentValue)
protected LimitsEnforcer createDefaultSendIntervalInSecondsEnforcer(java.lang.Integer currentValue)
protected void makeSureEndpointAddressIsValid(java.lang.String endpointAddress)
endpointAddress - java.lang.IllegalArgumentException - if the endpointAddress is invalid