Class RedisBackedNewSessionQueue
- All Implemented Interfaces:
Closeable, AutoCloseable, HttpHandler, Routable, HasReadyState
NewSessionQueue backed by Redis.
All queue state — request order, request payloads, per-request deadlines and the completion result — lives in Redis. This lets several SessionQueue replicas share a single logical queue: the Distributor (or several Distributor replicas) can poll and complete requests against any replica.
The HTTP thread that calls addToQueue(SessionRequest) blocks until the request is
completed. Because the completing complete() call may arrive at a different
replica than the one holding the blocked thread, completion is signalled two ways: a JVM-local
CountDownLatch fast-path for same-replica completion, and polling of the Redis result key
as the cross-replica fallback. Atomic SET NX on a per-request completion marker ensures a
single winner when a timeout races a successful creation.
Configure via:
[sessionqueue]
implementation = "org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue"
backend-url = "redis://redis-service:6379"
-
Field Summary
Fields inherited from class NewSessionQueue
tracer -
Constructor Summary
ConstructorsConstructorDescriptionRedisBackedNewSessionQueue(Tracer tracer, SlotMatcher slotMatcher, Duration requestTimeoutCheck, Duration requestTimeout, Duration maximumResponseDelay, Secret registrationSecret, int batchSize, URI redisUri) -
Method Summary
Modifier and TypeMethodDescriptionaddToQueue(SessionRequest request) intvoidclose()booleancomplete(RequestId reqId, Either<SessionNotCreatedException, CreateSessionResponse> result) Returns true if the session is still valid (not timed out and not canceled)static NewSessionQueuegetNextAvailable(Map<Capabilities, Long> stereotypes) intbooleanisReady()booleanA fast-path to detect if the queue is empty, returns false if there is no fast-path available.booleanretryAddToQueue(SessionRequest request) Methods inherited from class NewSessionQueue
execute, matches
-
Constructor Details
-
RedisBackedNewSessionQueue
-
-
Method Details
-
create
-
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
- Specified by:
addToQueuein classNewSessionQueue
-
retryAddToQueue
- Specified by:
retryAddToQueuein classNewSessionQueue
-
remove
- Specified by:
removein classNewSessionQueue
-
getNextAvailable
- Specified by:
getNextAvailablein classNewSessionQueue
-
complete
public boolean complete(RequestId reqId, Either<SessionNotCreatedException, CreateSessionResponse> result) Returns true if the session is still valid (not timed out and not canceled)- Specified by:
completein classNewSessionQueue
-
clearQueue
public int clearQueue()- Specified by:
clearQueuein classNewSessionQueue
-
getQueueContents
- Specified by:
getQueueContentsin classNewSessionQueue
-
getQueueSize
public int getQueueSize() -
isReady
public boolean isReady()- Specified by:
isReadyin interfaceHasReadyState
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-