Class LocalNewSessionQueue
java.lang.Object
org.openqa.selenium.grid.sessionqueue.NewSessionQueue
org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.openqa.selenium.remote.http.HttpHandler
,org.openqa.selenium.remote.http.Routable
,HasReadyState
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. - If the session request is completed, then
complete(RequestId, Either)
must be called. This will ensure thataddToQueue(SessionRequest)
returns. - 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 calling complete(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
ConstructorsConstructorDescriptionLocalNewSessionQueue
(org.openqa.selenium.remote.tracing.Tracer tracer, SlotMatcher slotMatcher, Duration requestTimeoutCheck, Duration requestTimeout, Secret registrationSecret, int batchSize) -
Method Summary
Modifier and TypeMethodDescriptionorg.openqa.selenium.remote.http.HttpResponse
addToQueue
(SessionRequest request) int
void
close()
void
complete
(RequestId reqId, org.openqa.selenium.internal.Either<org.openqa.selenium.SessionNotCreatedException, CreateSessionResponse> result) static NewSessionQueue
getNextAvailable
(Map<org.openqa.selenium.Capabilities, Long> stereotypes) int
boolean
isReady()
boolean
A fast-path to detect if the queue is empty, returns false if there is no fast-path available.boolean
retryAddToQueue
(SessionRequest request) Methods inherited from class org.openqa.selenium.grid.sessionqueue.NewSessionQueue
execute, matches
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openqa.selenium.remote.http.Routable
with
-
Constructor Details
-
LocalNewSessionQueue
public LocalNewSessionQueue(org.openqa.selenium.remote.tracing.Tracer tracer, SlotMatcher slotMatcher, Duration requestTimeoutCheck, Duration requestTimeout, Secret registrationSecret, int batchSize)
-
-
Method Details
-
create
-
peekEmpty
public boolean peekEmpty()Description copied from class:NewSessionQueue
A fast-path to detect if the queue is empty, returns false if there is no fast-path available.- Specified by:
peekEmpty
in classNewSessionQueue
- Returns:
- true if the queue is empty, false if it is not empty or unknown
-
addToQueue
- Specified by:
addToQueue
in classNewSessionQueue
-
retryAddToQueue
- Specified by:
retryAddToQueue
in classNewSessionQueue
-
remove
- Specified by:
remove
in classNewSessionQueue
-
getNextAvailable
public List<SessionRequest> getNextAvailable(Map<org.openqa.selenium.Capabilities, Long> 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
- Specified by:
getQueueContents
in classNewSessionQueue
-
getQueueSize
public int getQueueSize() -
isReady
public boolean isReady()- Specified by:
isReady
in interfaceHasReadyState
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-