Is there a way to determine the number of nodes in a Cassandra cluster without first having a context?
I am trying to get that number to make sure that the user does not give me a replicating factor that is too large (i.e. says 10 with only 9 nodes.)
Important: At this point, the only interface I have is thrift in C.
Note: I looked into using the describe_ring() but unfortunately, the function forces you to have a valid context (so it describes the ring for that context and not the number of existing nodes in a Cassandra cluster.)
You can look at the system table using the Thrift protocol: system.peers. Here are listed all others nodes and their information, but not the local node. By counting the number of nodes in system.peers, the total node count is entries_count_in_peers + 1
Below is the structure (CQL) of the system.peers table
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>
)
There is one partition (row key in Thrift terminology) per node