Send the heartbeat while the node is running
import com.google.common.cache.RemovalListener;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ImmutableCapabilities;
import org.openqa.selenium.NoSuchSessionException;
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;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import java.util.stream.Collectors;
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,
@@ -174,16 +170,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 {
