Interface BambooClusterNodeHeartbeatService

  • All Known Implementing Classes:
    BambooClusterNodeHeartbeatServiceImpl

    @Internal
    public interface BambooClusterNodeHeartbeatService
    Provides a heartbeat for nodes of a cluster and utility methods for finding out about the "liveness" of other nodes.
    • Method Detail

      • getNodeId

        @NotNull
        @NotNull String getNodeId()
        Returns the node ID for this node.
        Returns:
        the node ID for this node.
      • isNodeLive

        boolean isNodeLive​(@NotNull
                           @NotNull String nodeId)
        Checks whether the given cluster node is considered "live".

        Each live node will be writing a heartbeat on a set schedule (eg once a minute). A node is considered live if it has written a heartbeat within a reasonable tolerance level (eg 5 minutes).

        The tolerance level needs to be large enough to avoid certain expected slow-downs in the system including GC pauses, or just general slowness in the JVM / scheduler / network / database of the remote node.

        Parameters:
        nodeId - the cluster node to check
        Returns:
        true iff the given cluster node is still "live".
      • getLastHeartbeatTime

        @Nullable
        @Nullable Long getLastHeartbeatTime​(@NotNull
                                            @NotNull String nodeId)
        Returns the last time a heartbeat was sent by the given node.

        A null value indicates no heartbeats have ever been sent by the given node.

        Parameters:
        nodeId - the node
        Returns:
        the last time a heartbeat was sent by the given node.
      • findLiveNodes

        @NotNull
        @NotNull Collection<String> findLiveNodes()
        Returns all nodes that have sent a heartbeat within the default threshold time.
        Returns:
        all nodes that have sent a heartbeat within the default threshold time.
        See Also:
        findLiveNodes(long)
      • findLiveNodes

        @NotNull
        @NotNull Collection<String> findLiveNodes​(long threshold)
        Returns all nodes that have sent a heartbeat within the given threshold.
        Parameters:
        threshold - the threshold in milliseconds
        Returns:
        all nodes that have sent a heartbeat within the given threshold.
        See Also:
        findLiveNodes()
      • startNodeHeartbeat

        void startNodeHeartbeat()
                         throws Exception
        Starts registering heartbeats for the current node.
        Throws:
        Exception
      • isNodeHeartbeatStarted

        boolean isNodeHeartbeatStarted()
        Returns:
        true if node heartbeat has been started for the current node
      • isCurrentNodePrimaryBuffered

        boolean isCurrentNodePrimaryBuffered()
        Returns:
        true if current node has been recently (i.e. within timeout) successfully marked as alive.
      • setCurrentNodePrimary

        void setCurrentNodePrimary​(boolean primary)
        Set current node's primary flag.
      • getNodeStatuses

        @NotNull
        @NotNull List<BambooNodeStatus> getNodeStatuses()
        Get status of all nodes if DC license applied otherwise empty list.
        Since:
        8.0.2
      • shutdown

        void shutdown()