Class HeartBeatControl


  • public class HeartBeatControl
    extends Object
    This class controls the heartbeats of a cluster node, that is , the heartbeat for the database and the heartbeat for the communication.
    • Field Detail

      • logger

        protected final Logger logger
        The logger of the cluster node. (
      • controlLock

        protected final Lock controlLock
        The lock required to control the cluster node. This includes control operations like starting, terminating and restarting but also status changes.
      • heartBeat

        protected volatile de.aristaflow.adept2.core.registry.cluster.ClusterHeartBeat heartBeat
        The daemon thread that sends the alive signal of this cluster node and regularly polls for the server.
      • commHeartBeat

        protected volatile de.aristaflow.adept2.core.registry.cluster.CommHeartBeat commHeartBeat
        The daemon thread that polls the cluster server via communication.
    • Method Detail

      • spawnHeartBeat

        protected void spawnHeartBeat​(ClusterDbPoller poller,
                                      String clusterNodeName,
                                      String logName,
                                      long period)
        Creates a new thread for sending an alive signal to the cluster as well as polling the cluster server via database. A heartbeat thread will only be spawned if there is currently no heartbeat thread. Unless the heartbeat thread itself calls this method.
        Parameters:
        poller - The interface polling a cluster node via DB.
        clusterNodeName - The name of the cluster node including the cluster name.
        logName - The name of the cluster node including some state information to use in logs.
        period - The time in milliseconds, being alive is signalled/the server node is polled.
      • spawnCommHeartBeat

        protected void spawnCommHeartBeat​(ClusterCommPoller poller,
                                          String clusterNodeName,
                                          String logName,
                                          long period)
        Creates a new thread for polling the cluster server via communication. A communication heartbeat thread will only be spawned if there is currently no communication heartbeat thread. Unless the communication heartbeat thread itself calls this method.
        Parameters:
        poller - The interface polling a cluster node via communication.
        clusterNodeName - The name of the cluster node including the cluster name.
        logName - The name of the cluster node including some state information to use in logs.
        period - The time in milliseconds, being alive is signalled/the server node is polled.
      • triggerPoll

        protected void triggerPoll​(ClusterInteractionRequest cir)
        Triggers the DB heartbeat to poll using the designated request in case one exists.
        Parameters:
        cir - The request used for polling the DB.
      • triggerCommPoll

        protected void triggerCommPoll()
        Triggers the communication heartbeat to poll in case one exists.
      • terminateHeartBeat

        protected void terminateHeartBeat()
        Terminates the heartbeat polling the database in case one exists. This is required right before the platform terminates since the cluster heartbeat uses the JDBC data source of the active platform.
      • terminateCommHeartBeat

        protected void terminateCommHeartBeat()
        Terminates the heartbeat using communication in case one exists. This is required when shutting down the injected service. Afterwards the registry will not provide the cluster service of the server any more and the heartbeat cannot poll.