I went through Is there a way to see token ranges for each node in cassandra which uses vnodes?. In this implementation we get all hosts and get token ranges in those individual hosts to get all token range across all nodes.
But, in my case, I am using below code:
public static synchronized List<Object[]> getTokenRangesAcrossNodes(
final String node, final Integer port, final String userName, final String password) {
if (cluster == null) {
connect(node, port, userName, password);
}
Metadata metadata = cluster.getMetadata();
return unwrapTokenRanges(new ArrayList<>(metadata.getTokenRanges()));
}
In above connect()
function node
has all the comma seperated cassandra host string and I use Cluster.builder().addContactPoints() to create session.
My question is:
- Does
metadata.getTokenRanges()
gives all token ranges across all hosts? or do I need to get all hosts and get token ranges for each host? - Does fetching token range across all nodes is different from the token range for a given
keyspace
?
Cassandra version: 3.*