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 Summary
Modifier and TypeMethodDescriptionaddComponent(BabelNode node, BabelNodeComponent component) Adds a newly discovered component to the store.<T extends BabelNodeComponent>
voidRegisters 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.<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.booleanremoveComponent(BabelNode node, BabelNodeComponent component) Removes a stale or dead component from the store.voidresolutionFailed(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).voidresolutionSuccessuful(BabelNode node, Class<? extends BabelNodeComponent> type) Signals that the resolver protocol successfully resolved the requested component type for the given node.
-
Method Details
-
getComponentsOfType
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 querytype- the class representing the component type- Returns:
- a sorted set of components of the requested type attached to the node
-
addComponent
Adds a newly discovered component to the store. Invoking this will trigger any callbacks registered viaawaitComponent(BabelNode, Class, Runnable, Consumer).- Parameters:
node- the node to which the component is addedcomponent- the component to add- Returns:
- a sorted set of components attached to the node after the addition
-
removeComponent
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 removedcomponent- the component to remove- Returns:
- true if the component was present and removed, false otherwise
-
resolutionFailed
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 viaawaitComponent(BabelNode, Class, Runnable, Consumer)with an empty sorted set.- Parameters:
node- the node for which resolution failedtype- the type of component that failed to resolve
-
resolutionSuccessuful
Signals that the resolver protocol successfully resolved the requested component type for the given node. Invoking this will trigger any callbacks registered viaawaitComponent(BabelNode, Class, Runnable, Consumer)with the resolved components.- Parameters:
node- the node for which resolution succeededtype- 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 resolvedtype- the type of component needed (e.g., IPBabelNodeComponent.class)missing- the callback to execute if the component is not currently presentcallback- the action to perform once the component is available, or when resolution fails
-