Search in sources :

Example 1 with GridPartitionedSingleGetFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture in project ignite by apache.

the class GridDhtAtomicCache method getAsync0.

/**
 * Entry point to all public API single get methods.
 *
 * @param key Key.
 * @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<V> getAsync0(KeyCacheObject key, boolean forcePrimary, UUID subjId, String taskName, boolean deserializeBinary, boolean recovery, @Nullable ExpiryPolicy expiryPlc, boolean skipVals, boolean skipStore, boolean needVer) {
    AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
    IgniteCacheExpiryPolicy expiry = skipVals ? null : expiryPolicy(expiryPlc);
    GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, key, topVer, !skipStore, forcePrimary, subjId, taskName, deserializeBinary, expiry, skipVals, needVer, false, recovery);
    fut.init();
    return (IgniteInternalFuture<V>) fut;
}
Also used : GridPartitionedSingleGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)

Example 2 with GridPartitionedSingleGetFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture in project ignite by apache.

the class GridDhtColocatedCache method getAsync.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteInternalFuture<V> getAsync(final K key, boolean forcePrimary, boolean skipTx, @Nullable UUID subjId, String taskName, final boolean deserializeBinary, final boolean skipVals, final boolean needVer) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    if (keyCheck)
        validateCacheKey(key);
    GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
    final CacheOperationContext opCtx = ctx.operationContextPerCall();
    final boolean recovery = opCtx != null && opCtx.recovery();
    if (tx != null && !tx.implicit() && !skipTx) {
        return asyncOp(tx, new AsyncOp<V>() {

            @Override
            public IgniteInternalFuture<V> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
                IgniteInternalFuture<Map<Object, Object>> fut = tx.getAllAsync(ctx, readyTopVer, Collections.singleton(ctx.toCacheKeyObject(key)), deserializeBinary, skipVals, false, opCtx != null && opCtx.skipStore(), recovery, needVer);
                return fut.chain(new CX1<IgniteInternalFuture<Map<Object, Object>>, V>() {

                    @SuppressWarnings("unchecked")
                    @Override
                    public V applyx(IgniteInternalFuture<Map<Object, Object>> e) throws IgniteCheckedException {
                        Map<Object, Object> map = e.get();
                        assert map.isEmpty() || map.size() == 1 : map.size();
                        if (skipVals) {
                            Boolean val = map.isEmpty() ? false : (Boolean) F.firstValue(map);
                            return (V) (val);
                        }
                        return (V) F.firstValue(map);
                    }
                });
            }
        }, opCtx, /*retry*/
        false);
    }
    AffinityTopologyVersion topVer = tx == null ? ctx.affinity().affinityTopologyVersion() : tx.topologyVersion();
    subjId = ctx.subjectIdPerCall(subjId, opCtx);
    GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, ctx.toCacheKeyObject(key), topVer, opCtx == null || !opCtx.skipStore(), forcePrimary, subjId, taskName, deserializeBinary, skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null), skipVals, needVer, /*keepCacheObjects*/
    false, opCtx != null && opCtx.recovery());
    fut.init();
    return (IgniteInternalFuture<V>) fut;
}
Also used : GridPartitionedSingleGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) CX1(org.apache.ignite.internal.util.typedef.CX1) Map(java.util.Map) GridCacheConcurrentMap(org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap)

Example 3 with GridPartitionedSingleGetFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture in project ignite by apache.

the class GridDhtColocatedCache method loadAsync.

/**
 * @param key Key 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 needVer If {@code true} returns values as tuples containing value and version.
 * @param keepCacheObj Keep cache objects flag.
 * @return Load future.
 */
public final IgniteInternalFuture<Object> loadAsync(KeyCacheObject key, boolean readThrough, boolean forcePrimary, AffinityTopologyVersion topVer, @Nullable UUID subjId, String taskName, boolean deserializeBinary, @Nullable IgniteCacheExpiryPolicy expiryPlc, boolean skipVals, boolean needVer, boolean keepCacheObj, boolean recovery) {
    GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, ctx.toCacheKeyObject(key), topVer, readThrough, forcePrimary, subjId, taskName, deserializeBinary, expiryPlc, skipVals, needVer, keepCacheObj, recovery);
    fut.init();
    return fut;
}
Also used : GridPartitionedSingleGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture)

Example 4 with GridPartitionedSingleGetFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture in project ignite by apache.

the class GridDhtColocatedCache method loadAsync.

/**
 * @param key Key to load.
 * @param readThrough Read through flag.
 * @param forcePrimary Force get from primary node flag.
 * @param topVer Topology version.
 * @param taskName Task name.
 * @param deserializeBinary Deserialize binary flag.
 * @param expiryPlc Expiry policy.
 * @param skipVals Skip values flag.
 * @param needVer If {@code true} returns values as tuples containing value and version.
 * @param keepCacheObj Keep cache objects flag.
 * @param txLbl Transaction label.
 * @return Load future.
 */
public final IgniteInternalFuture<Object> loadAsync(KeyCacheObject key, boolean readThrough, boolean forcePrimary, AffinityTopologyVersion topVer, String taskName, boolean deserializeBinary, @Nullable IgniteCacheExpiryPolicy expiryPlc, boolean skipVals, boolean needVer, boolean keepCacheObj, boolean recovery, @Nullable MvccSnapshot mvccSnapshot, @Nullable String txLbl) {
    GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, ctx.toCacheKeyObject(key), topVer, readThrough, forcePrimary, taskName, deserializeBinary, expiryPlc, skipVals, needVer, keepCacheObj, recovery, txLbl, mvccSnapshot);
    fut.init();
    return fut;
}
Also used : GridPartitionedSingleGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture)

Example 5 with GridPartitionedSingleGetFuture

use of org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture in project ignite by apache.

the class GridDhtAtomicCache method getAsync0.

/**
 * Entry point to all public API single get methods.
 *
 * @param key Key.
 * @param forcePrimary Force primary flag.
 * @param taskName Task name.
 * @param deserializeBinary Deserialize binary flag.
 * @param readRepairStrategy Read Repair strategy.
 * @param expiryPlc Expiry policy.
 * @param skipVals Skip values flag.
 * @param skipStore Skip store flag.
 * @param needVer Need version.
 * @return Get future.
 */
private IgniteInternalFuture<V> getAsync0(KeyCacheObject key, boolean forcePrimary, String taskName, boolean deserializeBinary, boolean recovery, ReadRepairStrategy readRepairStrategy, @Nullable ExpiryPolicy expiryPlc, boolean skipVals, boolean skipStore, boolean needVer) {
    AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
    IgniteCacheExpiryPolicy expiry = skipVals ? null : expiryPolicy(expiryPlc);
    if (readRepairStrategy != null) {
        return new GridNearReadRepairCheckOnlyFuture(ctx, Collections.singleton(ctx.toCacheKeyObject(key)), readRepairStrategy, !skipStore, taskName, deserializeBinary, recovery, expiry, skipVals, needVer, false, null).single();
    }
    GridPartitionedSingleGetFuture fut = new GridPartitionedSingleGetFuture(ctx, key, topVer, !skipStore, forcePrimary, taskName, deserializeBinary, expiry, skipVals, needVer, false, recovery, null, null);
    fut.init();
    return (IgniteInternalFuture<V>) fut;
}
Also used : GridNearReadRepairCheckOnlyFuture(org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture) GridPartitionedSingleGetFuture(org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)

Aggregations

GridPartitionedSingleGetFuture (org.apache.ignite.internal.processors.cache.distributed.dht.GridPartitionedSingleGetFuture)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)4 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)4 Map (java.util.Map)2 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)2 CacheOperationContext (org.apache.ignite.internal.processors.cache.CacheOperationContext)2 GridCacheConcurrentMap (org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap)2 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)2 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)2 GridNearTxLocal (org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal)2 GridNearReadRepairCheckOnlyFuture (org.apache.ignite.internal.processors.cache.distributed.near.consistency.GridNearReadRepairCheckOnlyFuture)2 CX1 (org.apache.ignite.internal.util.typedef.CX1)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 ReadRepairStrategy (org.apache.ignite.cache.ReadRepairStrategy)1 MvccQueryTracker (org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker)1 MvccSnapshot (org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot)1