Search code examples
ignite

How to know which nodes does one cache entry reside


I have an Ignite Cluster with 10 nodes, I have a partitioned cache, 2 backups. For a given cache entry, i would like to know which nodes doesn't this entry reside in? Looks the command line interface(ignitevisorcmd.sh) doesn't provide this functionality.


Solution

  • This is how you can get primary node for a key:

    Affinity affinity = ignite.affinity("my-cache");
    ClusterNode primary = affinity.mapKeyToNode(key);
    

    Affinity API has also bunch of other methods that allow to manually calculate affinity (partition numbers, node mappings, etc).