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