Skip to content

Commit

Permalink
Fire heartbeat event immediately upon starting
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 6, 2021
1 parent 7421ba6 commit 9b1f2d7
Showing 1 changed file with 1 addition and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.openqa.selenium.grid.data.Availability;
import org.openqa.selenium.grid.data.CreateSessionRequest;
import org.openqa.selenium.grid.data.CreateSessionResponse;
import org.openqa.selenium.grid.data.NodeAddedEvent;
import org.openqa.selenium.grid.data.NodeDrainComplete;
import org.openqa.selenium.grid.data.NodeDrainStarted;
import org.openqa.selenium.grid.data.NodeHeartBeatEvent;
Expand Down Expand Up @@ -116,7 +115,6 @@ public class LocalNode extends Node {
private final Cache<SessionId, TemporaryFilesystem> tempFileSystems;
private final Regularly regularly;
private final AtomicInteger pendingSessions = new AtomicInteger();
private final AtomicBoolean heartBeatStarted = new AtomicBoolean(false);

private LocalNode(
Tracer tracer,
Expand Down Expand Up @@ -173,15 +171,7 @@ private LocalNode(
this.regularly = new Regularly("Local Node: " + externalUri);
regularly.submit(currentSessions::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
regularly.submit(tempFileSystems::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
bus.addListener(NodeAddedEvent.listener(nodeId -> {
if (getId().equals(nodeId)) {
// Lets avoid to create more than one "Regularly" when the Node registers again.
if (!heartBeatStarted.getAndSet(true)) {
regularly.submit(
() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod, heartbeatPeriod);
}
}
}));
regularly.submit(() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod, heartbeatPeriod);

bus.addListener(SessionClosedEvent.listener(id -> {
try {
Expand Down

0 comments on commit 9b1f2d7

Please sign in to comment.