Class PublisherBase
- All Implemented Interfaces:
MonitorPointSender
- Direct Known Subclasses:
BufferedPublisherBase
,KafkaPublisher
,ListenerPublisher
- the time interval (
throttlingTime
) elapses or - the max allowed size of the buffer has been reached
PublisherBase
gets all the values from the monitored system and saves them
in a map (the buffer) until the throttling time expires or the max allowed size has been reached
and only then sends all of them at once.
The map allows to easily save only the last update value for each managed monitor point preventing
a misbehaving plugin to fire tons of messages per time interval.
Monitor point values are sent one by one to the core of the IAS.
Reaching the max size of the buffer, triggers the immediate sending of the values of the monitor points. The periodic thread will continue to run.
Life cyle:
start()
is the first method to call to allow a correct initialization.shutdown()
must be called when down with this object to clean the resources
- Author:
- acaproni
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eso.ias.plugin.publisher.MonitorPointSender
MonitorPointSender.SenderStats
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default max size of the bufferstatic final long
The default throttling time in millisecondprotected final SimpleDateFormat
ISO 8601 date formatterstatic final String
The name of the property to set max dimension of monitor points to bufferstatic final int
The max number of monitor point values to keep in memory in the time interval.final String
The ID of the system monitored by the plugin.protected final Map<String,
ValueToSend> The map to store the monitor points received during the throttling time interval.protected final AtomicLong
The number of monitor point values sent to the core of the IASprotected final AtomicLong
The number of errors while sending monitor point values to the core of the IASfinal String
The ID of the plugin.protected final AtomicLong
The number of messages sent to the core of the IASstatic final String
The name of the property to set the throttling sending values to the IAS (100<=msec<=1000)static final long
-
Constructor Summary
ConstructorDescriptionPublisherBase
(String pluginId, String monitoredSystemId, ScheduledExecutorService executorSvc) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetStats()
Return the statistics collected during the last time intervalboolean
isClosed()
boolean
protected void
mergeProperties
(InputStream defaultStream, InputStream userStream) Merges the default and user provided properties in the system propertiesvoid
offer
(ValueToSend monitorPoint) A new value has been produced by the monitored system: it is queued ready to be sent when the throttling time interval elapses.protected abstract long
publish
(MonitorPointData mpData) Send the passed monitor point value to the core of the IAS.protected void
Send the monitor points to the core of the IAS.void
setUp()
Initialize the publisherprotected abstract void
shutdown()
Performs the cleanup of the implementers of this abstract classprotected abstract void
start()
Performs the initialization of the implementers of this abstract class.void
Publishing of messages begins after calling this method.void
Stop sending messages to the core of the IAS.void
tearDown()
Shuts down the server cleaning all the associated resources
-
Field Details
-
THROTTLING_PROPNAME
The name of the property to set the throttling sending values to the IAS (100<=msec<=1000)- See Also:
-
defaultThrottlingTime
public static final long defaultThrottlingTimeThe default throttling time in millisecond- See Also:
-
throttlingTime
public static final long throttlingTime -
MAX_BUFFER_SIZE_PROPNAME
The name of the property to set max dimension of monitor points to buffer- See Also:
-
defaultBufferSize
public static final int defaultBufferSizeThe default max size of the buffer- See Also:
-
maxBufferSize
public static final int maxBufferSizeThe max number of monitor point values to keep in memory in the time interval.If the size of the buffer is greater or equal the
maxBufferSize
, the monitor point values are sent immediately to the core of the IAS -
pluginId
The ID of the plugin. -
monitoredSystemId
The ID of the system monitored by the plugin. -
monitorPoints
The map to store the monitor points received during the throttling time interval.A map allows to save only the last received update of a monitor point if a misbehaving implementation is continuously updating a value.
The key is the ID of the monitor point, the value is the
FilteredValue
as returned applying the filter to a set of samples. -
iso8601dateFormat
ISO 8601 date formatter -
publishedMessages
The number of messages sent to the core of the IAS -
monitorPointsSent
The number of monitor point values sent to the core of the IAS -
numOfErrorsSending
The number of errors while sending monitor point values to the core of the IAS
-
-
Constructor Details
-
PublisherBase
public PublisherBase(String pluginId, String monitoredSystemId, ScheduledExecutorService executorSvc) Constructor- Parameters:
pluginId
- The identifier of the pluginmonitoredSystemId
- The identifier of the system monitored by the pluginexecutorSvc
- The executor service
-
-
Method Details
-
publish
Send the passed monitor point value to the core of the IAS.This method is supposed to effectively send the data to the core of the IAS but some implementation can buffer the date and send them asynchronously.
- Parameters:
mpData
- The monitor point data to send to the core of the IAS- Returns:
- The number of bytes sent to the core of the IAS
- Throws:
PublisherException
- In case of error publishing
-
start
Performs the initialization of the implementers of this abstract class.- Throws:
PublisherException
- Exception returned by the implementer
-
setUp
Initialize the publisher- Specified by:
setUp
in interfaceMonitorPointSender
- Throws:
PublisherException
- in case of error initializing- See Also:
-
sendMonitoredPointsToIas
protected void sendMonitoredPointsToIas()Send the monitor points to the core of the IAS.The method is synchronized as it can be called by 2 different threads: when the throttling time interval elapses and if the max size of the buffer has been reached
-
tearDown
Shuts down the server cleaning all the associated resources- Specified by:
tearDown
in interfaceMonitorPointSender
- Throws:
PublisherException
- returned by the implementer- See Also:
-
shutdown
Performs the cleanup of the implementers of this abstract class- Throws:
PublisherException
- In case of error shutting down
-
offer
A new value has been produced by the monitored system: it is queued ready to be sent when the throttling time interval elapses.- Specified by:
offer
in interfaceMonitorPointSender
- Parameters:
monitorPoint
- The notnull
monitor point to be sent to the IAS- Throws:
IllegalStateException
- If the publisher has not been initialized before offering values- See Also:
-
getStats
Return the statistics collected during the last time interval- Specified by:
getStats
in interfaceMonitorPointSender
- Returns:
- the statistics collected during the last time interval
-
startSending
public void startSending()Description copied from interface:MonitorPointSender
Publishing of messages begins after calling this method.- Specified by:
startSending
in interfaceMonitorPointSender
- See Also:
-
stopSending
public void stopSending()Description copied from interface:MonitorPointSender
Stop sending messages to the core of the IAS.Updates to be published when the sender is stopped are lost forever.
- Specified by:
stopSending
in interfaceMonitorPointSender
- See Also:
-
stopped
MonitorPointSender.stopSending()
-
isStopped
public boolean isStopped()- Specified by:
isStopped
in interfaceMonitorPointSender
- Returns:
true
if sending values to the core of the IAS has been stopped- See Also:
-
isClosed
public boolean isClosed()- Specified by:
isClosed
in interfaceMonitorPointSender
- Returns:
true
if the sender has been closed- See Also:
-
mergeProperties
protected void mergeProperties(InputStream defaultStream, InputStream userStream) throws PublisherException Merges the default and user provided properties in the system properties- Parameters:
defaultStream
- : The path to load default user properties;null
means no defaultuserStream
- : The path to load default user propertiesnull
means no user defined property file- Throws:
PublisherException
- In case of error merging the properties
-