Class HeartbeatWatcher
- java.lang.Object
-
- de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.HeartbeatWatcher
-
public class HeartbeatWatcher extends java.lang.ObjectImplements the basis of a device heartbeat watcher.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>metricsCallbackprivate java.util.Map<java.lang.String,java.lang.Long>receivedprivate de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>statusCallbackprivate longtimeout
-
Constructor Summary
Constructors Constructor Description HeartbeatWatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all devices/entries.de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>createMetricsReceptionCallback()Creates a reception callback to be used withStreamNames.SERVICE_METRICSorStreamNames.RESOURCE_METRICS.de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>createStatusReceptionCallback()Creates a reception callback to be used withStreamNames.STATUS_STREAM.voiddeleteOutdated(long timeout, java.util.function.Consumer<java.lang.String> outdatedHandler)Deletes outdated entries and informsoutdatedHandlerabout the removed entry.voiddeleteOutdated(java.util.function.Consumer<java.lang.String> outdatedHandler)Deletes outdated entries and informsoutdatedHandlerabout the removed entry.intgetDeviceCount()Returns 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(java.lang.String deviceId)Called to notify that we received a deletion signal fromdeviceId.voidnotifyRecordReceived(java.lang.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 Detail
-
timeout
private long timeout
-
received
private java.util.Map<java.lang.String,java.lang.Long> received
-
metricsCallback
private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> metricsCallback
-
statusCallback
private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> statusCallback
-
-
Method Detail
-
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 java.io.IOExceptionCreates two reception callbacks and installs them intoconnector. Stores the callbacks in this class.- Parameters:
connector- the connector to install the callbacks into- Throws:
java.io.IOException- if installation fails
-
uninstallFrom
public void uninstallFrom(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector) throws java.io.IOExceptionUninstalls the two stored callbacks fromconnector. Deletes the callbacks from this class.- Parameters:
connector- the connector to uninstall the callbacks from- Throws:
java.io.IOException- if uninstallation fails
-
notifyRecordReceived
public void notifyRecordReceived(java.lang.String deviceId)
Called to notify that we received a signal fromdeviceId.- Parameters:
deviceId- the deviceId we received a signal/event from
-
notifyRecordDeleted
public void notifyRecordDeleted(java.lang.String deviceId)
Called to notify that we received a deletion signal fromdeviceId.- Parameters:
deviceId- the deviceId we received a signal/event from
-
deleteOutdated
public void deleteOutdated(java.util.function.Consumer<java.lang.String> outdatedHandler)
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
public void deleteOutdated(long timeout, java.util.function.Consumer<java.lang.String> outdatedHandler)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
-
-