Hi,
I saw that in cassandra-driver-core,(3.1.0) Metadata.TokenMap has
primaryToTokens which has the value for ALL the nodes.
I tried to find (primary)range ownership for nodes in one DC.
And executed the following in debug mode in IDE.
TreeMap<Long,Host> primaryTokenMap = new TreeMap<>();
for(Host host :
main.cluster.getMetadata().tokenMap.primaryToTokens.keySet()){
if(!host.getDatacenter().equals("dc2"))
continue;
for(Token token :
main.cluster.getMetadata().tokenMap.primaryToTokens.get(host)){
primaryTokenMap.put((Long) token.getValue(),host);
}
}
primaryTokenMap //this printed the map in evaluate code fragment window
dc2 has 3 nodes, RF is 3
Sample entries :
244925668410340093 -> /10.0.3.79:9042
291047688656337660 -> /10.0.3.217:9042
317775761591844910 -> /10.0.3.135:9042
328177243900091789 -> /10.0.3.79:9042
329239043633655596 -> /10.0.3.135:9042
....
Can I safely assume
Token
Range
Host
244925668410340093 to 291047688656337660 -1 belongs to 10.0.3.79:9042
291047688656337660 to 317775761591844910 -1 belongs to 10.0.3.135:9042
317775761591844910 to 328177243900091789 -1 belongs to 10.0.3.135:9042
And so on.
Is the above assumption ABSOLUTELY correct?
(Kindly suggest changes/errors, if any)
Any help would be great.
Thanks and Regards,
Siddharth Verma