/** {@inheritDoc} */ @Override public <K1, V1> GridCacheProxyImpl<K1, V1> keepBinary() { if (opCtx != null && opCtx.isKeepBinary()) return (GridCacheProxyImpl<K1, V1>)this; return new GridCacheProxyImpl<>((GridCacheContext<K1, V1>)ctx, (GridCacheAdapter<K1, V1>)delegate, opCtx != null ? opCtx.keepBinary() : new CacheOperationContext(false, null, true, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX)); }
@Override public GridCacheVersion apply(K k) { return ctx.versions().next(opCtx.dataCenterId()); } });
/** {@inheritDoc} */ @Override public GridCacheProxyImpl<K, V> forSubjectId(UUID subjId) { return new GridCacheProxyImpl<>(ctx, delegate, opCtx != null ? opCtx.forSubjectId(subjId) : new CacheOperationContext(false, subjId, false, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX)); }
/** {@inheritDoc} */ @Override public GridCacheProxyImpl<K, V> setSkipStore(boolean skipStore) { CacheOperationContext prev = gate.enter(opCtx); try { if (opCtx != null && opCtx.skipStore() == skipStore) return this; return new GridCacheProxyImpl<>(ctx, delegate, opCtx != null ? opCtx.setSkipStore(skipStore) : new CacheOperationContext(true, null, false, null, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX)); } finally { gate.leave(prev); } }
if (opCtx != null && keys != null && opCtx.hasDataCenterId()) { assert conflictMap == null : conflictMap; retval, rawRetval, opCtx != null ? opCtx.expiry() : null, CU.filterArray(null), subjId, taskNameHash, opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary(), opCtx != null && opCtx.recovery(), opCtx != null && opCtx.noRetries() ? 1 : MAX_RETRIES);
/** * @return Operation context. */ public CacheOperationContext setAllowAtomicOpsInTx() { return new CacheOperationContext( skipStore, subjId, keepBinary, expiryPlc, noRetries, dataCenterId, recovery, true); }
/** * @return Keep binary flag. */ public boolean keepBinary() { CacheOperationContext opCtx = operationContextPerCall(); return opCtx != null && opCtx.isKeepBinary(); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) { A.notNull(keys, "keys"); final boolean statsEnabled = ctx.statisticsEnabled(); final long start = statsEnabled ? System.nanoTime() : 0L; String taskName = ctx.kernalContext().job().currentTaskName(); CacheOperationContext opCtx = ctx.operationContextPerCall(); IgniteInternalFuture<Map<K, V>> fut = getAllAsync( keys, !ctx.config().isReadFromBackup(), /*skip tx*/false, opCtx != null ? opCtx.subjectId() : null, taskName, !(opCtx != null && opCtx.isKeepBinary()), opCtx != null && opCtx.recovery(), /*skip vals*/false, /*need ver*/false); if (ctx.config().getInterceptor() != null) return fut.chain(new CX1<IgniteInternalFuture<Map<K, V>>, Map<K, V>>() { @Override public Map<K, V> applyx(IgniteInternalFuture<Map<K, V>> f) throws IgniteCheckedException { return interceptGet(keys, f.get()); } }); if (statsEnabled) fut.listen(new UpdateGetTimeStatClosure<Map<K, V>>(metrics0(), start)); return fut; }
/** * @param p Predicate. * @param args Arguments. * @return Load cache future. * @throws IgniteCheckedException If failed. */ IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args) throws IgniteCheckedException { ctx.kernalContext().task().setThreadContext(TC_NO_FAILOVER, true); CacheOperationContext opCtx = ctx.operationContextPerCall(); ExpiryPolicy plc = opCtx != null ? opCtx.expiry() : null; Collection<ClusterNode> nodes = ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).nodes(); assert !F.isEmpty(nodes) : "There are not datanodes fo cache: " + ctx.name(); //TODO IGNITE-7954 MvccUtils.verifyMvccOperationSupport(ctx, "Load"); final boolean keepBinary = opCtx != null && opCtx.isKeepBinary(); ComputeTaskInternalFuture fut = ctx.kernalContext().closure().callAsync(BROADCAST, Collections.singletonList( new LoadCacheJobV2<>(ctx.name(), ctx.affinity().affinityTopologyVersion(), p, args, plc, keepBinary)), nodes); return fut; }
/** {@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; }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<?> removeAllAsync() { GridFutureAdapter<Void> opFut = new GridFutureAdapter<>(); AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); CacheOperationContext opCtx = ctx.operationContextPerCall(); removeAllAsync(opFut, topVer, opCtx != null && opCtx.skipStore(), opCtx != null && opCtx.isKeepBinary()); return opFut; }
/** {@inheritDoc} */ @Override public GridCacheProxyImpl<K, V> withExpiryPolicy(ExpiryPolicy plc) { CacheOperationContext prev = gate.enter(opCtx); try { return new GridCacheProxyImpl<>(ctx, delegate, opCtx != null ? opCtx.withExpiryPolicy(plc) : new CacheOperationContext(false, null, false, plc, false, null, false, DFLT_ALLOW_ATOMIC_OPS_IN_TX)); } finally { gate.leave(prev); } }
/** {@inheritDoc} */ @Override public final IgniteInternalFuture<Map<K, V>> getAllOutTxAsync(Set<? extends K> keys) { String taskName = ctx.kernalContext().job().currentTaskName(); CacheOperationContext opCtx = ctx.operationContextPerCall(); return getAllAsync(keys, !ctx.config().isReadFromBackup(), /*skip tx*/true, null, taskName, !(opCtx != null && opCtx.isKeepBinary()), opCtx != null && opCtx.recovery(), /*skip values*/false, /*need ver*/false); }
/** {@inheritDoc} */ @Override public <K1, V1> GatewayProtectedCacheProxy<K1, V1> keepBinary() { CacheOperationGate opGate = onEnter(); try { return new GatewayProtectedCacheProxy<>((IgniteCacheProxy<K1, V1>) delegate, opCtx.keepBinary(), lock); } finally { onLeave(opGate); } }
/** {@inheritDoc} */ @Override public GatewayProtectedCacheProxy<K, V> withDataCenterId(byte dataCenterId) { CacheOperationGate opGate = onEnter(); try { Byte prevDataCenterId = opCtx.dataCenterId(); if (prevDataCenterId != null && dataCenterId == prevDataCenterId) return this; return new GatewayProtectedCacheProxy<>(delegate, opCtx.setDataCenterId(dataCenterId), lock); } finally { onLeave(opGate); } }
/** {@inheritDoc} */ @Override public GatewayProtectedCacheProxy<K, V> withNoRetries() { CacheOperationGate opGate = onEnter(); try { boolean noRetries = opCtx.noRetries(); if (noRetries) return this; return new GatewayProtectedCacheProxy<>(delegate, opCtx.setNoRetries(true), lock); } finally { onLeave(opGate); } }
/** {@inheritDoc} */ @Override public IgniteCache<K, V> withAllowAtomicOpsInTx() { if (context().atomic() && !opCtx.allowedAtomicOpsInTx() && context().tm().tx() != null) { throw new IllegalStateException("Enabling atomic operations during active transaction is not allowed. " + "Enable atomic operations before transaction start."); } CacheOperationGate opGate = onEnter(); try { boolean allowed = opCtx.allowedAtomicOpsInTx(); if (allowed) return this; return new GatewayProtectedCacheProxy<>(delegate, opCtx.setAllowAtomicOpsInTx(), lock); } finally { onLeave(opGate); } }
/** {@inheritDoc} */ @Override public PlatformTarget processOutObject(int type) throws IgniteCheckedException { switch (type) { case OP_WITH_PARTITION_RECOVER: { return copy(rawCache.withPartitionRecover(), keepBinary); } case OP_WITH_KEEP_BINARY: { if (keepBinary) return this; return copy(rawCache.withKeepBinary(), true); } case OP_WITH_NO_RETRIES: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.noRetries()) return this; return copy(rawCache.withNoRetries(), keepBinary); } case OP_WITH_SKIP_STORE: { CacheOperationContext opCtx = cache.context().operationContextPerCall(); if (opCtx != null && opCtx.skipStore()) return this; return copy(rawCache.withSkipStore(), keepBinary); } case OP_ITERATOR: { Iterator<Cache.Entry> iter = cache.iterator(); return new PlatformCacheIterator(platformCtx, iter); } } return super.processOutObject(type); }