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)