Fire heartbeat event immediately upon starting
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;
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,
@@ -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 {
