Skip to content

Commit d2333a2

Browse files
committed
[grid] Ensure a Node is purged as per the heartbeat period
1 parent 8480b8e commit d2333a2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

java/server/src/org/openqa/selenium/grid/distributor/GridModel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,16 @@ public void purgeDeadNodes() {
190190
Set<NodeStatus> toRemove = new HashSet<>();
191191

192192
for (NodeStatus node : nodes) {
193+
Instant now = Instant.now();
193194
Instant lastTouched = nodePurgeTimes.getOrDefault(node.getNodeId(), Instant.now());
194195
Instant lostTime = lastTouched.plus(node.getHeartbeatPeriod().multipliedBy(PURGE_TIMEOUT_MULTIPLIER / 2));
195196
Instant deadTime = lastTouched.plus(node.getHeartbeatPeriod().multipliedBy(PURGE_TIMEOUT_MULTIPLIER));
196197

197-
if (node.getAvailability() == UP && lastTouched.isBefore(lostTime)) {
198+
if (node.getAvailability() == UP && lostTime.isBefore(now)) {
198199
LOG.info(String.format("Switching node %s from UP to DOWN", node.getNodeId()));
199200
replacements.put(node, rewrite(node, DOWN));
200201
}
201-
if (node.getAvailability() == DOWN && lastTouched.isBefore(deadTime)) {
202+
if (node.getAvailability() == DOWN && deadTime.isBefore(now)) {
202203
LOG.info(String.format("Removing node %s that is DOWN for too long", node.getNodeId()));
203204
toRemove.add(node);
204205
}

0 commit comments

Comments
 (0)