You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Stanislav Lukyanov <st...@gmail.com> on 2018/06/16 14:34:49 UTC

RE: How to use Affinity Function to Map a set of Keys to a particularnode in a cluster?

Hi,

1. Yes
2. This is controlled by the AffinityFunction::assignPartitions implementation. If the default one doesn’t suite you, you have to write another one yourself.

Reading this thread I have a feeling that this is a case of the XY problem (https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem).
You’re asking about how to make sure that your keys 1-10000 are stored on the node 1, but this is not a business problem (this is the Y, not the X).

I believe that 99% of the Ignite’s use cases don’t require to implement the AffinityFunction (or even tune the default one).
In these cases, choosing an affinity key for your objects and defining it via @AffinityKeyMapped is enough. And a lot of the times you don’t even need the affinity key.
The developer normally don’t even need to think about the partition-to-node mappings (at least, not from the start).
That’s a part of the beauty of the scalable systems – you may add or remove a node and the system will just work, no need to change anything.

Try solving your problem by just defining the @AffinityKeyMapped – it seems that this thread has a lot of info on how the affinity collocation works.
If you’re still unsure of how to proceed, I suggest you describe your use case in more details.

Thanks,
Stan

From: the_palakkaran
Sent: 13 июня 2018 г. 12:11
To: user@ignite.apache.org
Subject: Re: How to use Affinity Function to Map a set of Keys to a particularnode in a cluster?

Thanks for the detailed reply, now everything makes more sense to me.

1.Do I have a control over number of partitions ignite makes? I think this
is done using affinity.setPartitions(5) right? 

2. Can I tell ignite to have a single partition of my cache in each node? [5
nodes => 5 partitions]

Your suggestion method 1 will have worked for me, if I knew in which
partition of which node all entries marked with (int) affinity = 1 --> means
ranging from 1-10000. I know about using
CacheConfiguration().getAffinityFunction().partition(Object key), but I
can't use this for each record, I need to know it in prior. And I also need
to know details of partitions against node.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/