Interface BambooClusterNodeHeartbeatService
- All Known Implementing Classes:
BambooClusterNodeHeartbeatServiceImpl
-
Method Summary
Modifier and TypeMethodDescription@NotNull Collection<String>
Returns all nodes IDs that have sent a heartbeat within the default threshold time.@NotNull Collection<String>
findLiveNodes
(long thresholdInMillis) Deprecated.@NotNull Collection<BambooNodeStatus>
Returns all nodes objects that have sent a heartbeat within the default threshold time.@NotNull io.atlassian.fugue.Either<Exception,
List<BambooNodeInfo>> Get info of all nodes (dead and alive).@Nullable Long
getLastHeartbeatTime
(@NotNull String nodeId) Returns the last time a heartbeat was sent by the given node.int
Gets a number of live nodes in the cluster.@NotNull String
Returns the node ID for this node.@NotNull List<BambooNodeStatus>
Get status of all nodes if DC license applied otherwise empty list.boolean
boolean
boolean
Checks whether the current cluster node is considered "live".boolean
isNodeLive
(@NotNull String nodeId) Checks whether the given cluster node is considered "live".boolean
Performs the heartbeat action for the current node and refreshes live nodes.void
Refreshes the list of live nodes.void
removeNode
(@NotNull String nodeId) Remove node by the given id.void
renouncePrimaryRole
(boolean panicMode) Renounce primary role.void
setCurrentNodePrimary
(boolean primary) Set current node's primary flag.void
shutdown()
Stop the heartbeat scheduler service.void
Starts registering heartbeats for the current node.
-
Method Details
-
getNodeId
Returns the node ID for this node.- Returns:
- the node ID for this node.
-
isNodeLive
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.
This method is database sensitive and will return false if the database operations could not be performed.
- Parameters:
nodeId
- the cluster node to check- Returns:
- true iff the given cluster node is still "live".
-
isNodeLive
boolean isNodeLive()Checks whether the current 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.
This method is NOT database sensitive and the returned value will be evaluated properly, even without a database connection.
- Returns:
- true iff the given cluster node is still "live".
- Since:
- 9.4.0
-
getLastHeartbeatTime
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
Returns all nodes IDs that have sent a heartbeat within the default threshold time.- Returns:
- all nodes IDs that have sent a heartbeat within the default threshold time.
-
findLiveNodes
Deprecated.since 9.4.0 usefindLiveNodes()
insteadReturns all nodes that have sent a heartbeat within the given threshold.- Parameters:
thresholdInMillis
- the threshold in milliseconds- Returns:
- all nodes IDs that have sent a heartbeat within the given threshold.
-
findLiveNodesStatuses
Returns all nodes objects that have sent a heartbeat within the default threshold time. The returned nodes are buffered and may not be up to date. UserefreshLiveNodes()
to perform an update.- Returns:
- collection of nodes
- Since:
- 9.4.0
-
startNodeHeartbeat
Starts registering heartbeats for the current node. The first heartbeat is synchronous and will be performed before this method returns. In case of initial heartbeat failure, the method will kill 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. Executed when the current node loses primary lock. -
renouncePrimaryRole
void renouncePrimaryRole(boolean panicMode) Renounce primary role.- Parameters:
panicMode
- indicates that this node is (supposedly) the primary but encountered irrecoverable error.- Since:
- 9.5
-
getNodeStatuses
Get status of all nodes if DC license applied otherwise empty list.- Since:
- 8.0.2
-
getAllNodesInfo
Get info of all nodes (dead and alive).- Returns:
- either list of nodes info or exception if something went wrong
- Since:
- 9.5
-
refreshLiveNodes
void refreshLiveNodes()Refreshes the list of live nodes. Takes the information from the heartbeat table and give accurate information of which nodes are alive.- Since:
- 9.4
-
performHeartbeatAction
boolean performHeartbeatAction()Performs the heartbeat action for the current node and refreshes live nodes.- Returns:
- true if the action was successful, false otherwise
- Since:
- 9.5
-
shutdown
void shutdown()Stop the heartbeat scheduler service.- Since:
- 9.1
-
removeNode
Remove node by the given id.- Since:
- 9.5.0
-
getLiveNodeCount
int getLiveNodeCount()Gets a number of live nodes in the cluster.- Returns:
- number of live nodes
- Since:
- 9.5.0
-
findLiveNodes()
instead