Search in sources :

Example 36 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class BPlusTree method doRemove.

/**
     * @param row Lookup row.
     * @param needOld {@code True} if need return removed row.
     * @return Removed row.
     * @throws IgniteCheckedException If failed.
     */
private T doRemove(L row, boolean needOld) throws IgniteCheckedException {
    checkDestroyed();
    Remove r = new Remove(row, needOld);
    try {
        for (; ; ) {
            r.init();
            Result res = removeDown(r, r.rootId, 0L, 0L, r.rootLvl);
            switch(res) {
                case RETRY:
                case RETRY_ROOT:
                    checkInterrupted();
                    continue;
                default:
                    if (!r.isFinished()) {
                        res = r.finishTail();
                        // If not found, then the tree grew beyond our call stack -> retry from the actual root.
                        if (res == RETRY || res == NOT_FOUND) {
                            assert r.checkTailLevel(getRootLevel()) : "tail=" + r.tail + ", res=" + res;
                            checkInterrupted();
                            continue;
                        }
                        assert res == FOUND : res;
                    }
                    assert r.isFinished();
                    return r.rmvd;
            }
        }
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on search row: " + row, e);
    } catch (RuntimeException e) {
        throw new IgniteException("Runtime failure on search row: " + row, e);
    } catch (AssertionError e) {
        throw new AssertionError("Assertion error on search row: " + row, e);
    } finally {
        r.releaseAll();
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException)

Example 37 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class BPlusTree method invoke.

/** {@inheritDoc} */
@Override
public void invoke(L row, Object z, InvokeClosure<T> c) throws IgniteCheckedException {
    checkDestroyed();
    Invoke x = new Invoke(row, z, c);
    try {
        for (; ; ) {
            x.init();
            Result res = invokeDown(x, x.rootId, 0L, 0L, x.rootLvl);
            switch(res) {
                case RETRY:
                case RETRY_ROOT:
                    checkInterrupted();
                    continue;
                default:
                    if (!x.isFinished()) {
                        res = x.tryFinish();
                        if (res == RETRY || res == RETRY_ROOT) {
                            checkInterrupted();
                            continue;
                        }
                        assert x.isFinished() : res;
                    }
                    return;
            }
        }
    } catch (IgniteCheckedException e) {
        throw new IgniteCheckedException("Runtime failure on search row: " + row, e);
    } catch (RuntimeException e) {
        throw new IgniteException("Runtime failure on search row: " + row, e);
    } catch (AssertionError e) {
        throw new AssertionError("Assertion error on search row: " + row, e);
    } finally {
        x.releaseAll();
        checkDestroyed();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException)

Example 38 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridPartitionedGetFuture method localGet.

/**
     * @param key Key.
     * @param part Partition.
     * @param locVals Local values.
     * @return {@code True} if there is no need to further search value.
     */
private boolean localGet(KeyCacheObject key, int part, Map<K, V> locVals) {
    assert cctx.affinityNode() : this;
    GridDhtCacheAdapter<K, V> cache = cache();
    boolean readNoEntry = cctx.readNoEntry(expiryPlc, false);
    boolean evt = !skipVals;
    while (true) {
        try {
            boolean skipEntry = readNoEntry;
            EntryGetResult getRes = null;
            CacheObject v = null;
            GridCacheVersion ver = null;
            if (readNoEntry) {
                CacheDataRow row = cctx.offheap().read(key);
                if (row != null) {
                    long expireTime = row.expireTime();
                    if (expireTime == 0 || expireTime > U.currentTimeMillis()) {
                        v = row.value();
                        if (needVer)
                            ver = row.version();
                        if (evt) {
                            cctx.events().readEvent(key, null, row.value(), subjId, taskName, !deserializeBinary);
                        }
                    } else
                        skipEntry = false;
                }
            }
            if (!skipEntry) {
                GridCacheEntryEx entry = cache.entryEx(key);
                // If our DHT cache do has value, then we peek it.
                if (entry != null) {
                    boolean isNew = entry.isNewLocked();
                    if (needVer) {
                        getRes = entry.innerGetVersioned(null, null, /*update-metrics*/
                        false, /*event*/
                        evt, subjId, null, taskName, expiryPlc, !deserializeBinary, null);
                        if (getRes != null) {
                            v = getRes.value();
                            ver = getRes.version();
                        }
                    } else {
                        v = entry.innerGet(null, null, /*read-through*/
                        false, /*update-metrics*/
                        false, /*event*/
                        evt, subjId, null, taskName, expiryPlc, !deserializeBinary);
                    }
                    cache.context().evicts().touch(entry, topVer);
                    // Entry was not in memory or in swap, so we remove it from cache.
                    if (v == null) {
                        if (isNew && entry.markObsoleteIfEmpty(ver))
                            cache.removeEntry(entry);
                    }
                }
            }
            if (v != null) {
                cctx.addResult(locVals, key, v, skipVals, keepCacheObjects, deserializeBinary, true, getRes, ver, 0, 0, needVer);
                return true;
            }
            boolean topStable = cctx.isReplicated() || topVer.equals(cctx.topology().topologyVersion());
            // Entry not found, do not continue search if topology did not change and there is no store.
            if (!cctx.readThroughConfigured() && (topStable || partitionOwned(part))) {
                if (!skipVals && cctx.config().isStatisticsEnabled())
                    cache.metrics0().onRead(false);
                return true;
            }
            return false;
        } catch (GridCacheEntryRemovedException ignored) {
        // No-op, will retry.
        } catch (GridDhtInvalidPartitionException ignored) {
            return false;
        } catch (IgniteCheckedException e) {
            onDone(e);
            return true;
        }
    }
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) EntryGetResult(org.apache.ignite.internal.processors.cache.EntryGetResult) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 39 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridDhtPreloader method processAffinityAssignmentRequest.

/**
     * @param node Node.
     * @param req Request.
     */
private void processAffinityAssignmentRequest(final ClusterNode node, final GridDhtAffinityAssignmentRequest req) {
    final AffinityTopologyVersion topVer = req.topologyVersion();
    if (log.isDebugEnabled())
        log.debug("Processing affinity assignment request [node=" + node + ", req=" + req + ']');
    cctx.affinity().affinityReadyFuture(req.topologyVersion()).listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {

        @Override
        public void apply(IgniteInternalFuture<AffinityTopologyVersion> fut) {
            if (log.isDebugEnabled())
                log.debug("Affinity is ready for topology version, will send response [topVer=" + topVer + ", node=" + node + ']');
            AffinityAssignment assignment = cctx.affinity().assignment(topVer);
            GridDhtAffinityAssignmentResponse res = new GridDhtAffinityAssignmentResponse(req.futureId(), cctx.cacheId(), topVer, assignment.assignment());
            if (cctx.affinity().affinityCache().centralizedAffinityFunction()) {
                assert assignment.idealAssignment() != null;
                res.idealAffinityAssignment(assignment.idealAssignment());
            }
            try {
                cctx.io().send(node, res, AFFINITY_POOL);
            } catch (IgniteCheckedException e) {
                U.error(log, "Failed to send affinity assignment response to remote node [node=" + node + ']', e);
            }
        }
    });
}
Also used : AffinityAssignment(org.apache.ignite.internal.processors.affinity.AffinityAssignment) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridDhtAffinityAssignmentResponse(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtAffinityAssignmentResponse) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Example 40 with IgniteCheckedException

use of org.apache.ignite.IgniteCheckedException in project ignite by apache.

the class GridDhtPreloader method processForceKeysRequest0.

/**
     * @param node Node originated request.
     * @param msg Force keys message.
     */
private void processForceKeysRequest0(ClusterNode node, GridDhtForceKeysRequest msg) {
    if (!enterBusy())
        return;
    try {
        ClusterNode loc = cctx.localNode();
        GridDhtForceKeysResponse res = new GridDhtForceKeysResponse(cctx.cacheId(), msg.futureId(), msg.miniId(), cctx.deploymentEnabled());
        for (KeyCacheObject k : msg.keys()) {
            int p = cctx.affinity().partition(k);
            GridDhtLocalPartition locPart = top.localPartition(p, AffinityTopologyVersion.NONE, false);
            // If this node is no longer an owner.
            if (locPart == null && !top.owners(p).contains(loc)) {
                res.addMissed(k);
                continue;
            }
            GridCacheEntryEx entry = null;
            while (true) {
                try {
                    entry = cctx.dht().entryEx(k);
                    entry.unswap();
                    GridCacheEntryInfo info = entry.info();
                    if (info == null) {
                        assert entry.obsolete() : entry;
                        continue;
                    }
                    if (!info.isNew())
                        res.addInfo(info);
                    cctx.evicts().touch(entry, msg.topologyVersion());
                    break;
                } catch (GridCacheEntryRemovedException ignore) {
                    if (log.isDebugEnabled())
                        log.debug("Got removed entry: " + k);
                } catch (GridDhtInvalidPartitionException ignore) {
                    if (log.isDebugEnabled())
                        log.debug("Local node is no longer an owner: " + p);
                    res.addMissed(k);
                    break;
                }
            }
        }
        if (log.isDebugEnabled())
            log.debug("Sending force key response [node=" + node.id() + ", res=" + res + ']');
        cctx.io().send(node, res, cctx.ioPolicy());
    } catch (ClusterTopologyCheckedException ignore) {
        if (log.isDebugEnabled())
            log.debug("Received force key request form failed node (will ignore) [nodeId=" + node.id() + ", req=" + msg + ']');
    } catch (IgniteCheckedException e) {
        U.error(log, "Failed to reply to force key request [nodeId=" + node.id() + ", req=" + msg + ']', e);
    } finally {
        leaveBusy();
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridCacheEntryInfo(org.apache.ignite.internal.processors.cache.GridCacheEntryInfo) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1568 IgniteException (org.apache.ignite.IgniteException)388 ArrayList (java.util.ArrayList)237 IOException (java.io.IOException)226 ClusterNode (org.apache.ignite.cluster.ClusterNode)215 Map (java.util.Map)181 UUID (java.util.UUID)163 HashMap (java.util.HashMap)160 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)150 Test (org.junit.Test)143 List (java.util.List)139 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)138 Nullable (org.jetbrains.annotations.Nullable)134 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)118 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)109 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)105 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)104 Collection (java.util.Collection)97 HashSet (java.util.HashSet)97 Ignite (org.apache.ignite.Ignite)96