Search in sources :

Example 1 with CacheDataRow

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

the class GridCacheAdapter method getAllAsync0.

/**
     * @param keys Keys.
     * @param readerArgs Near cache reader will be added if not null.
     * @param readThrough Read-through flag.
     * @param checkTx Check local transaction flag.
     * @param subjId Subject ID.
     * @param taskName Task name/
     * @param deserializeBinary Deserialize binary flag.
     * @param expiry Expiry policy.
     * @param skipVals Skip values flag.
     * @param keepCacheObjects Keep cache objects.
     * @param canRemap Can remap flag.
     * @param needVer If {@code true} returns values as tuples containing value and version.
     * @return Future.
     */
protected final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(@Nullable final Collection<KeyCacheObject> keys, @Nullable final ReaderArguments readerArgs, final boolean readThrough, boolean checkTx, @Nullable final UUID subjId, final String taskName, final boolean deserializeBinary, @Nullable final IgniteCacheExpiryPolicy expiry, final boolean skipVals, final boolean keepCacheObjects, final boolean recovery, boolean canRemap, final boolean needVer) {
    if (F.isEmpty(keys))
        return new GridFinishedFuture<>(Collections.<K1, V1>emptyMap());
    GridNearTxLocal tx = null;
    if (checkTx) {
        try {
            checkJta();
        } catch (IgniteCheckedException e) {
            return new GridFinishedFuture<>(e);
        }
        tx = ctx.tm().threadLocalTx(ctx.systemTx() ? ctx : null);
    }
    if (tx == null || tx.implicit()) {
        Map<KeyCacheObject, EntryGetResult> misses = null;
        final AffinityTopologyVersion topVer = tx == null ? (canRemap ? ctx.affinity().affinityTopologyVersion() : ctx.shared().exchange().readyAffinityVersion()) : tx.topologyVersion();
        try {
            int keysSize = keys.size();
            GridDhtTopologyFuture topFut = ctx.shared().exchange().lastFinishedFuture();
            Throwable ex = topFut != null ? topFut.validateCache(ctx, recovery, /*read*/
            true, null, keys) : null;
            if (ex != null)
                return new GridFinishedFuture<>(ex);
            final Map<K1, V1> map = keysSize == 1 ? (Map<K1, V1>) new IgniteBiTuple<>() : U.<K1, V1>newHashMap(keysSize);
            final boolean storeEnabled = !skipVals && readThrough && ctx.readThrough();
            boolean readNoEntry = ctx.readNoEntry(expiry, readerArgs != null);
            for (KeyCacheObject key : keys) {
                while (true) {
                    try {
                        EntryGetResult res = null;
                        boolean evt = !skipVals;
                        boolean updateMetrics = !skipVals;
                        GridCacheEntryEx entry = null;
                        boolean skipEntry = readNoEntry;
                        if (readNoEntry) {
                            CacheDataRow row = ctx.offheap().read(key);
                            if (row != null) {
                                long expireTime = row.expireTime();
                                if (expireTime != 0) {
                                    if (expireTime > U.currentTimeMillis()) {
                                        res = new EntryGetWithTtlResult(row.value(), row.version(), false, expireTime, 0);
                                    } else
                                        skipEntry = false;
                                } else
                                    res = new EntryGetResult(row.value(), row.version(), false);
                            }
                            if (res != null) {
                                if (evt) {
                                    ctx.events().readEvent(key, null, row.value(), subjId, taskName, !deserializeBinary);
                                }
                                if (updateMetrics && ctx.cache().configuration().isStatisticsEnabled())
                                    ctx.cache().metrics0().onRead(true);
                            } else if (storeEnabled)
                                skipEntry = false;
                        }
                        if (!skipEntry) {
                            entry = entryEx(key);
                            if (entry == null) {
                                if (!skipVals && ctx.config().isStatisticsEnabled())
                                    ctx.cache().metrics0().onRead(false);
                                break;
                            }
                            if (storeEnabled) {
                                res = entry.innerGetAndReserveForLoad(updateMetrics, evt, subjId, taskName, expiry, !deserializeBinary, readerArgs);
                                assert res != null;
                                if (res.value() == null) {
                                    if (misses == null)
                                        misses = new HashMap<>();
                                    misses.put(key, res);
                                    res = null;
                                }
                            } else {
                                res = entry.innerGetVersioned(null, null, updateMetrics, evt, subjId, null, taskName, expiry, !deserializeBinary, readerArgs);
                                if (res == null)
                                    ctx.evicts().touch(entry, topVer);
                            }
                        }
                        if (res != null) {
                            ctx.addResult(map, key, res, skipVals, keepCacheObjects, deserializeBinary, true, needVer);
                            if (entry != null && (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED)))
                                ctx.evicts().touch(entry, topVer);
                            if (keysSize == 1)
                                // Safe to return because no locks are required in READ_COMMITTED mode.
                                return new GridFinishedFuture<>(map);
                        }
                        break;
                    } catch (GridCacheEntryRemovedException ignored) {
                        if (log.isDebugEnabled())
                            log.debug("Got removed entry in getAllAsync(..) method (will retry): " + key);
                    }
                }
            }
            if (storeEnabled && misses != null) {
                final Map<KeyCacheObject, EntryGetResult> loadKeys = misses;
                final IgniteTxLocalAdapter tx0 = tx;
                final Collection<KeyCacheObject> loaded = new HashSet<>();
                return new GridEmbeddedFuture(ctx.closures().callLocalSafe(ctx.projectSafe(new GPC<Map<K1, V1>>() {

                    @Override
                    public Map<K1, V1> call() throws Exception {
                        ctx.store().loadAll(null, /*tx*/
                        loadKeys.keySet(), new CI2<KeyCacheObject, Object>() {

                            @Override
                            public void apply(KeyCacheObject key, Object val) {
                                EntryGetResult res = loadKeys.get(key);
                                if (res == null || val == null)
                                    return;
                                loaded.add(key);
                                CacheObject cacheVal = ctx.toCacheObject(val);
                                while (true) {
                                    GridCacheEntryEx entry = null;
                                    try {
                                        ctx.shared().database().ensureFreeSpace(ctx.memoryPolicy());
                                        entry = entryEx(key);
                                        entry.unswap();
                                        EntryGetResult verVal = entry.versionedValue(cacheVal, res.version(), null, expiry, readerArgs);
                                        if (log.isDebugEnabled())
                                            log.debug("Set value loaded from store into entry [" + "oldVer=" + res.version() + ", newVer=" + verVal.version() + ", " + "entry=" + entry + ']');
                                        // Don't put key-value pair into result map if value is null.
                                        if (verVal.value() != null) {
                                            ctx.addResult(map, key, verVal, skipVals, keepCacheObjects, deserializeBinary, true, needVer);
                                        }
                                        if (tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED))
                                            ctx.evicts().touch(entry, topVer);
                                        break;
                                    } catch (GridCacheEntryRemovedException ignore) {
                                        if (log.isDebugEnabled())
                                            log.debug("Got removed entry during getAllAsync (will retry): " + entry);
                                    } catch (IgniteCheckedException e) {
                                        // Wrap errors (will be unwrapped).
                                        throw new GridClosureException(e);
                                    }
                                }
                            }
                        });
                        if (loaded.size() != loadKeys.size()) {
                            boolean needTouch = tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED);
                            for (Map.Entry<KeyCacheObject, EntryGetResult> e : loadKeys.entrySet()) {
                                if (loaded.contains(e.getKey()))
                                    continue;
                                if (needTouch || e.getValue().reserved()) {
                                    GridCacheEntryEx entry = peekEx(e.getKey());
                                    if (entry != null) {
                                        if (e.getValue().reserved())
                                            entry.clearReserveForLoad(e.getValue().version());
                                        if (needTouch)
                                            ctx.evicts().touch(entry, topVer);
                                    }
                                }
                            }
                        }
                        return map;
                    }
                }), true), new C2<Map<K, V>, Exception, IgniteInternalFuture<Map<K, V>>>() {

                    @Override
                    public IgniteInternalFuture<Map<K, V>> apply(Map<K, V> map, Exception e) {
                        if (e != null)
                            return new GridFinishedFuture<>(e);
                        if (tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED)) {
                            Collection<KeyCacheObject> notFound = new HashSet<>(loadKeys.keySet());
                            notFound.removeAll(loaded);
                            // Touch entries that were not found in store.
                            for (KeyCacheObject key : notFound) {
                                GridCacheEntryEx entry = peekEx(key);
                                if (entry != null)
                                    ctx.evicts().touch(entry, topVer);
                            }
                        }
                        // There were no misses.
                        return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
                    }
                }, new C2<Map<K1, V1>, Exception, Map<K1, V1>>() {

                    @Override
                    public Map<K1, V1> apply(Map<K1, V1> loaded, Exception e) {
                        if (e == null)
                            map.putAll(loaded);
                        return map;
                    }
                });
            } else
                // Misses can be non-zero only if store is enabled.
                assert misses == null;
            return new GridFinishedFuture<>(map);
        } catch (RuntimeException | AssertionError e) {
            if (misses != null) {
                for (KeyCacheObject key0 : misses.keySet()) ctx.evicts().touch(peekEx(key0), topVer);
            }
            return new GridFinishedFuture<>(e);
        } catch (IgniteCheckedException e) {
            return new GridFinishedFuture<>(e);
        }
    } else {
        return asyncOp(tx, new AsyncOp<Map<K1, V1>>(keys) {

            @Override
            public IgniteInternalFuture<Map<K1, V1>> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
                return tx.getAllAsync(ctx, readyTopVer, keys, deserializeBinary, skipVals, false, !readThrough, recovery, needVer);
            }
        }, ctx.operationContextPerCall(), /*retry*/
        false);
    }
}
Also used : IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) HashMap(java.util.HashMap) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) CI2(org.apache.ignite.internal.util.typedef.CI2) GridEmbeddedFuture(org.apache.ignite.internal.util.future.GridEmbeddedFuture) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridDhtTopologyFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture) GridCacheRawVersionedEntry(org.apache.ignite.internal.processors.cache.version.GridCacheRawVersionedEntry) CacheEntry(org.apache.ignite.cache.CacheEntry) DataStreamerEntry(org.apache.ignite.internal.processors.datastreamer.DataStreamerEntry) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteTxLocalAdapter(org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter) HashSet(java.util.HashSet) CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) IgniteTxRollbackCheckedException(org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException) InvalidObjectException(java.io.InvalidObjectException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) EntryProcessorException(javax.cache.processor.EntryProcessorException) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) IOException(java.io.IOException) ObjectStreamException(java.io.ObjectStreamException) IgniteException(org.apache.ignite.IgniteException) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) NoSuchElementException(java.util.NoSuchElementException) IgniteTxHeuristicCheckedException(org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) Collection(java.util.Collection) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with CacheDataRow

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

the class IgniteCacheOffheapManagerImpl method keysIterator.

/** {@inheritDoc} */
@Override
public GridCloseableIterator<KeyCacheObject> keysIterator(final int part) throws IgniteCheckedException {
    CacheDataStore data = partitionData(part);
    if (data == null)
        return new GridEmptyCloseableIterator<>();
    final GridCursor<? extends CacheDataRow> cur = data.cursor();
    return new GridCloseableIteratorAdapter<KeyCacheObject>() {

        /** */
        private KeyCacheObject next;

        @Override
        protected KeyCacheObject onNext() {
            KeyCacheObject res = next;
            next = null;
            return res;
        }

        @Override
        protected boolean onHasNext() throws IgniteCheckedException {
            if (next != null)
                return true;
            if (cur.next()) {
                CacheDataRow row = cur.get();
                next = row.key();
            }
            return next != null;
        }
    };
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridCloseableIteratorAdapter(org.apache.ignite.internal.util.GridCloseableIteratorAdapter)

Example 3 with CacheDataRow

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

the class IgniteCacheOffheapManagerImpl method rowsIterator.

/**
     * @param primary Primary entries flag.
     * @param backups Backup entries flag.
     * @param topVer Topology version.
     * @return Iterator.
     */
private GridIterator<CacheDataRow> rowsIterator(boolean primary, boolean backups, AffinityTopologyVersion topVer) {
    final Iterator<CacheDataStore> dataIt = cacheData(primary, backups, topVer);
    return new GridCloseableIteratorAdapter<CacheDataRow>() {

        /** */
        private GridCursor<? extends CacheDataRow> cur;

        /** */
        private int curPart;

        /** */
        private CacheDataRow next;

        @Override
        protected CacheDataRow onNext() {
            CacheDataRow res = next;
            next = null;
            return res;
        }

        @Override
        protected boolean onHasNext() throws IgniteCheckedException {
            if (next != null)
                return true;
            while (true) {
                if (cur == null) {
                    if (dataIt.hasNext()) {
                        CacheDataStore ds = dataIt.next();
                        curPart = ds.partId();
                        cur = ds.cursor();
                    } else
                        break;
                }
                if (cur.next()) {
                    next = cur.get();
                    next.key().partition(curPart);
                    break;
                } else
                    cur = null;
            }
            return next != null;
        }
    };
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridCursor(org.apache.ignite.internal.util.lang.GridCursor) GridCloseableIteratorAdapter(org.apache.ignite.internal.util.GridCloseableIteratorAdapter)

Example 4 with CacheDataRow

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

the class GridDhtColocatedCache method loadAsync.

/**
     * @param keys Keys to load.
     * @param readThrough Read through flag.
     * @param forcePrimary Force get from primary node flag.
     * @param topVer Topology version.
     * @param subjId Subject ID.
     * @param taskName Task name.
     * @param deserializeBinary Deserialize binary flag.
     * @param expiryPlc Expiry policy.
     * @param skipVals Skip values flag.
     * @param canRemap Flag indicating whether future can be remapped on a newer topology version.
     * @param needVer If {@code true} returns values as tuples containing value and version.
     * @param keepCacheObj Keep cache objects flag.
     * @return Load future.
     */
public final IgniteInternalFuture<Map<K, V>> loadAsync(@Nullable Collection<KeyCacheObject> keys, boolean readThrough, boolean forcePrimary, AffinityTopologyVersion topVer, @Nullable UUID subjId, String taskName, boolean deserializeBinary, boolean recovery, @Nullable IgniteCacheExpiryPolicy expiryPlc, boolean skipVals, boolean canRemap, boolean needVer, boolean keepCacheObj) {
    if (keys == null || keys.isEmpty())
        return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
    if (expiryPlc == null)
        expiryPlc = expiryPolicy(null);
    // Optimisation: try to resolve value locally and escape 'get future' creation.
    if (!forcePrimary && ctx.affinityNode()) {
        try {
            Map<K, V> locVals = null;
            boolean success = true;
            boolean readNoEntry = ctx.readNoEntry(expiryPlc, false);
            boolean evt = !skipVals;
            for (KeyCacheObject key : keys) {
                if (readNoEntry) {
                    CacheDataRow row = ctx.offheap().read(key);
                    if (row != null) {
                        long expireTime = row.expireTime();
                        if (expireTime == 0 || expireTime > U.currentTimeMillis()) {
                            if (locVals == null)
                                locVals = U.newHashMap(keys.size());
                            ctx.addResult(locVals, key, row.value(), skipVals, keepCacheObj, deserializeBinary, true, null, row.version(), 0, 0, needVer);
                            if (evt) {
                                ctx.events().readEvent(key, null, row.value(), subjId, taskName, !deserializeBinary);
                            }
                        } else
                            success = false;
                    } else
                        success = false;
                } else {
                    GridCacheEntryEx entry = null;
                    while (true) {
                        try {
                            entry = entryEx(key);
                            // If our DHT cache do has value, then we peek it.
                            if (entry != null) {
                                boolean isNew = entry.isNewLocked();
                                EntryGetResult getRes = null;
                                CacheObject v = null;
                                GridCacheVersion ver = null;
                                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);
                                }
                                // Entry was not in memory or in swap, so we remove it from cache.
                                if (v == null) {
                                    GridCacheVersion obsoleteVer = context().versions().next();
                                    if (isNew && entry.markObsoleteIfEmpty(obsoleteVer))
                                        removeEntry(entry);
                                    success = false;
                                } else {
                                    if (locVals == null)
                                        locVals = U.newHashMap(keys.size());
                                    ctx.addResult(locVals, key, v, skipVals, keepCacheObj, deserializeBinary, true, getRes, ver, 0, 0, needVer);
                                }
                            } else
                                success = false;
                            // While.
                            break;
                        } catch (GridCacheEntryRemovedException ignored) {
                        // No-op, retry.
                        } catch (GridDhtInvalidPartitionException ignored) {
                            success = false;
                            // While.
                            break;
                        } finally {
                            if (entry != null)
                                context().evicts().touch(entry, topVer);
                        }
                    }
                }
                if (!success)
                    break;
                else if (!skipVals && ctx.config().isStatisticsEnabled())
                    ctx.cache().metrics0().onRead(true);
            }
            if (success) {
                sendTtlUpdateRequest(expiryPlc);
                return new GridFinishedFuture<>(locVals);
            }
        } catch (IgniteCheckedException e) {
            return new GridFinishedFuture<>(e);
        }
    }
    if (expiryPlc != null)
        expiryPlc.reset();
    // Either reload or not all values are available locally.
    GridPartitionedGetFuture<K, V> fut = new GridPartitionedGetFuture<>(ctx, keys, topVer, readThrough, forcePrimary, subjId, taskName, deserializeBinary, recovery, expiryPlc, skipVals, canRemap, needVer, keepCacheObj);
    fut.init();
    return fut;
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) GridPartitionedGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) 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) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 5 with CacheDataRow

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

the class GridDhtAtomicCache method getAllAsync0.

/**
     * Entry point to all public API get methods.
     *
     * @param keys Keys.
     * @param forcePrimary Force primary flag.
     * @param subjId Subject ID.
     * @param taskName Task name.
     * @param deserializeBinary Deserialize binary flag.
     * @param expiryPlc Expiry policy.
     * @param skipVals Skip values flag.
     * @param skipStore Skip store flag.
     * @param needVer Need version.
     * @return Get future.
     */
private IgniteInternalFuture<Map<K, V>> getAllAsync0(@Nullable Collection<KeyCacheObject> keys, boolean forcePrimary, UUID subjId, String taskName, boolean deserializeBinary, boolean recovery, @Nullable ExpiryPolicy expiryPlc, boolean skipVals, boolean skipStore, boolean canRemap, boolean needVer) {
    AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() : ctx.shared().exchange().readyAffinityVersion();
    final IgniteCacheExpiryPolicy expiry = skipVals ? null : expiryPolicy(expiryPlc);
    final boolean evt = !skipVals;
    // Optimisation: try to resolve value locally and escape 'get future' creation.
    if (!forcePrimary && ctx.affinityNode()) {
        try {
            Map<K, V> locVals = U.newHashMap(keys.size());
            boolean success = true;
            boolean readNoEntry = ctx.readNoEntry(expiry, false);
            // Optimistically expect that all keys are available locally (avoid creation of get future).
            for (KeyCacheObject key : keys) {
                if (readNoEntry) {
                    CacheDataRow row = ctx.offheap().read(key);
                    if (row != null) {
                        long expireTime = row.expireTime();
                        if (expireTime == 0 || expireTime > U.currentTimeMillis()) {
                            ctx.addResult(locVals, key, row.value(), skipVals, false, deserializeBinary, true, null, row.version(), 0, 0, needVer);
                            if (evt) {
                                ctx.events().readEvent(key, null, row.value(), subjId, taskName, !deserializeBinary);
                            }
                        } else
                            success = false;
                    } else
                        success = false;
                } else {
                    GridCacheEntryEx entry = null;
                    while (true) {
                        try {
                            entry = entryEx(key);
                            // If our DHT cache do has value, then we peek it.
                            if (entry != null) {
                                boolean isNew = entry.isNewLocked();
                                EntryGetResult getRes = null;
                                CacheObject v = null;
                                GridCacheVersion ver = null;
                                if (needVer) {
                                    getRes = entry.innerGetVersioned(null, null, /*update-metrics*/
                                    false, /*event*/
                                    evt, subjId, null, taskName, expiry, true, 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, expiry, !deserializeBinary);
                                }
                                // Entry was not in memory or in swap, so we remove it from cache.
                                if (v == null) {
                                    if (isNew && entry.markObsoleteIfEmpty(context().versions().next()))
                                        removeEntry(entry);
                                    success = false;
                                } else {
                                    ctx.addResult(locVals, key, v, skipVals, false, deserializeBinary, true, getRes, ver, 0, 0, needVer);
                                }
                            } else
                                success = false;
                            // While.
                            break;
                        } catch (GridCacheEntryRemovedException ignored) {
                        // No-op, retry.
                        } catch (GridDhtInvalidPartitionException ignored) {
                            success = false;
                            // While.
                            break;
                        } finally {
                            if (entry != null)
                                ctx.evicts().touch(entry, topVer);
                        }
                    }
                }
                if (!success)
                    break;
                else if (!skipVals && ctx.config().isStatisticsEnabled())
                    metrics0().onRead(true);
            }
            if (success) {
                sendTtlUpdateRequest(expiry);
                return new GridFinishedFuture<>(locVals);
            }
        } catch (IgniteCheckedException e) {
            return new GridFinishedFuture<>(e);
        }
    }
    if (expiry != null)
        expiry.reset();
    // Either reload or not all values are available locally.
    GridPartitionedGetFuture<K, V> fut = new GridPartitionedGetFuture<>(ctx, keys, topVer, !skipStore, forcePrimary, subjId, taskName, deserializeBinary, recovery, expiry, skipVals, canRemap, needVer, false);
    fut.init();
    return fut;
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.database.CacheDataRow) GridDhtInvalidPartitionException(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException) GridPartitionedGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedGetFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) GridCacheEntryEx(org.apache.ignite.internal.processors.cache.GridCacheEntryEx) GridCacheVersion(org.apache.ignite.internal.processors.cache.version.GridCacheVersion) 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) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Aggregations

CacheDataRow (org.apache.ignite.internal.processors.cache.database.CacheDataRow)24 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)13 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)9 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)7 GridCacheEntryEx (org.apache.ignite.internal.processors.cache.GridCacheEntryEx)6 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)6 UUID (java.util.UUID)5 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)5 EntryGetResult (org.apache.ignite.internal.processors.cache.EntryGetResult)5 GridDhtLocalPartition (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition)5 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)4 GridDhtInvalidPartitionException (org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException)4 GridCloseableIteratorAdapter (org.apache.ignite.internal.util.GridCloseableIteratorAdapter)4 IgniteException (org.apache.ignite.IgniteException)3 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)3 GridFinishedFuture (org.apache.ignite.internal.util.future.GridFinishedFuture)3 NoSuchElementException (java.util.NoSuchElementException)2 EntryProcessor (javax.cache.processor.EntryProcessor)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 StorageException (org.apache.ignite.internal.pagemem.wal.StorageException)2