Interface NodeStore

All Known Implementing Classes:
DefaultNodeStore

public interface NodeStore
A central directory mapping identities (BabelNode) to transport-specific attributes (BabelNodeComponent).

In the Babel 2 architecture, this store acts as the bridge between channels and resolver protocols.

  • Method Details

    • getComponentsOfType

      <T extends BabelNodeComponent> SortedSet<T> getComponentsOfType(BabelNode node, Class<T> type)
      Gets all components of a specific type (e.g., IPBabelNodeComponent.class) attached to a node. Implementations should ideally return this sorted by reachability priority and in an immutable view.
      Type Parameters:
      T - the type of the component
      Parameters:
      node - the node to query
      type - the class representing the component type
      Returns:
      a sorted set of components of the requested type attached to the node
    • addComponent

      SortedSet<BabelNodeComponent> addComponent(BabelNode node, BabelNodeComponent component)
      Adds a newly discovered component to the store. Invoking this will trigger any callbacks registered via awaitComponent(BabelNode, Class, Runnable, Consumer).
      Parameters:
      node - the node to which the component is added
      component - the component to add
      Returns:
      a sorted set of components attached to the node after the addition
    • removeComponent

      boolean removeComponent(BabelNode node, BabelNodeComponent component)
      Removes a stale or dead component from the store. Essential for evicting IPs that no longer respond to heartbeats.
      Parameters:
      node - the node from which the component is removed
      component - the component to remove
      Returns:
      true if the component was present and removed, false otherwise
    • resolutionFailed

      void resolutionFailed(BabelNode node, Class<? extends BabelNodeComponent> type)
      Signals that the resolver protocol failed to find the requested component type for the given node (e.g., discovery timeout). Invoking this will trigger any callbacks registered via awaitComponent(BabelNode, Class, Runnable, Consumer) with an empty sorted set.
      Parameters:
      node - the node for which resolution failed
      type - the type of component that failed to resolve
    • resolutionSuccessuful

      void resolutionSuccessuful(BabelNode node, Class<? extends BabelNodeComponent> type)
      Signals that the resolver protocol successfully resolved the requested component type for the given node. Invoking this will trigger any callbacks registered via awaitComponent(BabelNode, Class, Runnable, Consumer) with the resolved components.
      Parameters:
      node - the node for which resolution succeeded
      type - the type of component that was successfully resolved
    • awaitComponent

      <T extends BabelNodeComponent> void awaitComponent(BabelNode node, Class<T> type, Runnable missing, Consumer<SortedSet<T>> callback)
      Registers a one-shot callback that executes the next time a component of the requested type is added for the given node, or when resolution explicitly fails.

      This allows channels to avoid synchronous blocking or silently dropping messages when an address is unknown.

      Type Parameters:
      T - the type of the component
      Parameters:
      node - the node being resolved
      type - the type of component needed (e.g., IPBabelNodeComponent.class)
      missing - the callback to execute if the component is not currently present
      callback - the action to perform once the component is available, or when resolution fails