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. - 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
SessionRequests 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, SlotMatcher slotMatcher, java.time.Duration requestTimeoutCheck, java.time.Duration requestTimeout, Secret registrationSecret, int batchSize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.openqa.selenium.remote.http.HttpResponseaddToQueue(SessionRequest request)intclearQueue()voidclose()voidcomplete(RequestId reqId, org.openqa.selenium.internal.Either<org.openqa.selenium.SessionNotCreatedException,CreateSessionResponse> result)static NewSessionQueuecreate(Config config)java.util.List<SessionRequest>getNextAvailable(java.util.Map<org.openqa.selenium.Capabilities,java.lang.Long> stereotypes)java.util.List<SessionRequestCapability>getQueueContents()intgetQueueSize()booleanisReady()booleanpeekEmpty()A fast-path to detect if the queue is empty, returns false if there is no fast-path available.java.util.Optional<SessionRequest>remove(RequestId reqId)booleanretryAddToQueue(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, SlotMatcher slotMatcher, java.time.Duration requestTimeoutCheck, java.time.Duration requestTimeout, Secret registrationSecret, int batchSize)
-
-
Method Detail
-
create
public static NewSessionQueue create(Config config)
-
peekEmpty
public boolean peekEmpty()
Description copied from class:NewSessionQueueA fast-path to detect if the queue is empty, returns false if there is no fast-path available.- Specified by:
peekEmptyin classNewSessionQueue- Returns:
- true if the queue is empty, false if it is not empty or unknown
-
addToQueue
public org.openqa.selenium.remote.http.HttpResponse addToQueue(SessionRequest request)
- Specified by:
addToQueuein classNewSessionQueue
-
retryAddToQueue
public boolean retryAddToQueue(SessionRequest request)
- Specified by:
retryAddToQueuein classNewSessionQueue
-
remove
public java.util.Optional<SessionRequest> remove(RequestId reqId)
- Specified by:
removein classNewSessionQueue
-
getNextAvailable
public java.util.List<SessionRequest> getNextAvailable(java.util.Map<org.openqa.selenium.Capabilities,java.lang.Long> stereotypes)
- Specified by:
getNextAvailablein classNewSessionQueue
-
complete
public void complete(RequestId reqId, org.openqa.selenium.internal.Either<org.openqa.selenium.SessionNotCreatedException,CreateSessionResponse> result)
- Specified by:
completein classNewSessionQueue
-
clearQueue
public int clearQueue()
- Specified by:
clearQueuein classNewSessionQueue
-
getQueueContents
public java.util.List<SessionRequestCapability> getQueueContents()
- Specified by:
getQueueContentsin classNewSessionQueue
-
getQueueSize
public int getQueueSize()
-
isReady
public boolean isReady()
- Specified by:
isReadyin interfaceHasReadyState
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-