Search in sources :

Example 6 with CachePartialUpdateCheckedException

use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.

the class PlatformCache method convertException.

/** {@inheritDoc} */
@Override
public Exception convertException(Exception e) {
    if (e instanceof CachePartialUpdateException)
        return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException) e.getCause(), platformCtx, keepBinary);
    if (e instanceof CachePartialUpdateCheckedException)
        return new PlatformCachePartialUpdateException((CachePartialUpdateCheckedException) e, platformCtx, keepBinary);
    if (e.getCause() instanceof EntryProcessorException)
        return (Exception) e.getCause();
    TransactionDeadlockException deadlockException = X.cause(e, TransactionDeadlockException.class);
    if (deadlockException != null)
        return deadlockException;
    TransactionTimeoutException timeoutException = X.cause(e, TransactionTimeoutException.class);
    if (timeoutException != null)
        return timeoutException;
    return super.convertException(e);
}
Also used : TransactionDeadlockException(org.apache.ignite.transactions.TransactionDeadlockException) EntryProcessorException(javax.cache.processor.EntryProcessorException) TransactionTimeoutException(org.apache.ignite.transactions.TransactionTimeoutException) CachePartialUpdateException(org.apache.ignite.cache.CachePartialUpdateException) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException)

Example 7 with CachePartialUpdateCheckedException

use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.

the class GridNearAtomicUpdateFuture method onAllReceived.

/**
     * @return Non null topology version if update should be remapped.
     */
@Nullable
private AffinityTopologyVersion onAllReceived() {
    assert Thread.holdsLock(this);
    assert futureMapped() : this;
    AffinityTopologyVersion remapTopVer0 = null;
    if (remapKeys != null) {
        assert remapTopVer != null;
        remapTopVer0 = remapTopVer;
    } else {
        if (err != null && X.hasCause(err, CachePartialUpdateCheckedException.class) && X.hasCause(err, ClusterTopologyCheckedException.class) && storeFuture() && --remapCnt > 0) {
            ClusterTopologyCheckedException topErr = X.cause(err, ClusterTopologyCheckedException.class);
            if (!(topErr instanceof ClusterTopologyServerNotFoundException)) {
                CachePartialUpdateCheckedException cause = X.cause(err, CachePartialUpdateCheckedException.class);
                assert cause != null && cause.topologyVersion() != null : err;
                assert remapKeys == null;
                assert remapTopVer == null;
                remapTopVer = remapTopVer0 = new AffinityTopologyVersion(cause.topologyVersion().topologyVersion() + 1);
                err = null;
                Collection<Object> failedKeys = cause.failedKeys();
                remapKeys = new ArrayList<>(failedKeys.size());
                for (Object key : failedKeys) remapKeys.add(cctx.toCacheKeyObject(key));
            }
        }
    }
    if (remapTopVer0 != null) {
        cctx.mvcc().removeAtomicFuture(futId);
        topVer = AffinityTopologyVersion.ZERO;
        futId = 0;
        remapTopVer = null;
    }
    return remapTopVer0;
}
Also used : AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with CachePartialUpdateCheckedException

use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.

the class GridNearAtomicUpdateFuture method waitAndRemap.

private void waitAndRemap(AffinityTopologyVersion remapTopVer) {
    assert remapTopVer != null;
    if (topLocked) {
        assert !F.isEmpty(remapKeys) : remapKeys;
        CachePartialUpdateCheckedException e = new CachePartialUpdateCheckedException("Failed to update keys (retry update if possible).");
        ClusterTopologyCheckedException cause = new ClusterTopologyCheckedException("Failed to update keys, topology changed while execute atomic update inside transaction.");
        cause.retryReadyFuture(cctx.affinity().affinityReadyFuture(remapTopVer));
        e.add(remapKeys, cause);
        completeFuture(null, e, null);
        return;
    }
    IgniteInternalFuture<AffinityTopologyVersion> fut = cctx.shared().exchange().affinityReadyFuture(remapTopVer);
    if (fut == null)
        fut = new GridFinishedFuture<>(remapTopVer);
    fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {

        @Override
        public void apply(final IgniteInternalFuture<AffinityTopologyVersion> fut) {
            cctx.kernalContext().closure().runLocalSafe(new Runnable() {

                @Override
                public void run() {
                    mapOnTopology();
                }
            });
        }
    });
}
Also used : AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture)

Example 9 with CachePartialUpdateCheckedException

use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.

the class GridNearAtomicUpdateFuture method onNodeLeft.

/** {@inheritDoc} */
@Override
public boolean onNodeLeft(UUID nodeId) {
    GridCacheReturn opRes0 = null;
    CachePartialUpdateCheckedException err0 = null;
    AffinityTopologyVersion remapTopVer0 = null;
    boolean rcvAll = false;
    List<GridNearAtomicCheckUpdateRequest> checkReqs = null;
    long futId;
    synchronized (this) {
        if (!futureMapped())
            return false;
        futId = this.futId;
        if (singleReq != null) {
            if (singleReq.req.nodeId.equals(nodeId)) {
                GridNearAtomicAbstractUpdateRequest req = singleReq.onPrimaryFail();
                if (req != null) {
                    rcvAll = true;
                    GridNearAtomicUpdateResponse res = primaryFailedResponse(req);
                    singleReq.onPrimaryResponse(res, cctx);
                    onPrimaryError(req, res);
                }
            } else {
                DhtLeftResult res = singleReq.onDhtNodeLeft(nodeId);
                if (res == DhtLeftResult.DONE)
                    rcvAll = true;
                else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY)
                    checkReqs = Collections.singletonList(new GridNearAtomicCheckUpdateRequest(singleReq.req));
            }
            if (rcvAll) {
                opRes0 = opRes;
                err0 = err;
                remapTopVer0 = onAllReceived();
            }
        } else {
            if (mappings == null)
                return false;
            for (Map.Entry<UUID, PrimaryRequestState> e : mappings.entrySet()) {
                assert e.getKey().equals(e.getValue().req.nodeId());
                PrimaryRequestState reqState = e.getValue();
                boolean reqDone = false;
                if (e.getKey().equals(nodeId)) {
                    GridNearAtomicAbstractUpdateRequest req = reqState.onPrimaryFail();
                    if (req != null) {
                        reqDone = true;
                        GridNearAtomicUpdateResponse res = primaryFailedResponse(req);
                        reqState.onPrimaryResponse(res, cctx);
                        onPrimaryError(req, res);
                    }
                } else {
                    DhtLeftResult res = reqState.onDhtNodeLeft(nodeId);
                    if (res == DhtLeftResult.DONE)
                        reqDone = true;
                    else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY) {
                        if (checkReqs == null)
                            checkReqs = new ArrayList<>();
                        checkReqs.add(new GridNearAtomicCheckUpdateRequest(reqState.req));
                    }
                }
                if (reqDone) {
                    assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
                    resCnt++;
                    if (mappings.size() == resCnt) {
                        rcvAll = true;
                        opRes0 = opRes;
                        err0 = err;
                        remapTopVer0 = onAllReceived();
                        break;
                    }
                }
            }
        }
    }
    if (checkReqs != null) {
        assert !rcvAll;
        for (int i = 0; i < checkReqs.size(); i++) sendCheckUpdateRequest(checkReqs.get(i));
    } else if (rcvAll)
        finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
    return false;
}
Also used : GridCacheReturn(org.apache.ignite.internal.processors.cache.GridCacheReturn) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException) UUID(java.util.UUID) Map(java.util.Map)

Example 10 with CachePartialUpdateCheckedException

use of org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException in project ignite by apache.

the class GridNearAtomicUpdateFuture method checkDhtNodes.

private void checkDhtNodes(long futId) {
    GridCacheReturn opRes0 = null;
    CachePartialUpdateCheckedException err0 = null;
    AffinityTopologyVersion remapTopVer0 = null;
    List<GridNearAtomicCheckUpdateRequest> checkReqs = null;
    boolean rcvAll = false;
    synchronized (this) {
        if (!checkFutureId(futId))
            return;
        if (singleReq != null) {
            if (!singleReq.req.initMappingLocally())
                return;
            DhtLeftResult res = singleReq.checkDhtNodes(cctx);
            if (res == DhtLeftResult.DONE) {
                opRes0 = opRes;
                err0 = err;
                remapTopVer0 = onAllReceived();
            } else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY)
                checkReqs = Collections.singletonList(new GridNearAtomicCheckUpdateRequest(singleReq.req));
            else
                return;
        } else {
            if (mappings != null) {
                for (PrimaryRequestState reqState : mappings.values()) {
                    if (!reqState.req.initMappingLocally())
                        continue;
                    DhtLeftResult res = reqState.checkDhtNodes(cctx);
                    if (res == DhtLeftResult.DONE) {
                        assert mappings.size() > resCnt : "[mappings=" + mappings.size() + ", cnt=" + resCnt + ']';
                        resCnt++;
                        if (mappings.size() == resCnt) {
                            rcvAll = true;
                            opRes0 = opRes;
                            err0 = err;
                            remapTopVer0 = onAllReceived();
                            break;
                        }
                    } else if (res == DhtLeftResult.ALL_RCVD_CHECK_PRIMARY) {
                        if (checkReqs == null)
                            checkReqs = new ArrayList<>(mappings.size());
                        checkReqs.add(new GridNearAtomicCheckUpdateRequest(reqState.req));
                    }
                }
            } else
                return;
        }
    }
    if (checkReqs != null) {
        assert !rcvAll;
        for (int i = 0; i < checkReqs.size(); i++) sendCheckUpdateRequest(checkReqs.get(i));
    } else if (rcvAll)
        finishUpdateFuture(opRes0, err0, remapTopVer0, futId);
}
Also used : GridCacheReturn(org.apache.ignite.internal.processors.cache.GridCacheReturn) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException)

Aggregations

CachePartialUpdateCheckedException (org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException)17 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)12 GridCacheReturn (org.apache.ignite.internal.processors.cache.GridCacheReturn)9 Map (java.util.Map)4 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)4 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)4 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 UUID (java.util.UUID)2 EntryProcessorException (javax.cache.processor.EntryProcessorException)2 EntryProcessorResult (javax.cache.processor.EntryProcessorResult)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)2 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)2 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)2 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)2 GridFinishedFuture (org.apache.ignite.internal.util.future.GridFinishedFuture)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1