/** * @return Current transaction. */ private IgniteTxLocalAdapter currentTx() { return cctx.tm().localTx(); }
/** {@inheritDoc} */ @Override public int getTxXidMapSize() { return cctx.tm().idMapSize(); }
/** {@inheritDoc} */ @Override public int getTxThreadMapSize() { return cctx.tm().threadMapSize(); }
/** {@inheritDoc} */ @Override public int getTxDhtXidMapSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().idMapSize() : -1; }
/** {@inheritDoc} */ @Override public int getTxDhtCommittedVersionsSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().completedVersionsSize() : -1; }
/** {@inheritDoc} */ @Override public int getTxDhtRolledbackVersionsSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().completedVersionsSize() : -1; }
/** * Verifies there is no ongoing user transaction. * * @throws CacheException */ private void checkTx() throws CacheException { if (delegate.context().tm().inUserTx()) throw new CacheException("Explicit lock can't be acquired within a transaction."); }
/** * Checks that transaction manager for cache context does not have any pending transactions. * * @param ctx Cache context. */ private void checkTxsEmpty(GridCacheContext ctx) { Collection txs = ctx.tm().activeTransactions(); assert txs.isEmpty() : "Not all transactions were salvaged: " + txs; }
/** {@inheritDoc} */ @Nullable @Override public CacheObject peek() throws GridCacheEntryRemovedException, IgniteCheckedException { IgniteInternalTx tx = cctx.tm().localTx(); AffinityTopologyVersion topVer = tx != null ? tx.topologyVersion() : cctx.affinity().affinityTopologyVersion(); return peek(true, false, topVer, null); }
/** {@inheritDoc} */ @Override public IgniteInternalFuture<Boolean> lockAllAsync(Collection<? extends K> keys, long timeout) { IgniteTxLocalEx tx = ctx.tm().localTx(); return lockAllAsync(ctx.cacheKeysView(keys), timeout, tx, CU.empty0()); }
/** * Checks that transaction manager for cache context has expected number of pending transactions. * * @param ctx Cache context. * @param exp Expected amount of transactions. */ private void checkTxsNotEmpty(GridCacheContext ctx, int exp) { int size = ctx.tm().activeTransactions().size(); assertEquals("Some transactions were salvaged unexpectedly", exp, size); } }
/** * @param prev Previous. */ public void leaveNoLock(CacheOperationContext prev) { ctx.tm().resetContext(); ctx.mvcc().contextReset(); // Unwind eviction notifications. CU.unwindEvicts(ctx); // Return back previous thread local operation context per call. ctx.operationContextPerCall(prev); }
/** */ protected GridNearTxLocal checkCurrentTx() { if (!ctx.mvccEnabled()) return ctx.tm().threadLocalTx(ctx); try { return MvccUtils.currentTx(ctx.kernalContext(), null); } catch (MvccUtils.UnsupportedTxModeException | MvccUtils.NonMvccTransactionException e) { throw new TransactionException(e.getMessage()); } }
/** * Leave a cache call entered by {@link #enterNoLock} method. */ public void leaveNoLock() { ctx.tm().resetContext(); ctx.mvcc().contextReset(); // Unwind eviction notifications. if (!ctx.shared().closed(ctx)) CU.unwindEvicts(ctx); }
/** * @throws IgniteCheckedException If failed. */ private void proceedMapping() throws IgniteCheckedException { boolean set = tx != null && cctx.shared().tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { proceedMapping0(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }
/** * @throws IgniteCheckedException If failed. */ private void proceedMapping() throws IgniteCheckedException { boolean set = tx != null && cctx.shared().tm().setTxTopologyHint(tx.topologyVersionSnapshot()); try { proceedMapping0(); } finally { if (set) cctx.tm().setTxTopologyHint(null); } }
@Override public boolean apply() { for (IgniteKernal g : grids) { GridCacheAdapter<?, ?> cache = g.internalCache(DEFAULT_CACHE_NAME); IgniteTxManager txMgr = cache.isNear() ? ((GridNearCacheAdapter)cache).dht().context().tm() : cache.context().tm(); int txNum = txMgr.idMapSize(); if (txNum != 0) return false; } return true; } }, 10000);
@Override public boolean apply() { for (IgniteKernal g : grids) { GridCacheAdapter<?, ?> cache = g.internalCache(DEFAULT_CACHE_NAME); IgniteTxManager txMgr = cache.isNear() ? ((GridNearCacheAdapter)cache).dht().context().tm() : cache.context().tm(); int txNum = txMgr.idMapSize(); if (txNum != 0) return false; } return true; } }, 10000);
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { assertEquals(0, ((IgniteKernal)ignite).<String, Integer>internalCache(DEFAULT_CACHE_NAME).context().tm().idMapSize()); IgniteCache<Object, Object> cache = ignite.cache(DEFAULT_CACHE_NAME); ClusterNode node = ((IgniteKernal)ignite).localNode(); for (int k = 0; k < size; k++) { if (affinity(cache).isPrimaryOrBackup(node, k)) assertEquals("Check failed for node: " + node.id(), k, cache.localPeek(k, CachePeekMode.ONHEAP, CachePeekMode.OFFHEAP)); } } }