Re: Run task on all nodes with specified cache and throw exception if some node is offline

2019-04-05 Thread dilaz03
OK. I have found solution with IgniteCompute#affinityCall.



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


Run task on all nodes with specified cache and throw exception if some node is offline

2019-04-05 Thread Dmitry Lazurkin
Hello.

I would like to run task on all nodes with specified cache or all
partitions of specified cache and throw exception if some node is
offline. I use this code:

private ClusterGroup getCacheClusterGroup() {
Set baselineConsitentIds = ignite
.cluster()
.currentBaselineTopology()
.stream()
.map(n -> n.consistentId())
.collect(toSet());

ClusterGroup cacheClusterGroup = ignite
.cluster()
.forCacheNodes("test_cache");

cacheClusterGroup
.nodes()
.forEach(n -> baselineConsitentIds.remove(n.consistentId()));

if (!baselineConsitentIds.isEmpty()) {
throw new IllegalStateException("Some Ignite baseline nodes are offline:
" + baselineConsitentIds);
}

return cacheClusterGroup;
}


ignite
.compute(getCacheClusterGroup())
.broadcast(job)

Is it good solution? May be someone knows something better...

Thank you.