2 Replies Latest reply on Jan 8, 2010 9:43 AM by Mircea Markus

    Key/node affinity - how to get it?

    Nikita Ivanov Newbie

      Hey Guys,

      We are looking at integrating GridGain 2.x with Infinispan for one of our clients and I can't find a way to get a key-to-node mapping, i.e. given a key how do I get a node where data for this key is stored (partitioned cache, of course)?

       

      Thanks in advance!

      Nikita.

        • 1. Re: Key/node affinity - how to get it?
          Manik Surtani Master

          Hi Nikita,

           

          Not sure I understand. 

           

          Doing a Cache.get(key) will perform the necessary remote lookups if the key is not mapped to the instance you invoked the method on (and is not in L1 - provided you have enabled L1 caching). 

           

          If you want to generate a key such that it will always be stored on a local instance (in addition to N backups), there is currently a feature request for this which will be there in 4.1.0.  The JIRA (ISPN-232) contains info on how you could do this yourself for the time being.

           

          HTH,

          Manik

          1 of 1 people found this helpful
          • 2. Re: Key/node affinity - how to get it?
            Mircea Markus Master

            If you have the key, you can determine the node(s) on which it resides as follows:

             

                  ConsistentHash consistentHash = cache1.getAdvancedCache().getDistributionManager().getConsistentHash();
                  consistentHash.locate("yourKey",1)

            1 of 1 people found this helpful