Class LocalNodeRegistry
java.lang.Object
org.openqa.selenium.grid.distributor.local.LocalNodeRegistry
- All Implemented Interfaces:
Closeable,AutoCloseable,NodeRegistry,HasReadyState
Default implementation of
NodeRegistry that keeps nodes in memory.-
Constructor Summary
ConstructorsConstructorDescriptionLocalNodeRegistry(org.openqa.selenium.remote.tracing.Tracer tracer, EventBus bus, int newSessionThreadPoolSize, org.openqa.selenium.remote.http.HttpClient.Factory clientFactory, Secret registrationSecret, Duration healthcheckInterval, ScheduledExecutorService nodeHealthCheckService, Duration purgeNodesInterval, ScheduledExecutorService purgeDeadNodesService) -
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.getModel()Get the GridModel used by this registry.Get a node by its 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, Session session) Set a session for a particular slot.voidupdateNodeAvailability(URI nodeUri, NodeId id, Availability availability) Updates a node's availability status.
-
Constructor Details
-
LocalNodeRegistry
public LocalNodeRegistry(org.openqa.selenium.remote.tracing.Tracer tracer, EventBus bus, int newSessionThreadPoolSize, org.openqa.selenium.remote.http.HttpClient.Factory clientFactory, Secret registrationSecret, Duration healthcheckInterval, ScheduledExecutorService nodeHealthCheckService, Duration purgeNodesInterval, ScheduledExecutorService purgeDeadNodesService)
-
-
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.
-
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
-
getModel
Get the GridModel used by this registry. This is primarily for use by the LocalDistributor.- Returns:
- The GridModel instance
-
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
-
getNode
Get a node by its URI.- Specified by:
getNodein interfaceNodeRegistry- Parameters:
uri- The URI of the node to find- Returns:
- The node if found, null otherwise
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-