public interface Metadata
Updates to this object are guaranteed to be atomic: the node list, schema, and token metadata are immutable, and will always be consistent for a given metadata instance. The node instances are the only mutable objects in the hierarchy, and some of their fields will be modified dynamically (in particular the node state).
Session.getMetadata()| Modifier and Type | Method and Description |
|---|---|
default Optional<Node> |
findNode(EndPoint endPoint)
Finds the node with the given connection information, if it
exists.
|
default Optional<Node> |
findNode(InetSocketAddress broadcastRpcAddress)
Finds the node with the given untranslated broadcast RPC address, if it exists.
|
default Optional<String> |
getClusterName()
The cluster name to which this session is connected.
|
default Optional<KeyspaceMetadata> |
getKeyspace(CqlIdentifier keyspaceId) |
default Optional<KeyspaceMetadata> |
getKeyspace(String keyspaceName)
Shortcut for
getKeyspace(CqlIdentifier.fromCql(keyspaceName)). |
Map<CqlIdentifier,KeyspaceMetadata> |
getKeyspaces()
The keyspaces defined in this cluster.
|
Map<UUID,Node> |
getNodes()
The nodes known to the driver, indexed by their unique identifier (
host_id in system.local/system.peers). |
Optional<TokenMap> |
getTokenMap()
The token map for this cluster.
|
@NonNull Map<UUID,Node> getNodes()
host_id in system.local/system.peers). This might include nodes that are currently viewed as
down, or ignored by the load balancing policy.@NonNull default Optional<Node> findNode(@NonNull EndPoint endPoint)
Note that this method performs a linear search of getNodes().
@NonNull default Optional<Node> findNode(@NonNull InetSocketAddress broadcastRpcAddress)
Note that this method performs a linear search of getNodes().
@NonNull Map<CqlIdentifier,KeyspaceMetadata> getKeyspaces()
Note that schema metadata can be disabled or restricted to a subset of keyspaces, therefore this map might be empty or incomplete.
@NonNull default Optional<KeyspaceMetadata> getKeyspace(@NonNull CqlIdentifier keyspaceId)
@NonNull default Optional<KeyspaceMetadata> getKeyspace(@NonNull String keyspaceName)
getKeyspace(CqlIdentifier.fromCql(keyspaceName)).@NonNull Optional<TokenMap> getTokenMap()
Note that this property might be absent if token metadata was disabled, or if there was a runtime error while computing the map (this would generate a warning log).
@NonNull default Optional<String> getClusterName()
Note that this method has a default implementation for backwards compatibility. It is expected that any implementing classes override this method.
Copyright © 2017–2025. All rights reserved.