如何以编程方式确定 Cassandra 集群中的节点数?
How to programmatically determine the number of nodes in a Cassandra Cluster?
有没有一种方法可以在没有上下文的情况下确定 Cassandra 集群中的节点数?
我正在尝试获取该数字以确保用户不会给我一个太大的复制因子(即说 10 只有 9 个节点。)
重要:此时,我唯一的接口是C中的thrift。
注意: 我研究过使用 describe_ring() 但不幸的是,该函数强制您拥有有效的上下文(因此它描述了该上下文的环而不是 Cassandra 集群中现有节点的数量。)
您可以使用 Thrift 协议查看系统 table:system.peers。这里列出了所有其他节点及其信息,但不包括本地节点。通过统计system.peers中的节点数,总节点数为entries_count_in_peers + 1
下面是system.peerstable
的结构(CQL)
CREATE TABLE system.peers (
peer inet PRIMARY KEY,
data_center text,
host_id uuid,
preferred_ip inet,
rack text,
release_version text,
rpc_address inet,
schema_version uuid,
tokens set<text>
)
每个节点有一个分区(Thrift 术语中的行键)
有没有一种方法可以在没有上下文的情况下确定 Cassandra 集群中的节点数?
我正在尝试获取该数字以确保用户不会给我一个太大的复制因子(即说 10 只有 9 个节点。)
重要:此时,我唯一的接口是C中的thrift。
注意: 我研究过使用 describe_ring() 但不幸的是,该函数强制您拥有有效的上下文(因此它描述了该上下文的环而不是 Cassandra 集群中现有节点的数量。)
您可以使用 Thrift 协议查看系统 table:system.peers。这里列出了所有其他节点及其信息,但不包括本地节点。通过统计system.peers中的节点数,总节点数为entries_count_in_peers + 1
下面是system.peerstable
的结构(CQL)CREATE TABLE system.peers (
peer inet PRIMARY KEY,
data_center text,
host_id uuid,
preferred_ip inet,
rack text,
release_version text,
rpc_address inet,
schema_version uuid,
tokens set<text>
)
每个节点有一个分区(Thrift 术语中的行键)