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.