Tom
Tom

Reputation: 6342

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.

Upvotes: 0

Views: 696

Answers (2)

Valentin Kulichenko
Valentin Kulichenko

Reputation: 8390

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).

Upvotes: 1

Aniketh Jain
Aniketh Jain

Reputation: 623

I had asked a similar question. You can go through it at this link:

Putting cache entries to specific Ignite Server

  1. At a higher level, Ignite takes the key that you give it while performing an put operation.
  2. It then forms an affinity key that is more suitable for hashing .
  3. It generates the hash code of this affinity key and performs a modulus operation (depending upon the number of Ignite Servers) to equally distribute it.

I think there is no way to find out the Ignite Server on which an entry resides. But, if your use case is to execute some computation in that specific grid, you can make use of Affinity Call in the Ignite Compute Grid or use invoke an Entry processor on that key.

Upvotes: 0

Related Questions