Master node and Replica node for partition Id


We are using Rack-awareness feature. We want to check master node and replica node for some partition Ids to check if they are on different racks/hosts

Whats command to check master node and replica node for a given partition Id ?


You can use the partition-info command.

asinfo -v "partition-info" -l
# or
asadm -e "asinfo -v 'partition-info' -l"

The command isn’t really documented, it primarily used by QA, though asadm uses it for its ‘show pmap’ command which could be used to infer what you are asking.

asadm -e "show pmap"

You could also use replicas-all - this also isn’t documented, it is used by our clients to determine which nodes own which partitions.

asadm -e "asinfo -v 'replicas-all'"

It returns a list of base64 encoded bitmaps for each namespace. Basically if a node in rack 1 has a bit set for some offset on the first bitmap then no other node in that rack should have a bit set for that offset in any of the bitmaps (unless, of course, n_racks is less than the configured replication-factor).