You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by dmsy <du...@gmail.com> on 2017/01/21 00:08:57 UTC

Custom AffinityFunction

Can someone please explain the concept of partition in the AffinityFunction
interface. What is the purpose of a partition? Why not just map keys to node
directly? 

Background:
I am trying to make my data as evenly distributed as possible across 3
nodes. I have an object relationship that is very similar to a
organization/person example, where an organization can contain multiple
person. I want to have a very balanced person cache where if:
Org1 has 3 person(s)
Org2 has 3
Org3 has 2
Org4 has 1

Then the data should be distributed like:
Node 1, Org1, 3 person
Node 2, Org2, 3 person
Node 3, Org3, 2 person
Node 3, Org4, 1 person

This also requires all person that belong to an organization to be
collocated.

Any idea how this can be done?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Custom-AffinityFunction-tp10167.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Custom AffinityFunction

Posted by vkulichenko <va...@gmail.com>.
Yes, if collocated types are stored in different caches, these caches must
have the same affinity function.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Custom-AffinityFunction-tp10167p10396.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Custom AffinityFunction

Posted by dmsy <du...@gmail.com>.
Thanks for the quick response Val. Does that also mean that I wont be able to
take advantage of Affinity Collocation unless all Cache uses the same
AffinityFunction?



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Custom-AffinityFunction-tp10167p10391.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Custom AffinityFunction

Posted by vkulichenko <va...@gmail.com>.
Partitions are needed because number of keys is infinite, while number of
partitions is fixed. If topology changes, you need to remap only 1K
partitions (default value) instead of remapping all the keys in cache.

Distribution can indeed be uneven in case collocation is used, but in most
cases this levels off when the data set is fairly large and you have enough
nodes/memory to store it. In example with 10 entries it looks like a big
problem of course, but that's not what you will generally see in real life.

However, you can always implement your own AffinityFunction if you want to
plug in custom mapping strategy.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Custom-AffinityFunction-tp10167p10168.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.