Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-09-18 Thread Mikhail
Hi You can gather your data by @AffinityKeyMapped in one partition, but you can not force partition to be stored on some particular node. So you can use the same @AffinityKeyMapped for all data related to a particular city and this means all data about this city and/or related to this city would

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-09-05 Thread krishd
Hello I have a similar requirement : Need particular AffinityKey related data to go to Partitions OF PREDEFINED NODES ONLY. For eg. a PersonCache with 5 partitions distributed across 3 nodes. The Person object has cityCode as AffinityKeyMapped. The Person objects can have any of these 4

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-13 Thread the_palakkaran
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]

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-13 Thread dkarachentsev
Hi, I totally agree with Val that implementing own AffinityFunction is quite complex way. Requirement that you described is named affinity co-location as I wrote before. Let me explain in more details what to do and what are the drawbacks. 1. Use use @AffinityKeyMapped for all your keys. For

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Hi Val, My requirement is something like this: 5 nodes, 5 customers. I will keep data of 1 on each node. Whenever a file in the range 1-1 is coming in, I will process it in node 1, so that the read time is minimal (rather than looking for data on all nodes). I hope you got my

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread vkulichenko
Yes, every time topology is changed, assignments will be recalculated and data will be rebalanced. By partitioning mechanisms I meant basically the same that Dmitry was describing before. Ignite automatically distributes cache entries across nodes based on built-in affinity function. This

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
The requirement is an actual scenario, mate. I would have explained it if it was not a public forum. Also this is now a personal interest of mine, you have a great product, buddy. What are those "partitioning" mechanisms? -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread vkulichenko
Hi the_palakkaran, Where this requirement is coming from? Why won't you just use partitioning mechanisms Ignite provides out of the box? -Val -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Thanks a ton man !! One last doubt. Will this overridden partition method be invoked everytime a new node is added to the cluster? (Since there can be a new partition created at that time). Similarly, when one node in the cluster is down, hence one partition is gone, then also will this be

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Thanks a ton again. Still few more doubts : //It's much better if you in AffinityFunction.partition() method will calculate node according to your key. If you have key 1-1 it should go to partitions that belong to a single node. But at the same time method assignPartitions() should assign

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread dkarachentsev
There are various possible ways, but use one partition per node is definitely a bad idea, because you're loosing scaling possibilities. If you have 5 partitions and 5 nodes, then 6 node will be empty. It's much better if you in AffinityFunction.partition() method will calculate node according to

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Actually my requirement is something like the below: I have customers with customer numbers from 1 to 5, I have 5 nodes. I need my first 1 in node1, next 1 in node2 and so on. So I guess I cannot do that here. Again about the below: //AffinityFunction does two things: maps

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread dkarachentsev
Normally (without @AffinityKeyMapped) Ignite will use CustomerKey hash code (not object hashCode()) to find a partition. Ignite will colsult with AffinityFunction (partition() method) and to what partition put key and with assignPartitions find concrete node that holds that partition. In other

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Thanks. I still have few doubts: 1. If I have a customer id, customer number, customer name fields in CustomerKey, but only customer number is unique, I should annotate only customer number with @@AffinityKeyMapped. Is that so? 2. If so, ignite internally decides which node a key with the

Re: How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread dkarachentsev
Hi, Make sure that your keys are go to specific partition. Only one node could keep that partition at a time (except backups, of course). To do that, you may use @AffinityKeyMapped annotation [1]. Additionally you can implement your own AffinityFunction that will assign partitions that you need

How to use Affinity Function to Map a set of Keys to a particular node in a cluster?

2018-06-12 Thread the_palakkaran
Hi, How can I use Affinity Function to map a set of keys (may be an id range) to a particular node? What I need is that all the time this node will be responsible for loading/handling these set of keys. Also if there is a node failure, this should be distributed to other nodes. -- Sent