Skip to content

Commit 9b1f2d7

Browse files
committed
Fire heartbeat event immediately upon starting
1 parent 7421ba6 commit 9b1f2d7

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

java/server/src/org/openqa/selenium/grid/node/local/LocalNode.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.openqa.selenium.grid.data.Availability;
3636
import org.openqa.selenium.grid.data.CreateSessionRequest;
3737
import org.openqa.selenium.grid.data.CreateSessionResponse;
38-
import org.openqa.selenium.grid.data.NodeAddedEvent;
3938
import org.openqa.selenium.grid.data.NodeDrainComplete;
4039
import org.openqa.selenium.grid.data.NodeDrainStarted;
4140
import org.openqa.selenium.grid.data.NodeHeartBeatEvent;
@@ -116,7 +115,6 @@ public class LocalNode extends Node {
116115
private final Cache<SessionId, TemporaryFilesystem> tempFileSystems;
117116
private final Regularly regularly;
118117
private final AtomicInteger pendingSessions = new AtomicInteger();
119-
private final AtomicBoolean heartBeatStarted = new AtomicBoolean(false);
120118

121119
private LocalNode(
122120
Tracer tracer,
@@ -173,15 +171,7 @@ private LocalNode(
173171
this.regularly = new Regularly("Local Node: " + externalUri);
174172
regularly.submit(currentSessions::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
175173
regularly.submit(tempFileSystems::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
176-
bus.addListener(NodeAddedEvent.listener(nodeId -> {
177-
if (getId().equals(nodeId)) {
178-
// Lets avoid to create more than one "Regularly" when the Node registers again.
179-
if (!heartBeatStarted.getAndSet(true)) {
180-
regularly.submit(
181-
() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod, heartbeatPeriod);
182-
}
183-
}
184-
}));
174+
regularly.submit(() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod, heartbeatPeriod);
185175

186176
bus.addListener(SessionClosedEvent.listener(id -> {
187177
try {

0 commit comments

Comments
 (0)