public abstract class AbstractClusterNodeHeartbeatService extends Object implements ClusterNodeHeartbeatService
It is up to the concrete class to ensure that startHeartbeat()
is called upon product startup.
The current heartbeat is one minute which is the finest that atlassian-scheduler currently allows.
Constructor and Description |
---|
AbstractClusterNodeHeartbeatService(ClusterNodeHeartBeatDao clusterNodeHeartBeatDao,
com.atlassian.scheduler.SchedulerService schedulerService) |
Modifier and Type | Method and Description |
---|---|
Collection<String> |
findLiveNodes()
Returns all nodes that have sent a heartbeat within the default threshold time.
|
Collection<String> |
findLiveNodes(long threshold)
Returns all nodes that have sent a heartbeat within the given threshold.
|
Long |
getLastHeartbeatTime(String nodeId)
Returns the last time a heartbeat was sent by the given node.
|
String |
getNodeId()
Returns the node ID for this node.
|
boolean |
isNodeLive(String nodeId)
Checks whether the given cluster node is considered "live".
|
protected com.atlassian.scheduler.JobRunner |
newHeartbeatJobRunner() |
protected void |
startHeartbeat()
The concrete class must ensure that this is called upon product startup, but after the DB is available.
|
public AbstractClusterNodeHeartbeatService(ClusterNodeHeartBeatDao clusterNodeHeartBeatDao, com.atlassian.scheduler.SchedulerService schedulerService)
protected void startHeartbeat() throws com.atlassian.scheduler.SchedulerServiceException
com.atlassian.scheduler.SchedulerServiceException
- if the heartbeat job could not be scheduled. This should be considered a fatal exception.@Nonnull public String getNodeId()
ClusterNodeHeartbeatService
getNodeId
in interface ClusterNodeHeartbeatService
public boolean isNodeLive(@Nonnull String nodeId)
ClusterNodeHeartbeatService
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.
isNodeLive
in interface ClusterNodeHeartbeatService
nodeId
- the cluster node to checkpublic Long getLastHeartbeatTime(@Nonnull String nodeId)
ClusterNodeHeartbeatService
A null
value indicates no heartbeats have ever been sent by the given node.
getLastHeartbeatTime
in interface ClusterNodeHeartbeatService
nodeId
- the node@Nonnull public Collection<String> findLiveNodes()
ClusterNodeHeartbeatService
findLiveNodes
in interface ClusterNodeHeartbeatService
ClusterNodeHeartbeatService.findLiveNodes(long)
@Nonnull public Collection<String> findLiveNodes(long threshold)
ClusterNodeHeartbeatService
findLiveNodes
in interface ClusterNodeHeartbeatService
threshold
- the threshold in millisecondsClusterNodeHeartbeatService.findLiveNodes()
protected com.atlassian.scheduler.JobRunner newHeartbeatJobRunner()
Copyright © 2002-2019 Atlassian. All Rights Reserved.