Is there a way to see token ranges for each node in cassandra which uses vnodes?

ⅰ亾dé卋堺 提交于 2019-12-10 23:19:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!