Skip to content

Commit

Permalink
[grid] Splitting regular tasks in 3 for the LocalNode
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Aug 24, 2021
1 parent 9b2da60 commit 8b70122
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions java/src/org/openqa/selenium/grid/node/local/LocalNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public class LocalNode extends Node {
private final List<SessionSlot> factories;
private final Cache<SessionId, SessionSlot> currentSessions;
private final Cache<SessionId, TemporaryFilesystem> tempFileSystems;
private final Regularly regularly;
private final AtomicInteger pendingSessions = new AtomicInteger();

private LocalNode(
Expand Down Expand Up @@ -162,19 +161,22 @@ private LocalNode(
.build();

this.tempFileSystems = CacheBuilder.newBuilder()
.expireAfterAccess(sessionTimeout)
.ticker(ticker)
.removalListener((RemovalListener<SessionId, TemporaryFilesystem>) notification -> {
TemporaryFilesystem tempFS = notification.getValue();
tempFS.deleteTemporaryFiles();
tempFS.deleteBaseDir();
})
.build();

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));
regularly.submit(() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod, heartbeatPeriod);
.expireAfterAccess(sessionTimeout)
.ticker(ticker)
.removalListener((RemovalListener<SessionId, TemporaryFilesystem>) notification -> {
TemporaryFilesystem tempFS = notification.getValue();
tempFS.deleteTemporaryFiles();
tempFS.deleteBaseDir();
})
.build();

Regularly sessionCleanup = new Regularly("Session Cleanup Node: " + externalUri);
sessionCleanup.submit(currentSessions::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
Regularly tmpFileCleanup = new Regularly("TempFile Cleanup Node: " + externalUri);
tmpFileCleanup.submit(tempFileSystems::cleanUp, Duration.ofSeconds(30), Duration.ofSeconds(30));
Regularly regularHeartBeat = new Regularly("Heartbeat Node: " + externalUri);
regularHeartBeat.submit(() -> bus.fire(new NodeHeartBeatEvent(getStatus())), heartbeatPeriod,
heartbeatPeriod);

bus.addListener(SessionClosedEvent.listener(id -> {
// Listen to session terminated events so we know when to fire the NodeDrainComplete event
Expand Down

0 comments on commit 8b70122

Please sign in to comment.