java.lang.Object
de.iip_ecosphere.platform.services.environment.metricsProvider.metricsAas.HeartbeatWatcher

public class HeartbeatWatcher extends Object
Implements 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<?>
     
    private Map<String,Long>
     
    private de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>
     
    private long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears all devices/entries.
    de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>
    Creates a reception callback to be used with StreamNames.SERVICE_METRICS or StreamNames.RESOURCE_METRICS.
    de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?>
    Creates a reception callback to be used with StreamNames.STATUS_STREAM.
    void
    deleteOutdated(long timeout, Consumer<String> outdatedHandler)
    Deletes outdated entries and informs outdatedHandler about the removed entry.
    void
    deleteOutdated(Consumer<String> outdatedHandler)
    Deletes outdated entries and informs outdatedHandler about the removed entry.
    int
    Returns the number of devices known to this class.
    void
    installInto(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector)
    Creates two reception callbacks and installs them into connector.
    void
    Called to notify that we received a deletion signal from deviceId.
    void
    Called to notify that we received a signal from deviceId.
    long
    setTimeout(long tout)
    Changes the timeout.
    void
    uninstallFrom(de.iip_ecosphere.platform.transport.connectors.TransportConnector connector)
    Uninstalls the two stored callbacks from connector.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • timeout

      private long timeout
    • received

      private Map<String,Long> 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 with StreamNames.SERVICE_METRICS or StreamNames.RESOURCE_METRICS. You may also directly call notifyRecordReceived(String).
      Returns:
      the reception callback
    • createStatusReceptionCallback

      public de.iip_ecosphere.platform.transport.connectors.ReceptionCallback<?> createStatusReceptionCallback()
      Creates a reception callback to be used with StreamNames.STATUS_STREAM. You may also directly call notifyRecordReceived(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 into connector. 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 from connector. Deletes the callbacks from this class.
      Parameters:
      connector - the connector to uninstall the callbacks from
      Throws:
      IOException - if uninstallation fails
    • notifyRecordReceived

      public void notifyRecordReceived(String deviceId)
      Called to notify that we received a signal from deviceId.
      Parameters:
      deviceId - the deviceId we received a signal/event from
    • notifyRecordDeleted

      public void notifyRecordDeleted(String deviceId)
      Called to notify that we received a deletion signal from deviceId.
      Parameters:
      deviceId - the deviceId we received a signal/event from
    • deleteOutdated

      public void deleteOutdated(Consumer<String> outdatedHandler)
      Deletes outdated entries and informs outdatedHandler about the removed entry. To be used in an existing timer. Uses timeout as timeout for entries.
      Parameters:
      outdatedHandler - the outdated handler
    • deleteOutdated

      public void deleteOutdated(long timeout, Consumer<String> outdatedHandler)
      Deletes outdated entries and informs outdatedHandler about the removed entry. To be used in an existing timer.
      Parameters:
      timeout - for deletion in ms
      outdatedHandler - 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