Interface NodeRegistry
- All Superinterfaces:
AutoCloseable,Closeable,HasReadyState
- All Known Implementing Classes:
LocalNodeRegistry
Maintains a registry of the nodes available for a
Distributor. Implementations may store nodes in memory or
in an external data store to allow for high availability configurations.-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a node to this registry.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.Get 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.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.Methods inherited from interface org.openqa.selenium.status.HasReadyState
isReady
-
Method Details
-
register
Register a node status received from an event.- Parameters:
status- The node status to register.
-
add
Add a node to this registry.- Parameters:
node- The node to add.
-
remove
Removes a node from this registry.- Parameters:
nodeId- The id of the node to remove.
-
drain
Set a node to draining state.- Parameters:
nodeId- The id of the node to drain.- Returns:
- true if the node was set to draining, false otherwise.
-
updateNodeAvailability
Updates a node's availability status.- Parameters:
nodeUri- The URI of the node.id- The id of the node.availability- The new availability status.
-
refresh
void refresh()Refreshes all nodes by running a health check on each one. -
getStatus
DistributorStatus getStatus()Gets a snapshot of all registered nodes.- Returns:
- The current status of the distributor.
-
getUpNodes
Set<NodeStatus> getUpNodes()Get all nodes that are UP.- Returns:
- Set of UP node statuses.
-
getAvailableNodes
Set<NodeStatus> getAvailableNodes()Gets all available nodes that are not DOWN or DRAINING and has free slots.- Returns:
- Set of available node statuses.
-
getNode
Gets a node by its ID.- Parameters:
id- The node ID to look up.- Returns:
- The node, or null if not found.
-
getUpNodeCount
long getUpNodeCount()Gets the total number of nodes that are UP.- Returns:
- The number of UP nodes.
-
getDownNodeCount
long getDownNodeCount()Gets the total number of nodes that are DOWN.- Returns:
- The number of DOWN nodes.
-
runHealthChecks
void runHealthChecks()Run health checks on all nodes. -
reserve
Reserve a slot for a session.- Parameters:
slotId- The slot ID to reserve.- Returns:
- Whether the reservation was successful.
-
setSession
Set a session for a particular slot.- Parameters:
slotId- The slot ID.session- The session to associate with the slot, or null to clear.
-
getActiveSlots
int getActiveSlots()Get the number of active slots. -
getIdleSlots
int getIdleSlots()Get the number of idle slots. -
getNode
Get node by URI.- Parameters:
uri- The node URI to look up.- Returns:
- The node if found, null otherwise.
-