From c13ec4e1a3db51b18ae2cf4134cf3093f1cea659 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Mon, 26 Apr 2021 19:10:35 +0100 Subject: [PATCH] Add a `create` method to the `LocalNewSessionQueue` --- .../local/LocalNewSessionQueue.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java b/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java index 46f454b5d8b2f..87cc653922476 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java +++ b/java/server/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java @@ -4,6 +4,7 @@ import org.openqa.selenium.Capabilities; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.events.EventBus; +import org.openqa.selenium.grid.config.Config; import org.openqa.selenium.grid.data.CreateSessionResponse; import org.openqa.selenium.grid.data.NewSessionErrorResponse; import org.openqa.selenium.grid.data.NewSessionRejectedEvent; @@ -12,9 +13,14 @@ import org.openqa.selenium.grid.jmx.JMXHelper; import org.openqa.selenium.grid.jmx.ManagedAttribute; import org.openqa.selenium.grid.jmx.ManagedService; +import org.openqa.selenium.grid.log.LoggingOptions; import org.openqa.selenium.grid.security.Secret; +import org.openqa.selenium.grid.security.SecretOptions; +import org.openqa.selenium.grid.server.EventBusOptions; import org.openqa.selenium.grid.sessionqueue.NewSessionQueue; import org.openqa.selenium.grid.sessionqueue.SessionRequest; +import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions; +import org.openqa.selenium.grid.sessionqueue.config.SessionRequestOptions; import org.openqa.selenium.internal.Either; import org.openqa.selenium.internal.Require; import org.openqa.selenium.remote.http.Contents; @@ -113,6 +119,22 @@ public LocalNewSessionQueue( new JMXHelper().register(this); } + public static NewSessionQueue create(Config config) { + LoggingOptions loggingOptions = new LoggingOptions(config); + Tracer tracer = loggingOptions.getTracer(); + + EventBusOptions eventBusOptions = new EventBusOptions(config); + SessionRequestOptions requestOptions = new SessionRequestOptions(config); + SecretOptions secretOptions = new SecretOptions(config); + + return new LocalNewSessionQueue( + tracer, + eventBusOptions.getEventBus(), + requestOptions.getSessionRequestRetryInterval(), + requestOptions.getSessionRequestTimeout(), + secretOptions.getRegistrationSecret()); + } + private void timeoutSessions() { Instant now = Instant.now();