Class LocalNodeRegistry

java.lang.Object
org.openqa.selenium.grid.distributor.local.LocalNodeRegistry
All Implemented Interfaces:
Closeable, AutoCloseable, NodeRegistry, HasReadyState

public class LocalNodeRegistry extends Object implements NodeRegistry
Default implementation of NodeRegistry that keeps nodes in memory.
  • 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

      public void register(NodeStatus status)
      Description copied from interface: NodeRegistry
      Register a node status received from an event.
      Specified by:
      register in interface NodeRegistry
      Parameters:
      status - The node status to register.
    • add

      public void add(Node node)
      Description copied from interface: NodeRegistry
      Add a node to this registry.
      Specified by:
      add in interface NodeRegistry
      Parameters:
      node - The node to add.
    • remove

      public void remove(NodeId nodeId)
      Description copied from interface: NodeRegistry
      Removes a node from this registry.
      Specified by:
      remove in interface NodeRegistry
      Parameters:
      nodeId - The id of the node to remove.
    • drain

      public boolean drain(NodeId nodeId)
      Description copied from interface: NodeRegistry
      Set a node to draining state.
      Specified by:
      drain in interface NodeRegistry
      Parameters:
      nodeId - The id of the node to drain.
      Returns:
      true if the node was set to draining, false otherwise.
    • updateNodeAvailability

      public void updateNodeAvailability(URI nodeUri, NodeId id, Availability availability)
      Description copied from interface: NodeRegistry
      Updates a node's availability status.
      Specified by:
      updateNodeAvailability in interface NodeRegistry
      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: NodeRegistry
      Run health checks on all nodes.
      Specified by:
      runHealthChecks in interface NodeRegistry
    • refresh

      public void refresh()
      Description copied from interface: NodeRegistry
      Refreshes all nodes by running a health check on each one.
      Specified by:
      refresh in interface NodeRegistry
    • getStatus

      public DistributorStatus getStatus()
      Description copied from interface: NodeRegistry
      Gets a snapshot of all registered nodes.
      Specified by:
      getStatus in interface NodeRegistry
      Returns:
      The current status of the distributor.
    • getAvailableNodes

      public Set<NodeStatus> getAvailableNodes()
      Description copied from interface: NodeRegistry
      Gets all available nodes that are not DOWN or DRAINING and has free slots.
      Specified by:
      getAvailableNodes in interface NodeRegistry
      Returns:
      Set of available node statuses.
    • getUpNodes

      public Set<NodeStatus> getUpNodes()
      Description copied from interface: NodeRegistry
      Get all nodes that are UP.
      Specified by:
      getUpNodes in interface NodeRegistry
      Returns:
      Set of UP node statuses.
    • getNode

      public Node getNode(NodeId id)
      Description copied from interface: NodeRegistry
      Gets a node by its ID.
      Specified by:
      getNode in interface NodeRegistry
      Parameters:
      id - The node ID to look up.
      Returns:
      The node, or null if not found.
    • getUpNodeCount

      public long getUpNodeCount()
      Description copied from interface: NodeRegistry
      Gets the total number of nodes that are UP.
      Specified by:
      getUpNodeCount in interface NodeRegistry
      Returns:
      The number of UP nodes.
    • getDownNodeCount

      public long getDownNodeCount()
      Description copied from interface: NodeRegistry
      Gets the total number of nodes that are DOWN.
      Specified by:
      getDownNodeCount in interface NodeRegistry
      Returns:
      The number of DOWN nodes.
    • isReady

      public boolean isReady()
      Specified by:
      isReady in interface HasReadyState
    • getModel

      public GridModel getModel()
      Get the GridModel used by this registry. This is primarily for use by the LocalDistributor.
      Returns:
      The GridModel instance
    • reserve

      public boolean reserve(SlotId slotId)
      Description copied from interface: NodeRegistry
      Reserve a slot for a session.
      Specified by:
      reserve in interface NodeRegistry
      Parameters:
      slotId - The slot ID to reserve.
      Returns:
      Whether the reservation was successful.
    • setSession

      public void setSession(SlotId slotId, Session session)
      Description copied from interface: NodeRegistry
      Set a session for a particular slot.
      Specified by:
      setSession in interface NodeRegistry
      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: NodeRegistry
      Get the number of active slots.
      Specified by:
      getActiveSlots in interface NodeRegistry
    • getIdleSlots

      public int getIdleSlots()
      Description copied from interface: NodeRegistry
      Get the number of idle slots.
      Specified by:
      getIdleSlots in interface NodeRegistry
    • getNode

      public Node getNode(URI uri)
      Get a node by its URI.
      Specified by:
      getNode in interface NodeRegistry
      Parameters:
      uri - The URI of the node to find
      Returns:
      The node if found, null otherwise
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable