Search in sources :

Example 56 with CacheOperationContext

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

the class GridLocalAtomicCache method updateAllAsync0.

/**
 * Entry point for public API update methods.
 *
 * @param map Put map. Either {@code map} or {@code invokeMap} should be passed.
 * @param invokeMap Transform map. Either {@code map} or {@code invokeMap} should be passed.
 * @param invokeArgs Optional arguments for EntryProcessor.
 * @param retval Return value required flag.
 * @param rawRetval Return {@code GridCacheReturn} instance.
 * @param filter Cache entry filter for atomic updates.
 * @return Completion future.
 */
private IgniteInternalFuture updateAllAsync0(@Nullable final Map<? extends K, ? extends V> map, @Nullable final Map<? extends K, ? extends EntryProcessor> invokeMap, @Nullable final Object[] invokeArgs, final boolean retval, final boolean rawRetval, @Nullable final CacheEntryPredicate filter) {
    final GridCacheOperation op = invokeMap != null ? TRANSFORM : UPDATE;
    final Collection<? extends K> keys = map != null ? map.keySet() : invokeMap != null ? invokeMap.keySet() : null;
    final Collection<?> vals = map != null ? map.values() : invokeMap != null ? invokeMap.values() : null;
    final boolean writeThrough = ctx.writeThrough();
    final boolean readThrough = ctx.readThrough();
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final ExpiryPolicy expiry = expiryPerCall();
    final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
    return asyncOp(new GridPlainCallable<Object>() {

        @Override
        public Object call() throws Exception {
            return updateAllInternal(op, keys, vals, invokeArgs, expiry, retval, rawRetval, filter, writeThrough, readThrough, keepBinary);
        }
    });
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) IgniteCacheExpiryPolicy(org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy) ExpiryPolicy(javax.cache.expiry.ExpiryPolicy) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) GridCacheOperation(org.apache.ignite.internal.processors.cache.GridCacheOperation) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridCacheEntryRemovedException(org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException) CachePartialUpdateCheckedException(org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException) EntryProcessorException(javax.cache.processor.EntryProcessorException) CacheStorePartialUpdateException(org.apache.ignite.internal.processors.cache.CacheStorePartialUpdateException)

Example 57 with CacheOperationContext

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

the class GridLocalAtomicCache method invokeAll.

/**
 * {@inheritDoc}
 */
@Override
public <T> Map<K, EntryProcessorResult<T>> invokeAll(Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor, Object... args) throws IgniteCheckedException {
    A.notNull(keys, "keys", entryProcessor, "entryProcessor");
    warnIfUnordered(keys, BulkOperation.INVOKE);
    final boolean statsEnabled = ctx.statisticsEnabled();
    final long start = statsEnabled ? System.nanoTime() : 0L;
    Map<? extends K, EntryProcessor> invokeMap = F.viewAsMap(keys, new C1<K, EntryProcessor>() {

        @Override
        public EntryProcessor apply(K k) {
            return entryProcessor;
        }
    });
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    final boolean keepBinary = opCtx != null && opCtx.isKeepBinary();
    Map<K, EntryProcessorResult<T>> entryProcessorRes = (Map<K, EntryProcessorResult<T>>) updateAllInternal(TRANSFORM, invokeMap.keySet(), invokeMap.values(), args, expiryPerCall(), false, false, null, ctx.writeThrough(), ctx.readThrough(), keepBinary);
    if (statsEnabled)
        metrics0().addInvokeTimeNanos(System.nanoTime() - start);
    return entryProcessorRes;
}
Also used : EntryProcessor(javax.cache.processor.EntryProcessor) EntryProcessorResult(javax.cache.processor.EntryProcessorResult) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 58 with CacheOperationContext

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

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 59 with CacheOperationContext

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

the class GridNearTransactionalCache method getAllAsync.

/**
 * {@inheritDoc}
 */
@Override
public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, String taskName, final boolean deserializeBinary, final boolean recovery, final ReadRepairStrategy readRepairStrategy, 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, readRepairStrategy, needVer);
            }
        }, opCtx, /*retry*/
        false);
    }
    return loadAsync(null, ctx.cacheKeysView(keys), forcePrimary, 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 60 with CacheOperationContext

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

the class GridNearAtomicCache method getAllAsync.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys, boolean forcePrimary, boolean skipTx, String taskName, boolean deserializeBinary, boolean recovery, ReadRepairStrategy readRepairStrategy, boolean skipVals, boolean needVer) {
    ctx.checkSecurity(SecurityPermission.CACHE_READ);
    if (F.isEmpty(keys))
        return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
    warnIfUnordered(keys, BulkOperation.GET);
    CacheOperationContext opCtx = ctx.operationContextPerCall();
    return loadAsync(null, ctx.cacheKeysView(keys), forcePrimary, taskName, deserializeBinary, recovery, skipVals ? null : opCtx != null ? opCtx.expiry() : null, skipVals, opCtx != null && opCtx.skipStore(), needVer);
}
Also used : CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext)

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