Hi Prasad,

Affinity function does not directly map keys to nodes, it maps keys to
partitions. So it takes care about entities balance between nodes. To read
more please take a look here:


In case if for every subscriber you are going to create it's own cache then
you can try to setup the node filters for every subscriber:


If you have the same cache for all subscribers then try to setup your own
AffinityKey (as descibed above):

            IgniteCache<EntityKey, String> cache =

            for (int i = 0 ; i < 1_000_000; i++) {
                cache.put(new EntityKey(2*i, 1L), "Value1" + i); //sub id =
                cache.put(new EntityKey(2*i + 1, 2L), "Value2" + i); //sub
id =2


    public static class EntityKey {
        public EntityKey(long id, long subscriberId) {
            this.id = id;
            this.subscriberId = subscriberId;

        private long id;

        // Subscriber ID which will be used for affinity.
        private long subscriberId;

        public long getSubscriberId() {
            return subscriberId;

        public long getId() {
            return id;

Thank you,

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

Reply via email to