Which Cassandra version you are using.
I have tested it from Cassandra 2.x and Cassandra 3.x version. It is working properly.
root@cqlsh:test_db> SELECT token(name) from test_temp ;
system.token(name)
---------------------
-907920378987128470
nodetool getendpoints test_db test_temp -907920378987128470;
192.168.8.52
Updated Answer: Got the issue
Issue is generated for when 1st part of partition key is int.
CREATE TABLE test6 (
age int PRIMARY KEY,
name text
);
bin/nodetool getendpoints test test6 -7072928299163215694
error: For input string: "-7072928299163215694"java.lang.NumberFormatException: For input string:"-
7072928299163215694"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:583)
at java.lang.Integer.parseInt(Integer.java:615)
But works properly for below input
bin/nodetool getendpoints test test6 -7072
127.0.0.1
From DataStax Doc:
Provides the end points that own the partition key. The partitioner returns a token for the key. Cassandra will return an endpoint whether or not data exists on the identified node for that token.
** key is the partition key of the end points you want to get.
nodetool getendpoints actually takes the value of the partition key as input. In this case '-7072928299163215694' it is parsing it as an Integer thus end up thowing exception. It is working for long or String (it is taking '-7072928299163215694' value as a String) cause it has taken this as value of the key not actual token. It is not parsing tokens. So providing tokens as an input will not work.
getendpoints generates tokens from the value of the key and provide you the endpoints (nodes) the key is residing.
Please check this link:
What node does Cassandra store data on?
A patch has been provided for this:
https://issues.apache.org/jira/browse/CASSANDRA-4551
Hope this helps.