2

Is there a way to see token ranges for each node in cassandra which used vnodes? I dont want to see token for each node which you get by issuing nodetool ring. I just want to see the token ranger for each node which uses vnodes.

user1870400
  • 6,028
  • 13
  • 54
  • 115

1 Answers1

2

The token ranges for a given node will be a function of a keyspace's topology.

Programmatically you can use the java-driver for this using Cluster.getMetadata().getTokenRanges(keyspace, host). The following code example shows retrieving all token ranges by host for a keyspace:

String keyspace = "mykeyspace";
for(Host host : cluster.getMetadata().getAllHosts()) {
    Set<TokenRange> hostRanges = cluster.getMetadata().getTokenRanges(keyspace, host);
}

Additionally you can get at this using JMX to a Cassandra node via org.apache.cassandra.db:type=StorageService#getRangeToEndpointMap|getRangeToRpcaddressMap(String)

Andy Tolbert
  • 11,418
  • 1
  • 30
  • 45