Interface NodeRegistry

All Superinterfaces:
AutoCloseable, Closeable, HasReadyState
All Known Implementing Classes:
LocalNodeRegistry

public interface NodeRegistry extends HasReadyState, Closeable
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 Details

    • register

      void register(NodeStatus status)
      Register a node status received from an event.
      Parameters:
      status - The node status to register.
    • add

      void add(Node node)
      Add a node to this registry.
      Parameters:
      node - The node to add.
    • remove

      void remove(NodeId nodeId)
      Removes a node from this registry.
      Parameters:
      nodeId - The id of the node to remove.
    • drain

      boolean drain(NodeId nodeId)
      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

      void updateNodeAvailability(URI nodeUri, NodeId id, Availability availability)
      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.
    • getAvailableNodes

      Set<NodeStatus> getAvailableNodes()
      Gets all available nodes that are not DOWN or DRAINING.
      Returns:
      Set of available node statuses.
    • getNode

      Node getNode(NodeId id)
      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

      boolean reserve(SlotId slotId)
      Reserve a slot for a session.
      Parameters:
      slotId - The slot ID to reserve.
      Returns:
      Whether the reservation was successful.
    • setSession

      void setSession(SlotId slotId, Session session)
      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

      Node getNode(URI uri)
      Get node by URI.
      Parameters:
      uri - The node URI to look up.
      Returns:
      The node if found, null otherwise.