Search in sources :

Example 31 with AffinityAssignment

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);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) HashSet(java.util.HashSet)

Example 32 with AffinityAssignment

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

AffinityAssignment (org.apache.ignite.internal.processors.affinity.AffinityAssignment)32 ClusterNode (org.apache.ignite.cluster.ClusterNode)19 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)17 UUID (java.util.UUID)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)7 Map (java.util.Map)7 GridDhtPartitionMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap)7 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)6 GridTimeoutObject (org.apache.ignite.internal.processors.timeout.GridTimeoutObject)6 List (java.util.List)5 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)5 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)5 CacheStorePartialUpdateException (org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException)5 GridCacheOperation (org.apache.ignite.internal.processors.cache.GridCacheOperation)5 GridCacheUpdateAtomicResult (org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult)5 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)5 GridDhtCacheEntry (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry)5 IgniteBiTuple (org.apache.ignite.lang.IgniteBiTuple)5