You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Dmitry Lazurkin <di...@gmail.com> on 2019/04/05 10:52:31 UTC

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

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<Object> 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.


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

Posted by dilaz03 <di...@gmail.com>.
OK. I have found solution with IgniteCompute#affinityCall.



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