Class LocalNewSessionQueue
- java.lang.Object
-
- org.openqa.selenium.grid.sessionqueue.NewSessionQueue
-
- org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.openqa.selenium.remote.http.HttpHandler
,org.openqa.selenium.remote.http.Routable
,HasReadyState
public class LocalNewSessionQueue extends NewSessionQueue implements java.io.Closeable
An in-memory implementation of the list of new session requests.The lifecycle of a request can be described as:
- User adds an item on to the queue using
addToQueue(SessionRequest)
. This will block until the request completes in some way. - After being added, a
NewSessionRequestEvent
is fired. Listeners should use this as an indication to callremove(RequestId)
to get the session request. - If the session request is completed, then
complete(RequestId, Either)
must be called. This will not only ensure thataddToQueue(SessionRequest)
returns, but will also fire aNewSessionRejectedEvent
if the session was rejected. Positive completions of events are assumed to be notified on the event bus by other listeners. - If the request cannot be handled right now, call
retryAddToQueue(SessionRequest)
to return the session request to the front of the queue.
There is a background thread that will reap
SessionRequest
s that have timed out. This means that a request can either complete by a listener callingcomplete(RequestId, Either)
directly, or by being reaped by the thread.
-
-
Field Summary
-
Fields inherited from class org.openqa.selenium.grid.sessionqueue.NewSessionQueue
tracer
-
-
Constructor Summary
Constructors Constructor Description LocalNewSessionQueue(org.openqa.selenium.remote.tracing.Tracer tracer, EventBus bus, SlotMatcher slotMatcher, java.time.Duration retryPeriod, java.time.Duration requestTimeout, Secret registrationSecret)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.openqa.selenium.remote.http.HttpResponse
addToQueue(SessionRequest request)
int
clearQueue()
void
close()
void
complete(RequestId reqId, org.openqa.selenium.internal.Either<org.openqa.selenium.SessionNotCreatedException,CreateSessionResponse> result)
static NewSessionQueue
create(org.openqa.selenium.grid.config.Config config)
java.util.Optional<SessionRequest>
getNextAvailable(java.util.Set<org.openqa.selenium.Capabilities> stereotypes)
java.util.List<SessionRequestCapability>
getQueueContents()
int
getQueueSize()
boolean
isReady()
java.util.Optional<SessionRequest>
remove(RequestId reqId)
boolean
retryAddToQueue(SessionRequest request)
-
Methods inherited from class org.openqa.selenium.grid.sessionqueue.NewSessionQueue
execute, matches
-
-
-
-
Constructor Detail
-
LocalNewSessionQueue
public LocalNewSessionQueue(org.openqa.selenium.remote.tracing.Tracer tracer, EventBus bus, SlotMatcher slotMatcher, java.time.Duration retryPeriod, java.time.Duration requestTimeout, Secret registrationSecret)
-
-
Method Detail
-
create
public static NewSessionQueue create(org.openqa.selenium.grid.config.Config config)
-
addToQueue
public org.openqa.selenium.remote.http.HttpResponse addToQueue(SessionRequest request)
- Specified by:
addToQueue
in classNewSessionQueue
-
retryAddToQueue
public boolean retryAddToQueue(SessionRequest request)
- Specified by:
retryAddToQueue
in classNewSessionQueue
-
remove
public java.util.Optional<SessionRequest> remove(RequestId reqId)
- Specified by:
remove
in classNewSessionQueue
-
getNextAvailable
public java.util.Optional<SessionRequest> getNextAvailable(java.util.Set<org.openqa.selenium.Capabilities> stereotypes)
- Specified by:
getNextAvailable
in classNewSessionQueue
-
complete
public void complete(RequestId reqId, org.openqa.selenium.internal.Either<org.openqa.selenium.SessionNotCreatedException,CreateSessionResponse> result)
- Specified by:
complete
in classNewSessionQueue
-
clearQueue
public int clearQueue()
- Specified by:
clearQueue
in classNewSessionQueue
-
getQueueContents
public java.util.List<SessionRequestCapability> getQueueContents()
- Specified by:
getQueueContents
in classNewSessionQueue
-
getQueueSize
public int getQueueSize()
-
isReady
public boolean isReady()
- Specified by:
isReady
in interfaceHasReadyState
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-