Re: Partitions distribution across nodes

2018-08-09 Thread dkarachentsev
Hi Akash,

1) Actually exchange is a short-time process when nodes remap partitions.
But Ignite uses late affinity assignment, that means affinity distribution
will be switched after rebalance completed. In other words after rebalance
it will atomically switch partition distribution.
But you don't have to wait when rebalance finish, because it works
asynchronously.

2) I think, simpler would be to use IgniteCluster to determine number of
nodes [1]:
Ignite ignite = Ignition.start("examples/config/example-ignite.xml");

if (ignite.cluster().forServers().nodes().size() == 4) {
//... loadCache
}
3) No, you can use some custom value in cache with putIfAsent() to
atomically get if some action was performed. 

[1] https://apacheignite.readme.io/docs/cluster-groups

Thanks!
-Dmitry



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


Re: Partitions distribution across nodes

2018-08-08 Thread akash shinde
Hi,

I introduced the delay of 5 seconds and it worked.

1) What is exchange process and how to identify whether exchange process is
finished?

2) I am doing partition key aware data loading and I want to start load
process from server node only and not from the client node. I just want to
initiate my load process only after all the configured nodes are up and
running.
For that I am using Distributed count down latch. Each node when started
reduces the count on LifecycleEventType.AFTER_NODE_START event. When this
count down latch count becomes zero, cache.loadCache() method is invoked
and this method is always executed from the node which joins the cluster
last.
Is there any better way to achieve this?

3) I also want to make sure that if any other node joins the cluster after
the data loading process is comeplete, cache.loadCache method is not
invoked and the data is made available to this node using re-balancing
process.
I am thinking to use some variable which will tell the cache loading is
complete. Does ignite have any builtin feature to achieve this?


Code is as shown below to get the ignite partitions.

private List getPrimaryParitionIdsLocalToNode() {
  Affinity affinity = igniteSpringBean.affinity(cacheName);
  ClusterNode locNode = igniteSpringBean.cluster().localNode();
  List primaryPartitionIds =
Arrays.stream(affinity.primaryPartitions(locNode)).boxed()
  .collect(Collectors.toList());
  LOGGER.info("Primary Partition Ids for Node {} are {}",
locNode.id(), primaryPartitionIds);
  LOGGER.info("Number of Primary Partition Ids for Node {} are {}",
locNode.id(), primaryPartitionIds.size());
  return primaryPartitionIds;
}

private List getBackupParitionIdsLocalToNode() {
  Affinity affinity = igniteSpringBean.affinity(cacheName);
  ClusterNode locNode = igniteSpringBean.cluster().localNode();
  List backPartitionIds =
Arrays.stream(affinity.backupPartitions(locNode)).boxed()
  .collect(Collectors.toList());
  LOGGER.info("Backup Partition Ids for Node {} are {}", locNode.id(),
backPartitionIds);
  LOGGER.info("Number of Backup Partition Ids for Node {} are {}",
locNode.id(), backPartitionIds.size());
  return backPartitionIds;
}


Thanks,
Akash


On Wed, Aug 8, 2018 at 1:16 PM dkarachentsev 
wrote:

> Hi Akash,
>
> How do you measure partition distribution? Can you provide code for that
> test? I can assume that you get partitions before exchange process if
> finished. Try to use delay in 5 sec after all nodes are started and check
> again.
>
> Thanks!
> -Dmitry
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>


Re: Partitions distribution across nodes

2018-08-08 Thread dkarachentsev
Hi Akash,

How do you measure partition distribution? Can you provide code for that
test? I can assume that you get partitions before exchange process if
finished. Try to use delay in 5 sec after all nodes are started and check
again.

Thanks!
-Dmitry



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