Search in sources :

Example 71 with CacheOperationContext

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

the class GridNearTransactionalCache method lockAllAsync.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteInternalFuture<Boolean> lockAllAsync(Collection<KeyCacheObject> keys, long timeout, IgniteTxLocalEx tx, boolean isInvalidate, boolean isRead, boolean retval, TransactionIsolation isolation, long createTtl, long accessTtl) {
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    GridNearLockFuture fut = new GridNearLockFuture(ctx, keys, (GridNearTxLocal) tx, isRead, retval, timeout, createTtl, accessTtl, CU.empty0(), opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary(), opCtx != null && opCtx.recovery());
    fut.map();
    return fut;
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext)

Example 72 with CacheOperationContext

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

the class GridNearTransactionalCache method getAllAsync.

/**
 * {@inheritDoc}
 */
@Override
public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, @Nullable UUID subjId, String taskName, final boolean deserializeBinary, final boolean recovery, final boolean skipVals, final boolean needVer) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    if (F.isEmpty(keys))
        return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
    warnIfUnordered(keys, BulkOperation.GET);
    GridNearTxLocal tx = ctx.tm().threadLocalTx(ctx);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final boolean skipStore = opCtx != null && opCtx.skipStore();
    if (tx != null && !tx.implicit() && !skipTx) {
        return asyncOp(tx, new AsyncOp<Map<K, V>>(keys) {

            @Override
            public IgniteInternalFuture<Map<K, V>> op(GridNearTxLocal tx, AffinityTopologyVersion readyTopVer) {
                return tx.getAllAsync(ctx, readyTopVer, ctx.cacheKeysView(keys), deserializeBinary, skipVals, false, skipStore, recovery, needVer);
            }
        }, opCtx, /*retry*/
        false);
    }
    subjId = ctx.subjectIdPerCall(subjId, opCtx);
    return loadAsync(null, ctx.cacheKeysView(keys), forcePrimary, subjId, taskName, deserializeBinary, recovery, skipVals ? null : opCtx != null ? opCtx.expiry() : null, skipVals, skipStore, needVer);
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Map(java.util.Map)

Example 73 with CacheOperationContext

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

the class GridNearTxLocal method updateAsync.

/**
 * Executes key-value update operation in Mvcc mode.
 *
 * @param cacheCtx Cache context.
 * @param it Entries iterator.
 * @param retval Return value flag.
 * @param filter Filter.
 * @param timeout Timeout.
 * @param sequential Sequential locking flag.
 * @return Operation future.
 */
private IgniteInternalFuture<GridCacheReturn> updateAsync(GridCacheContext cacheCtx, UpdateSourceIterator<?> it, boolean retval, @Nullable CacheEntryPredicate filter, long timeout, boolean sequential) {
    try {
        final CacheOperationContext opCtx = cacheCtx.operationContextPerCall();
        final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
        /* TODO: IGNITE-9688: 'sequential' is always true here which can slowdown bulk operations,
             but possibly we can safely optimize this. */
        GridNearTxEnlistFuture fut = new GridNearTxEnlistFuture(cacheCtx, this, timeout, it, 0, sequential, filter, retval, keepBinary);
        fut.init();
        return nonInterruptable(new GridEmbeddedFuture<>(fut.chain(new CX1<IgniteInternalFuture<GridCacheReturn>, Boolean>() {

            @Override
            public Boolean applyx(IgniteInternalFuture<GridCacheReturn> fut0) throws IgniteCheckedException {
                fut0.get();
                return true;
            }
        }), new PLC1<GridCacheReturn>(null) {

            @Override
            protected GridCacheReturn postLock(GridCacheReturn ret) throws IgniteCheckedException {
                GridCacheReturn futRes = fut.get();
                assert futRes != null;
                mvccSnapshot.incrementOperationCounter();
                Object val = futRes.value();
                if (futRes.invokeResult() && val != null) {
                    assert val instanceof Map;
                    val = cacheCtx.unwrapInvokeResult((Map) val, keepBinary);
                }
                return new GridCacheReturn(cacheCtx, true, keepBinary, U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId), val, futRes.success());
            }
        }));
    } catch (RuntimeException e) {
        onException();
        throw e;
    }
}
Also used : GridCacheReturn(org.apache.ignite.internal.processors.cache.GridCacheReturn) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) GridTimeoutObject(org.apache.ignite.internal.processors.timeout.GridTimeoutObject) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) GridLeanMap(org.apache.ignite.internal.util.GridLeanMap)

Example 74 with CacheOperationContext

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

the class GridDhtAtomicCache method getAsync.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteInternalFuture<V> getAsync(final K key, final boolean skipTx, @Nullable UUID subjId, final String taskName, final boolean deserializeBinary, final boolean skipVals, final boolean needVer) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    subjId = ctx.subjectIdPerCall(null, opCtx);
    final UUID subjId0 = subjId;
    final ExpiryPolicy expiryPlc = skipVals ? null : opCtx != null ? opCtx.expiry() : null;
    final boolean skipStore = opCtx != null && opCtx.skipStore();
    final boolean recovery = opCtx != null && opCtx.recovery();
    return asyncOp(new CO<IgniteInternalFuture<V>>() {

        @Override
        public IgniteInternalFuture<V> apply() {
            return getAsync0(ctx.toCacheKeyObject(key), false, subjId0, taskName, deserializeBinary, recovery, expiryPlc, skipVals, skipStore, needVer);
        }
    });
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Example 75 with CacheOperationContext

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

the class GridDhtAtomicCache method invoke0.

/**
 * @param async Async operation flag.
 * @param key Key.
 * @param entryProcessor Entry processor.
 * @param args Entry processor arguments.
 * @return Future.
 */
private <T> IgniteInternalFuture<EntryProcessorResult<T>> invoke0(boolean async, K key, EntryProcessor<K, V, T> entryProcessor, Object... args) {
    A.notNull(key, "key", entryProcessor, "entryProcessor");
    final boolean statsEnabled = ctx.statisticsEnabled();
    final long start = statsEnabled ? System.nanoTime() : 0L;
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
    IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> fut = update0(key, null, entryProcessor, args, false, null, async);
    return fut.chain(new CX1<IgniteInternalFuture<Map<K, EntryProcessorResult<T>>>, EntryProcessorResult<T>>() {

        @Override
        public EntryProcessorResult<T> applyx(IgniteInternalFuture<Map<K, EntryProcessorResult<T>>> fut) throws IgniteCheckedException {
            Map<K, EntryProcessorResult<T>> resMap = fut.get();
            if (statsEnabled)
                metrics0().addInvokeTimeNanos(System.nanoTime() - start);
            if (resMap != null) {
                assert resMap.isEmpty() || resMap.size() == 1 : resMap.size();
                EntryProcessorResult<T> res = resMap.isEmpty() ? new CacheInvokeResult<>() : resMap.values().iterator().next();
                if (res instanceof CacheInvokeResult) {
                    CacheInvokeResult invokeRes = (CacheInvokeResult) res;
                    if (invokeRes.result() != null)
                        res = CacheInvokeResult.fromResult((T) ctx.unwrapBinaryIfNeeded(invokeRes.result(), keepBinary, false, null));
                }
                return res;
            }
            return new CacheInvokeResult<>();
        }
    });
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) CacheInvokeResult(org.apache.ignite.internal.processors.cache.CacheInvokeResult) EntryProcessorResult(javax.cache.processor.EntryProcessorResult) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IGNITE_ATOMIC_DEFERRED_ACK_TIMEOUT(org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_DEFERRED_ACK_TIMEOUT) EVT_CACHE_OBJECT_PUT(org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT) CACHE_API_NEAR_PROCESS_ATOMIC_UPDATE_REQUEST(org.apache.ignite.internal.processors.tracing.SpanType.CACHE_API_NEAR_PROCESS_ATOMIC_UPDATE_REQUEST) CACHE_API_DHT_PROCESS_ATOMIC_UPDATE_REQUEST(org.apache.ignite.internal.processors.tracing.SpanType.CACHE_API_DHT_PROCESS_ATOMIC_UPDATE_REQUEST) CACHE_API_PROCESS_CHECK_UPDATE_REQUEST(org.apache.ignite.internal.processors.tracing.SpanType.CACHE_API_PROCESS_CHECK_UPDATE_REQUEST) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) GridCacheConcurrentMap(org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap) HashMap(java.util.HashMap)

Aggregations

CacheOperationContext (org.apache.ignite.internal.processors.cache.CacheOperationContext)86 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)33 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)29 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)29 Map (java.util.Map)27 IgniteCacheExpiryPolicy (org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy)23 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)21 ExpiryPolicy (javax.cache.expiry.ExpiryPolicy)20 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)18 LinkedHashMap (java.util.LinkedHashMap)17 GridCacheEntryRemovedException (org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException)17 HashMap (java.util.HashMap)13 GridCacheVersion (org.apache.ignite.internal.processors.cache.version.GridCacheVersion)13 GridCacheConcurrentMap (org.apache.ignite.internal.processors.cache.GridCacheConcurrentMap)12 ArrayList (java.util.ArrayList)11 CacheException (javax.cache.CacheException)11 NodeStoppingException (org.apache.ignite.internal.NodeStoppingException)11 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)11 IgniteTxRollbackCheckedException (org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException)11 IgniteTxTimeoutCheckedException (org.apache.ignite.internal.transactions.IgniteTxTimeoutCheckedException)11