Class RedisBackedNodeRegistry
java.lang.Object
org.openqa.selenium.grid.distributor.redis.RedisBackedNodeRegistry
- All Implemented Interfaces:
Closeable, AutoCloseable, NodeRegistry, HasReadyState
Redis-backed implementation of
NodeRegistry. Node HTTP proxy objects are kept in
JVM-local memory (a live network connection cannot be serialized), but all grid model state is
delegated to RedisBackedGridModel.
Multiple Distributor replicas can share the same Redis instance. Health checks are coordinated via Redis leader-election locks so each node is checked exactly once per cycle across all replicas.
-
Constructor Summary
ConstructorsConstructorDescriptionRedisBackedNodeRegistry(Tracer tracer, EventBus bus, HttpClient.Factory clientFactory, Secret registrationSecret, Duration healthcheckInterval, ScheduledExecutorService nodeHealthCheckService, Duration purgeNodesInterval, ScheduledExecutorService purgeDeadNodesService, GridRedisClient redis) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a node to this registry.voidclose()booleanSet a node to draining state.intGet the number of active slots.Gets all available nodes that are not DOWN or DRAINING and has free slots.longGets the total number of nodes that are DOWN.intGet the number of idle slots.@Nullable NodeGet node by URI.Gets a node by its ID.Gets a snapshot of all registered nodes.longGets the total number of nodes that are UP.Get all nodes that are UP.booleanisReady()voidrefresh()Refreshes all nodes by running a health check on each one.voidregister(NodeStatus status) Register a node status received from an event.voidRemoves a node from this registry.booleanReserve a slot for a session.voidRun health checks on all nodes.voidsetSession(SlotId slotId, @Nullable Session session) Set a session for a particular slot.voidupdateNodeAvailability(URI nodeUri, NodeId id, Availability availability) Updates a node's availability status.
-
Constructor Details
-
RedisBackedNodeRegistry
public RedisBackedNodeRegistry(Tracer tracer, EventBus bus, HttpClient.Factory clientFactory, Secret registrationSecret, Duration healthcheckInterval, ScheduledExecutorService nodeHealthCheckService, Duration purgeNodesInterval, ScheduledExecutorService purgeDeadNodesService, GridRedisClient redis)
-
-
Method Details
-
register
Description copied from interface:NodeRegistryRegister a node status received from an event.- Specified by:
registerin interfaceNodeRegistry- Parameters:
status- The node status to register.
-
add
Description copied from interface:NodeRegistryAdd a node to this registry.- Specified by:
addin interfaceNodeRegistry- Parameters:
node- The node to add.
-
remove
Description copied from interface:NodeRegistryRemoves a node from this registry.- Specified by:
removein interfaceNodeRegistry- Parameters:
nodeId- The id of the node to remove.
-
drain
Description copied from interface:NodeRegistrySet a node to draining state.- Specified by:
drainin interfaceNodeRegistry- Parameters:
nodeId- The id of the node to drain.- Returns:
- true if the node was set to draining, false otherwise.
-
updateNodeAvailability
Description copied from interface:NodeRegistryUpdates a node's availability status.- Specified by:
updateNodeAvailabilityin interfaceNodeRegistry- Parameters:
nodeUri- The URI of the node.id- The id of the node.availability- The new availability status.
-
runHealthChecks
public void runHealthChecks()Description copied from interface:NodeRegistryRun health checks on all nodes.- Specified by:
runHealthChecksin interfaceNodeRegistry
-
refresh
public void refresh()Description copied from interface:NodeRegistryRefreshes all nodes by running a health check on each one.- Specified by:
refreshin interfaceNodeRegistry
-
getStatus
Description copied from interface:NodeRegistryGets a snapshot of all registered nodes.- Specified by:
getStatusin interfaceNodeRegistry- Returns:
- The current status of the distributor.
-
getAvailableNodes
Description copied from interface:NodeRegistryGets all available nodes that are not DOWN or DRAINING and has free slots.- Specified by:
getAvailableNodesin interfaceNodeRegistry- Returns:
- Set of available node statuses.
-
getUpNodes
Description copied from interface:NodeRegistryGet all nodes that are UP.- Specified by:
getUpNodesin interfaceNodeRegistry- Returns:
- Set of UP node statuses.
-
getNode
Description copied from interface:NodeRegistryGets a node by its ID.- Specified by:
getNodein interfaceNodeRegistry- Parameters:
id- The node ID to look up.- Returns:
- The node, or null if not found.
-
getNode
Description copied from interface:NodeRegistryGet node by URI.- Specified by:
getNodein interfaceNodeRegistry- Parameters:
uri- The node URI to look up.- Returns:
- The node if found, null otherwise.
-
getUpNodeCount
public long getUpNodeCount()Description copied from interface:NodeRegistryGets the total number of nodes that are UP.- Specified by:
getUpNodeCountin interfaceNodeRegistry- Returns:
- The number of UP nodes.
-
getDownNodeCount
public long getDownNodeCount()Description copied from interface:NodeRegistryGets the total number of nodes that are DOWN.- Specified by:
getDownNodeCountin interfaceNodeRegistry- Returns:
- The number of DOWN nodes.
-
isReady
public boolean isReady()- Specified by:
isReadyin interfaceHasReadyState
-
reserve
Description copied from interface:NodeRegistryReserve a slot for a session.- Specified by:
reservein interfaceNodeRegistry- Parameters:
slotId- The slot ID to reserve.- Returns:
- Whether the reservation was successful.
-
setSession
Description copied from interface:NodeRegistrySet a session for a particular slot.- Specified by:
setSessionin interfaceNodeRegistry- Parameters:
slotId- The slot ID.session- The session to associate with the slot, or null to clear.
-
getActiveSlots
public int getActiveSlots()Description copied from interface:NodeRegistryGet the number of active slots.- Specified by:
getActiveSlotsin interfaceNodeRegistry
-
getIdleSlots
public int getIdleSlots()Description copied from interface:NodeRegistryGet the number of idle slots.- Specified by:
getIdleSlotsin interfaceNodeRegistry
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-