|  | 
| 77 | 77 | import org.openqa.selenium.grid.data.NodeHeartBeatEvent; | 
| 78 | 78 | import org.openqa.selenium.grid.data.NodeId; | 
| 79 | 79 | import org.openqa.selenium.grid.data.NodeRemovedEvent; | 
|  | 80 | +import org.openqa.selenium.grid.data.NodeRestartedEvent; | 
| 80 | 81 | import org.openqa.selenium.grid.data.NodeStatus; | 
| 81 | 82 | import org.openqa.selenium.grid.data.NodeStatusEvent; | 
| 82 | 83 | import org.openqa.selenium.grid.data.RequestId; | 
| @@ -205,6 +206,7 @@ public LocalDistributor( | 
| 205 | 206 | 
 | 
| 206 | 207 |     bus.addListener(NodeStatusEvent.listener(this::register)); | 
| 207 | 208 |     bus.addListener(NodeStatusEvent.listener(model::refresh)); | 
|  | 209 | +    bus.addListener(NodeRestartedEvent.listener(this::handleNodeRestarted)); | 
| 208 | 210 |     bus.addListener(NodeRemovedEvent.listener(nodeStatus -> remove(nodeStatus.getNodeId()))); | 
| 209 | 211 |     bus.addListener( | 
| 210 | 212 |         NodeHeartBeatEvent.listener( | 
| @@ -327,6 +329,25 @@ private void register(NodeStatus status) { | 
| 327 | 329 |     } | 
| 328 | 330 |   } | 
| 329 | 331 | 
 | 
|  | 332 | +  private void handleNodeRestarted(NodeStatus status) { | 
|  | 333 | +    Require.nonNull("Node", status); | 
|  | 334 | +    Lock writeLock = lock.writeLock(); | 
|  | 335 | +    writeLock.lock(); | 
|  | 336 | +    try { | 
|  | 337 | +      if (!nodes.containsKey(status.getNodeId())) { | 
|  | 338 | +        return; | 
|  | 339 | +      } | 
|  | 340 | +      if (!getNodeFromURI(status.getExternalUri()).isDraining()) { | 
|  | 341 | +        LOG.info( | 
|  | 342 | +            String.format( | 
|  | 343 | +                "Node %s has restarted. Setting availability to DOWN.", status.getNodeId())); | 
|  | 344 | +        model.setAvailability(status.getNodeId(), DOWN); | 
|  | 345 | +      } | 
|  | 346 | +    } finally { | 
|  | 347 | +      writeLock.unlock(); | 
|  | 348 | +    } | 
|  | 349 | +  } | 
|  | 350 | + | 
| 330 | 351 |   @Override | 
| 331 | 352 |   public LocalDistributor add(Node node) { | 
| 332 | 353 |     Require.nonNull("Node", node); | 
|  | 
0 commit comments