[grid] Waiting for two missed heartbeats to mark a node DOWN and actually resurrect nodes after receiving a heartbeat event
@@ -164,12 +164,11 @@ public GridModel remove(NodeId id) {
public void purgeDeadNodes() {
long now = System.currentTimeMillis();
- long timeout = 30000;
Lock writeLock = lock.writeLock();
writeLock.lock();
try {
Set<NodeStatus> lost = nodes(UP).stream()
- .filter(status -> now - status.touched() > status.heartbeatPeriod().toMillis())
+ .filter(status -> now - status.touched() > status.heartbeatPeriod().toMillis() * 2)
.collect(toSet());
Set<NodeStatus> resurrected = nodes(DOWN).stream()
.filter(status -> now - status.touched() <= status.heartbeatPeriod().toMillis())
@@ -192,6 +191,7 @@ public void purgeDeadNodes() {
resurrected.stream()
.map(node -> String.format("%s (uri: %s)", node.getId(), node.getUri()))
.collect(joining(", "))));
+ nodes(DOWN).removeAll(resurrected);
nodes(UP).addAll(resurrected);
}
if (dead.size() > 0) {
