问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/48933184/custom-hashing-function-in-infinispan