/** {@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); } }
/** * Checks if this operation is available to be used in transaction. * * @throws IgniteException - in case of atomic operation inside transaction without permission. */ private void checkAtomicOpsInTx(CacheOperationContext opCtx) throws IgniteException { if (ctx.atomic() && !opCtx.allowedAtomicOpsInTx()) { if (ctx.grid().transactions().tx() != null) { throw new IgniteException("Transaction spans operations on atomic cache " + "(don't use atomic cache inside transaction or set up flag by cache.allowedAtomicOpsInTx())."); } } } }
/** {@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); } }
/** * Checks if this operation is available to be used in transaction. * * @throws IgniteException - in case of atomic operation inside transaction without permission. */ private void checkAtomicOpsInTx(CacheOperationContext opCtx) throws IgniteException { if (ctx.atomic() && !opCtx.allowedAtomicOpsInTx()) { if (ctx.grid().transactions().tx() != null) { throw new IgniteException("Transaction spans operations on atomic cache " + "(don't use atomic cache inside transaction or set up flag by cache.allowedAtomicOpsInTx())."); } } } }