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);
}
});
}
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;
}
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;
}
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);
}
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);
}
Aggregations