问题
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.
回答1:
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)
来源:https://stackoverflow.com/questions/34762730/is-there-a-way-to-see-token-ranges-for-each-node-in-cassandra-which-uses-vnodes