Node

Returned by nodes() and get_node(), one per server node:

for node in cluster.nodes():
    build = (await node.info("build"))["build"]
    print(f"{node.name} {node.address} v{node.version} build={build}")

The properties are the client’s own view of the node as of the last cluster tend, so reading them costs no round trip. info() sends the command to this node only, unlike the cluster-wide InfoCommands.

class aerospike_sdk.aio.node.Node[source]

Bases: NodeBase

One server node of a connected cluster.

Obtained from Cluster.nodes or Cluster.get_node. Properties and aliases() read state the client already holds; info() sends a command to this node specifically, which a cluster-wide info call cannot do.

Example:

for node in cluster.nodes():
    build = (await node.info("build"))["build"]
    print(f"{node.name} {node.address}: {build}")

See also

aerospike_sdk.sync.node.Node: The synchronous counterpart. InfoCommands: Parsed cluster-wide info.

async info(command)[source]

Run a raw info command on this node only.

Example:

node = cluster.get_node("BB9D4EB574A8DA6")
roster = await node.info("roster:namespace=test")
print(roster["roster:namespace=test"])
Parameters:

command (str) – The info command, e.g. "build" or "namespace/test".

Return type:

Dict[str, str]

Returns:

The response keyed by command. A command the server rejects comes back as an ERROR:... value, not as an exception.

Raises:

AerospikeError – If the node cannot be reached.

See also

InfoCommands.info_on_all_nodes: The same command on every node at once.

__init__(pnc_node)

Wrap a PNC node; obtained from Cluster.nodes or Cluster.get_node.

property address: str

The host:port address the client connects to for this node.

Example:

print(f"{node.name} at {node.address}")   # BB9D4EB574A8DA6 at 10.0.0.12:3000
Returns:

The address as "host:port".

See also

host: The same address as a (host, port) tuple.

aliases()

Every (host, port) the client has seen this node answer on.

A node reached through several addresses (seed hostname, peer-reported IP, alternate services address) is one node with several aliases.

Example:

for hostname, port in node.aliases():
    print(f"{node.name} reachable at {hostname}:{port}")
Return type:

List[Tuple[str, int]]

Returns:

The node’s known addresses, including host.

See also

host: The address the client currently connects to.

property failures: int

Failures the client has counted for this node since its last successful refresh.

Example:

flaky = [node.name for node in cluster.nodes() if node.failures > 0]
Returns:

The failure count; 0 for a healthy node, and reset to 0 by the next successful cluster tend.

See also

is_active: Whether the node is still in the cluster.

property host: Tuple[str, int]

The address the client connects to, as a (host, port) tuple.

Example:

hostname, port = node.host
assert port != 4333, "still connected over TLS"
Returns:

(hostname, port).

See also

address: The same address as a string.

property is_active: bool

Whether the client still considers this node part of the cluster.

A node object outlives its membership: one fetched before the node left keeps reporting its last-known state here as False.

Example:

inactive = [node.name for node in cluster.nodes() if not node.is_active]
Returns:

True while the node is in the client’s current node list.

See also

Cluster.nodes(): The current, active node list.

property name: str

The server-assigned node ID, e.g. "BB9D4EB574A8DA6".

This is the key Cluster.get_node() looks up, and the key the *_per_node info helpers return results under.

Example:

names = [node.name for node in cluster.nodes()]
Returns:

The node’s name.

See also

address: Where the client reaches this node.

property partition_generation: int

The node’s partition-map generation, bumped when its partition ownership changes.

Example:

generations = {node.name: node.partition_generation for node in cluster.nodes()}
Returns:

The generation the client last read from the node.

See also

rebalance_generation: The generation for rebalance events.

property rebalance_generation: int

The node’s rebalance generation, bumped each time the cluster rebalances.

Example:

generations = {node.rebalance_generation for node in cluster.nodes()}
settled = len(generations) == 1
Returns:

The generation the client last read from the node.

See also

partition_generation: The generation for partition-map changes.

property version: Version

The server version this node runs.

Per-node, unlike Cluster.server_version(), which reports the cluster minimum. Comparing them across nodes shows whether a rolling upgrade has finished.

Example:

versions = {node.name: str(node.version) for node in cluster.nodes()}
if len(set(versions.values())) > 1:
    print(f"mixed-version cluster: {versions}")
Returns:

The node’s Version.

See also

Cluster.server_version(): The minimum across all nodes.