Class HeartbeatWatcher
java.lang.Object
de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.HeartbeatWatcher
Implements the basis of a device heartbeat watcher.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> private long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all devices/entries.de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> Creates a reception callback to be used withStreamNames.SERVICE_METRICSorStreamNames.RESOURCE_METRICS.de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> Creates a reception callback to be used withStreamNames.STATUS_STREAM.voiddeleteOutdated(long timeout, Consumer<String> outdatedHandler) Deletes outdated entries and informsoutdatedHandlerabout the removed entry.voiddeleteOutdated(Consumer<String> outdatedHandler) Deletes outdated entries and informsoutdatedHandlerabout the removed entry.intReturns the number of devices known to this class.voidinstallInto(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector) Creates two reception callbacks and installs them intoconnector.voidnotifyRecordDeleted(String deviceId) Called to notify that we received a deletion signal fromdeviceId.voidnotifyRecordReceived(String deviceId) Called to notify that we received a signal fromdeviceId.longsetTimeout(long tout) Changes the timeout.voiduninstallFrom(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector) Uninstalls the two stored callbacks fromconnector.
-
Field Details
-
timeout
private long timeout -
received
-
metricsCallback
private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> metricsCallback -
statusCallback
private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> statusCallback
-
-
Constructor Details
-
HeartbeatWatcher
public HeartbeatWatcher()
-
-
Method Details
-
createMetricsReceptionCallback
public de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> createMetricsReceptionCallback()Creates a reception callback to be used withStreamNames.SERVICE_METRICSorStreamNames.RESOURCE_METRICS. You may also directly callnotifyRecordReceived(String).- Returns:
- the reception callback
-
createStatusReceptionCallback
public de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> createStatusReceptionCallback()Creates a reception callback to be used withStreamNames.STATUS_STREAM. You may also directly callnotifyRecordReceived(String).- Returns:
- the reception callback
-
installInto
public void installInto(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector) throws IOException Creates two reception callbacks and installs them intoconnector. Stores the callbacks in this class.- Parameters:
connector- the connector to install the callbacks into- Throws:
IOException- if installation fails
-
uninstallFrom
public void uninstallFrom(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector) throws IOException Uninstalls the two stored callbacks fromconnector. Deletes the callbacks from this class.- Parameters:
connector- the connector to uninstall the callbacks from- Throws:
IOException- if uninstallation fails
-
notifyRecordReceived
Called to notify that we received a signal fromdeviceId.- Parameters:
deviceId- the deviceId we received a signal/event from
-
notifyRecordDeleted
Called to notify that we received a deletion signal fromdeviceId.- Parameters:
deviceId- the deviceId we received a signal/event from
-
deleteOutdated
Deletes outdated entries and informsoutdatedHandlerabout the removed entry. To be used in an existing timer. Usestimeoutas timeout for entries.- Parameters:
outdatedHandler- the outdated handler
-
deleteOutdated
Deletes outdated entries and informsoutdatedHandlerabout the removed entry. To be used in an existing timer.- Parameters:
timeout- for deletion in msoutdatedHandler- the outdated handler
-
getDeviceCount
public int getDeviceCount()Returns the number of devices known to this class.- Returns:
- the number of devices
-
clear
public void clear()Clears all devices/entries. -
setTimeout
public long setTimeout(long tout) Changes the timeout.- Parameters:
tout- the timeout in ms- Returns:
- the timeout set before calling this method
-