nodetool getendpoints

Provides the IP addresses or names of replicas that own the partition key.

Provides the IP addresses or names of replicas that own the partition key.

Synopsis

install_location/bin/nodetool <options> getendpoints -- <keyspace> <table> key
Table 1. Options
Short Long Description
-h --host Hostname or IP address.
-p --port Port number.
-pwf --password-file Password file path.
-pw --password Password.
-u --username Remote JMX agent username.
keyspace Name of keyspace.
table Name of table.
key Partition key of the end points you want to get.
-- Separates an option from an argument that could be mistaken for a option.

Example

For example, which nodes own partition key_1, key_2, and key_3?
Note: The partitioner returns a token for the key. DataStax Distribution of Apache Cassandra (DDAC) will return an endpoint whether or not data exists on the identified node for that token.
 $ nodetool -h 127.0.0.1 -p 7100 getendpoints myks mytable key_1
127.0.0.2
 $ nodetool -h 127.0.0.1 -p 7100 getendpoints myks mytable key_2
127.0.0.2

For example, consider the following table, which uses a primary key of race_year and race_name. This table is created in the cycling keyspace.

CREATE TABLE cycling.rank_by_year_and_name (
    race_year int,
    race_name text,
    rank int,
    cyclist_name text,
    PRIMARY KEY ((race_year, race_name), rank)
) WITH CLUSTERING ORDER BY (rank ASC);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Benjamin PRADES', 1);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Adam PHELAN', 2);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Thomas LEBAS', 3);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Giro d''Italia - Stage 11 - Forli > Imola', 'Ilnur ZAKARIN', 1);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Giro d''Italia - Stage 11 - Forli > Imola', 'Carlos BETANCUR', 2);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Phillippe GILBERT', 1);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Daniel MARTIN', 2);
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Johan Esteban CHAVES', 3);

Given the previous information that was inserted into the table, run nodetool getendpoints and enter a value from the partition key. For example:

nodetool getendpoints cycling rank_by_year_and_name "2014"
10.255.100.150

The resulting output is the IP address of the replica that owns the partition key. Alternatively, you can specify values that comprise the full primary key. For example:

nodetool getendpoints cycling rank_by_year_and_name "2014:4th Tour of Beijing"
10.255.100.150