1

I am using Infinispan version 8.2 .I already knew when an Node puts an entry to an Cache.It uses its internal hashing on the key and chooses a primary node in an cluster.

I know that we can override this hashing with our custom hash function.But I don't know where to start and how to start.I have searched through a lot of documents and websites.But,none of them had a proper description in it.

I want someone to help me in this.

Thanks in advance.

karthi keyan
  • 213
  • 2
  • 19

1 Answers1

2

If you speak about determining the hashCode (which affect mostly mapping Object -> segment), this is pretty easy:

Hash myHash = ...;
ConfigurationBuilder cb = new ConfigurationBuilder()
cb.clustering().hash().hash(myHash)

Don't confuse this with consistentHash (the name refers to old algorithm that is not used anymore) which maps segments to actual nodes. You could override that one, too, but getting that right could be tricky.

Radim Vansa
  • 5,686
  • 2
  • 25
  • 40
  • .Yes I got your point,But I want to map the segments to an particular node,So i need to understand and implement the tricky part.But I don't know how.. Can you help me with that? pls – karthi keyan Feb 25 '18 at 03:38
  • The only way is to read the code of existing implementations, and run as many tests from testsuite as you can with your impl (some tests expect that ownership will move so you can't just use these), adding a few tests for your desired behaviour. – Radim Vansa Feb 26 '18 at 08:46
  • The first question obviously is: what if some of your expected nodes is not available, how will you map the segment to one of the running nodes? And how will your app behave if the data is not on the node where you expect them. – Radim Vansa Feb 26 '18 at 08:48