use of org.apache.ignite.internal.processors.affinity.AffinityAssignment in project ignite by apache.
the class ReducePartitionMapper method stableDataNodes.
/**
* @param cacheIds Participating cache IDs.
* @param topVer Topology version.
* @param isReplicatedOnly If we must only have replicated caches.
* @return Data nodes or {@code null} if repartitioning started and we need to retry.
*/
private Collection<ClusterNode> stableDataNodes(List<Integer> cacheIds, AffinityTopologyVersion topVer, boolean isReplicatedOnly) {
GridCacheContext<?, ?> cctx = (isReplicatedOnly) ? cacheContext(cacheIds.get(0)) : firstPartitionedCache(cacheIds);
Set<ClusterNode> nodes;
// Explicit partitions mapping is not applicable to replicated cache.
final AffinityAssignment topologyAssignment = cctx.affinity().assignment(topVer);
if (cctx.isReplicated()) {
// Mutable collection needed for this particular case.
nodes = isReplicatedOnly && cacheIds.size() > 1 ? new HashSet<>(topologyAssignment.nodes()) : topologyAssignment.nodes();
} else
nodes = topologyAssignment.primaryPartitionNodes();
return narrowToCaches(cctx, nodes, cacheIds, topVer, null, isReplicatedOnly);
}
use of org.apache.ignite.internal.processors.affinity.AffinityAssignment in project ignite by apache.
the class ReducePartitionMapper method stableDataNodesSet.
/**
* Note: This may return unmodifiable set.
*
* @param topVer Topology version.
* @param cctx Cache context.
* @param parts Partitions.
*/
private Set<ClusterNode> stableDataNodesSet(AffinityTopologyVersion topVer, final GridCacheContext<?, ?> cctx, @Nullable final int[] parts) {
// Explicit partitions mapping is not applicable to replicated cache.
final AffinityAssignment topologyAssignment = cctx.affinity().assignment(topVer);
if (cctx.isReplicated())
return topologyAssignment.nodes();
if (parts == null)
return topologyAssignment.primaryPartitionNodes();
List<List<ClusterNode>> assignment = topologyAssignment.assignment();
Set<ClusterNode> nodes = new HashSet<>();
for (int part : parts) {
List<ClusterNode> partNodes = assignment.get(part);
if (!partNodes.isEmpty())
nodes.add(partNodes.get(0));
}
return nodes;
}
Aggregations