Skip to content

Commit

Permalink
[grid] Covering use case where a Node is UP after being marked DOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jul 28, 2023
1 parent a4d317d commit 20c084f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions java/src/org/openqa/selenium/grid/distributor/GridModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,22 @@ public void refresh(NodeStatus status) {
}
}

public void touch(NodeId id) {
Require.nonNull("Node ID", id);
public void touch(NodeStatus nodeStatus) {
Require.nonNull("Node ID", nodeStatus);

Lock writeLock = lock.writeLock();
writeLock.lock();
try {
NodeStatus node = getNode(id);
NodeStatus node = getNode(nodeStatus.getNodeId());
if (node != null) {
nodePurgeTimes.put(node.getNodeId(), Instant.now());
// Covers the case where the Node might be DOWN in the Grid model (e.g. Node lost
// connectivity for a while). The Node reports itself back as UP.
if (node.getAvailability() != nodeStatus.getAvailability()
&& nodeStatus.getAvailability() == UP) {
nodes.remove(node);
nodes.add(nodeStatus);
}
}
} finally {
writeLock.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public LocalDistributor(
NodeHeartBeatEvent.listener(
nodeStatus -> {
if (nodes.containsKey(nodeStatus.getNodeId())) {
model.touch(nodeStatus.getNodeId());
model.touch(nodeStatus);
} else {
register(nodeStatus);
}
Expand Down

0 comments on commit 20c084f

Please sign in to comment.