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
FieldsModifier and TypeFieldDescriptionstatic final intThe default max size of the bufferstatic final longThe default throttling time in millisecondprotected final SimpleDateFormatISO 8601 date formatterstatic final StringThe name of the property to set max dimension of monitor points to bufferstatic final intThe max number of monitor point values to keep in memory in the time interval.final StringThe 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 AtomicLongThe number of monitor point values sent to the core of the IASprotected final AtomicLongThe number of errors while sending monitor point values to the core of the IASfinal StringThe ID of the plugin.protected final AtomicLongThe number of messages sent to the core of the IASstatic final StringThe name of the property to set the throttling sending values to the IAS (100<=msec<=1000)static final long -
Constructor Summary
ConstructorsConstructorDescriptionPublisherBase(String pluginId, String monitoredSystemId, ScheduledExecutorService executorSvc) Constructor -
Method Summary
Modifier and TypeMethodDescriptiongetStats()Return the statistics collected during the last time intervalbooleanisClosed()booleanprotected voidmergeProperties(InputStream defaultStream, InputStream userStream) Merges the default and user provided properties in the system propertiesvoidoffer(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 longpublish(MonitorPointData mpData) Send the passed monitor point value to the core of the IAS.protected voidSend the monitor points to the core of the IAS.voidsetUp()Initialize the publisherprotected abstract voidshutdown()Performs the cleanup of the implementers of this abstract classprotected abstract voidstart()Performs the initialization of the implementers of this abstract class.voidPublishing of messages begins after calling this method.voidStop sending messages to the core of the IAS.voidtearDown()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
FilteredValueas 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:
setUpin 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:
tearDownin 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:
offerin interfaceMonitorPointSender- Parameters:
monitorPoint- The notnullmonitor 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:
getStatsin interfaceMonitorPointSender- Returns:
- the statistics collected during the last time interval
-
startSending
public void startSending()Description copied from interface:MonitorPointSenderPublishing of messages begins after calling this method.- Specified by:
startSendingin interfaceMonitorPointSender- See Also:
-
stopSending
public void stopSending()Description copied from interface:MonitorPointSenderStop sending messages to the core of the IAS.Updates to be published when the sender is stopped are lost forever.
- Specified by:
stopSendingin interfaceMonitorPointSender- See Also:
-
isStopped
public boolean isStopped()- Specified by:
isStoppedin interfaceMonitorPointSender- Returns:
trueif sending values to the core of the IAS has been stopped- See Also:
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceMonitorPointSender- Returns:
trueif 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;nullmeans no defaultuserStream- : The path to load default user propertiesnullmeans no user defined property file- Throws:
PublisherException- In case of error merging the properties
-