Search in sources :

Example 11 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class CacheAffinitySharedManager method onChangeAffinityMessage.

/**
     * Called on exchange initiated by {@link CacheAffinityChangeMessage} which sent after rebalance finished.
     *
     * @param exchFut Exchange future.
     * @param crd Coordinator flag.
     * @param msg Message.
     * @throws IgniteCheckedException If failed.
     */
public void onChangeAffinityMessage(final GridDhtPartitionsExchangeFuture exchFut, boolean crd, final CacheAffinityChangeMessage msg) throws IgniteCheckedException {
    assert affCalcVer != null || cctx.kernalContext().clientNode();
    assert msg.topologyVersion() != null && msg.exchangeId() == null : msg;
    assert affCalcVer == null || affCalcVer.equals(msg.topologyVersion());
    final AffinityTopologyVersion topVer = exchFut.topologyVersion();
    if (log.isDebugEnabled()) {
        log.debug("Process affinity change message [exchVer=" + exchFut.topologyVersion() + ", affCalcVer=" + affCalcVer + ", msgVer=" + msg.topologyVersion() + ']');
    }
    final Map<Integer, Map<Integer, List<UUID>>> affChange = msg.assignmentChange();
    assert !F.isEmpty(affChange) : msg;
    final Map<Integer, IgniteUuid> deploymentIds = msg.cacheDeploymentIds();
    final Map<Object, List<List<ClusterNode>>> affCache = new HashMap<>();
    forAllCaches(crd, new IgniteInClosureX<GridAffinityAssignmentCache>() {

        @Override
        public void applyx(GridAffinityAssignmentCache aff) throws IgniteCheckedException {
            AffinityTopologyVersion affTopVer = aff.lastVersion();
            assert affTopVer.topologyVersion() > 0 : affTopVer;
            DynamicCacheDescriptor desc = registeredCaches.get(aff.cacheId());
            assert desc != null : aff.cacheName();
            IgniteUuid deploymentId = desc.deploymentId();
            if (!deploymentId.equals(deploymentIds.get(aff.cacheId()))) {
                aff.clientEventTopologyChange(exchFut.discoveryEvent(), topVer);
                return;
            }
            Map<Integer, List<UUID>> change = affChange.get(aff.cacheId());
            if (change != null) {
                assert !change.isEmpty() : msg;
                List<List<ClusterNode>> curAff = aff.assignments(affTopVer);
                List<List<ClusterNode>> assignment = new ArrayList<>(curAff);
                for (Map.Entry<Integer, List<UUID>> e : change.entrySet()) {
                    Integer part = e.getKey();
                    List<ClusterNode> nodes = toNodes(topVer, e.getValue());
                    assert !nodes.equals(assignment.get(part)) : "Assignment did not change " + "[cache=" + aff.cacheName() + ", part=" + part + ", cur=" + F.nodeIds(assignment.get(part)) + ", new=" + F.nodeIds(nodes) + ", exchVer=" + exchFut.topologyVersion() + ", msgVer=" + msg.topologyVersion() + ']';
                    assignment.set(part, nodes);
                }
                aff.initialize(topVer, cachedAssignment(aff, assignment, affCache));
            } else
                aff.clientEventTopologyChange(exchFut.discoveryEvent(), topVer);
        }
    });
    synchronized (mux) {
        if (affCalcVer == null)
            affCalcVer = msg.topologyVersion();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Example 12 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class GridCacheDeploymentManager method addGlobalParticipants.

/**
     * @param sndNodeId Sender node ID.
     * @param sndLdrId Sender loader ID.
     * @param participants Participants.
     * @param locDepOwner {@code True} if local deployment owner.
     * @return Added participants.
     */
@Nullable
private Map<UUID, IgniteUuid> addGlobalParticipants(UUID sndNodeId, IgniteUuid sndLdrId, Map<UUID, IgniteUuid> participants, boolean locDepOwner) {
    Map<UUID, IgniteUuid> added = null;
    if (participants != null) {
        for (Map.Entry<UUID, IgniteUuid> entry : participants.entrySet()) {
            UUID nodeId = entry.getKey();
            IgniteUuid ldrVer = entry.getValue();
            if (!ldrVer.equals(allParticipants.get(nodeId))) {
                allParticipants.put(nodeId, ldrVer);
                if (added == null)
                    added = IgniteUtils.newHashMap(participants.size());
                added.put(nodeId, ldrVer);
            }
        }
    }
    if (locDepOwner) {
        assert sndNodeId != null;
        assert sndLdrId != null;
        if (!sndLdrId.equals(allParticipants.get(sndNodeId))) {
            allParticipants.put(sndNodeId, sndLdrId);
            if (added == null)
                added = U.newHashMap(1);
            added.put(sndNodeId, sndLdrId);
        }
    }
    return added;
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) Map(java.util.Map) Nullable(org.jetbrains.annotations.Nullable)

Example 13 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class GridCacheDeploymentManager method addDeploymentContext.

/**
     * Adds deployment info to deployment contexts queue.
     *
     * @param info Info to add.
     */
public void addDeploymentContext(GridDeploymentInfo info) {
    IgniteUuid ldrId = info.classLoaderId();
    while (true) {
        CachedDeploymentInfo<K, V> depInfo = deps.get(ldrId);
        if (depInfo == null) {
            depInfo = new CachedDeploymentInfo<>(ldrId.globalId(), ldrId, info.userVersion(), info.deployMode(), info.participants());
            CachedDeploymentInfo<K, V> old = deps.putIfAbsent(ldrId, depInfo);
            if (old != null)
                depInfo = old;
            else
                break;
        }
        Map<UUID, IgniteUuid> participants = info.participants();
        if (participants != null) {
            if (!depInfo.addParticipants(participants, cctx)) {
                deps.remove(ldrId, depInfo);
                continue;
            }
        }
        break;
    }
}
Also used : IgniteUuid(org.apache.ignite.lang.IgniteUuid) UUID(java.util.UUID)

Example 14 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class CacheDataStructuresManager method onReconnected.

/**
     * @param clusterRestarted Cluster restarted flag.
     * @throws IgniteCheckedException If failed.
     */
public void onReconnected(boolean clusterRestarted) throws IgniteCheckedException {
    for (Map.Entry<IgniteUuid, GridCacheSetProxy> e : setsMap.entrySet()) {
        GridCacheSetProxy set = e.getValue();
        if (clusterRestarted) {
            set.blockOnRemove();
            setsMap.remove(e.getKey(), set);
        } else
            set.needCheckNotRemoved();
    }
    for (Map.Entry<IgniteUuid, GridCacheQueueProxy> e : queuesMap.entrySet()) {
        GridCacheQueueProxy queue = e.getValue();
        if (clusterRestarted) {
            queue.delegate().onRemoved(false);
            queuesMap.remove(e.getKey(), queue);
        }
    }
}
Also used : GridCacheSetProxy(org.apache.ignite.internal.processors.datastructures.GridCacheSetProxy) IgniteUuid(org.apache.ignite.lang.IgniteUuid) GridCacheQueueProxy(org.apache.ignite.internal.processors.datastructures.GridCacheQueueProxy) Map(java.util.Map) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 15 with IgniteUuid

use of org.apache.ignite.lang.IgniteUuid in project ignite by apache.

the class GridDhtCacheAdapter method beginMultiUpdate.

/**
     * Starts multi-update lock. Will wait for topology future is ready.
     *
     * @return Topology version.
     * @throws IgniteCheckedException If failed.
     */
public AffinityTopologyVersion beginMultiUpdate() throws IgniteCheckedException {
    IgniteBiTuple<IgniteUuid, GridDhtTopologyFuture> tup = multiTxHolder.get();
    if (tup != null)
        throw new IgniteCheckedException("Nested multi-update locks are not supported");
    top.readLock();
    GridDhtTopologyFuture topFut;
    AffinityTopologyVersion topVer;
    try {
        // While we are holding read lock, register lock future for partition release future.
        IgniteUuid lockId = IgniteUuid.fromUuid(ctx.localNodeId());
        topVer = top.topologyVersion();
        MultiUpdateFuture fut = new MultiUpdateFuture(topVer);
        MultiUpdateFuture old = multiTxFuts.putIfAbsent(lockId, fut);
        assert old == null;
        topFut = top.topologyVersionFuture();
        multiTxHolder.set(F.t(lockId, topFut));
    } finally {
        top.readUnlock();
    }
    topFut.get();
    return topVer;
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteUuid(org.apache.ignite.lang.IgniteUuid)

Aggregations

IgniteUuid (org.apache.ignite.lang.IgniteUuid)98 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)22 UUID (java.util.UUID)19 IgniteException (org.apache.ignite.IgniteException)17 HashMap (java.util.HashMap)13 Map (java.util.Map)11 IgfsPath (org.apache.ignite.igfs.IgfsPath)11 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)10 ArrayList (java.util.ArrayList)9 ClusterNode (org.apache.ignite.cluster.ClusterNode)9 Nullable (org.jetbrains.annotations.Nullable)9 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)7 TreeSet (java.util.TreeSet)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 IgfsException (org.apache.ignite.igfs.IgfsException)6 IgfsPathNotFoundException (org.apache.ignite.igfs.IgfsPathNotFoundException)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 Event (org.apache.ignite.events.Event)5 TaskEvent (org.apache.ignite.events.TaskEvent)5 IgfsPathIsDirectoryException (org.apache.ignite.igfs.IgfsPathIsDirectoryException)5