/** {@inheritDoc} */ @Override public void userRollback(boolean clearThreadMap) throws IgniteCheckedException { TransactionState state = state(); if (state != ROLLING_BACK && state != ROLLED_BACK) { setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for rollback [state=" + state + ", tx=" + this + ']'); } if (near()) { // Must evict near entries before rolling back from // transaction manager, so they will be removed from cache. for (IgniteTxEntry e : allEntries()) evictNearEntry(e, false); } if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) { cctx.tm().rollbackTx(this, clearThreadMap, skipCompletedVersions()); cctx.mvccCaching().onTxFinished(this, false); if (!internal()) { Collection<CacheStoreManager> stores = txState.stores(cctx); if (stores != null && !stores.isEmpty()) { assert isWriteToStoreFromDhtValid(stores) : "isWriteToStoreFromDht can't be different within one transaction"; boolean isWriteToStoreFromDht = F.first(stores).isWriteToStoreFromDht(); if (!stores.isEmpty() && (near() || isWriteToStoreFromDht)) sessionEnd(stores, false); } } } }
/** * @param entries Entries to lock or {@code null} if use default {@link IgniteInternalTx#optimisticLockEntries()}. * @throws IgniteCheckedException If prepare step failed. */ public void userPrepare(@Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException { if (state() != PREPARING) { if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); TransactionState state = state(); setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']'); } checkValid(); try { cctx.tm().prepareTx(this, entries); calculatePartitionUpdateCounters(); } catch (IgniteCheckedException e) { throw e; } catch (Throwable e) { setRollbackOnly(); if (e instanceof Error) throw e; throw new IgniteCheckedException("Transaction validation produced a runtime exception: " + this, e); } }
TransactionState state = state(); if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); setRollbackOnly(); checkValid(); Collection<IgniteTxEntry> commitEntries = (near() || cctx.snapshot().needTxReadLogging()) ? allEntries() : writeEntries(); boolean empty = F.isEmpty(commitEntries) && !queryEnlisted(); if (!empty || colocated()) cctx.tm().addCommittedTx(this); batchStoreCommit(writeEntries()); AffinityTopologyVersion topVer = topologyVersion(); if (!evictNearEntry(txEntry, false)) { if (cacheCtx.isNear() && cacheCtx.dr().receiveEnabled()) { cached.markObsolete(xidVer); boolean updateNearCache = updateNearCache(cacheCtx, txEntry.key(), topVer); boolean evt = !isNearLocallyMapped(txEntry, false); IgniteBiTuple<GridCacheOperation, CacheObject> res = applyTransformClosures(txEntry,
) throws IgniteCheckedException { for (KeyCacheObject k : keys) { IgniteTxEntry txEntry = entry(cacheCtx.txKey(k)); assert cached.detached() || cached.lockedByThread(threadId) || isRollbackOnly() : "Transaction lock is not acquired [entry=" + cached + ", tx=" + this + ", nodeId=" + cctx.localNodeId() + ", threadId=" + threadId + ']'; boolean hasPrevVal = txEntry.hasPreviousValue(); if (onePhaseCommit()) filter = txEntry.filters(); /*event*/!invoke && !dht(), CU.subjectId(this, cctx), null, resolveTaskName(), null, txEntry.keepBinary()); assert optimistic() : txEntry; addInvokeResult(txEntry, v, ret, ver); if (onePhaseCommit()) txEntry.filtersPassed(pass); txEntry.cached(entryEx(cached.context(), txEntry.txKey(), topologyVersion()));
checkInternal(key); IgniteTxEntry old = entry(key); assert drExpireTime >= 0L; entryTtlDr(key, drTtl, drExpireTime); entryExpiry(key, expiryPlc); updateExplicitVersion(txEntry, entry); log.debug("Got removed entry in transaction newEntry method (will retry): " + entry); entry = entryEx(entry.context(), txEntry.txKey(), topologyVersion());
/** * Checks transaction expiration. * * @throws IgniteCheckedException If transaction check failed. */ protected void checkValid() throws IgniteCheckedException { checkValid(true); }
/** {@inheritDoc} */ @Override public String toString() { return GridToStringBuilder.toString(IgniteTxLocalAdapter.class, this, "super", super.toString(), "size", allEntries().size()); }
TransactionState state = state(); if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); setRollbackOnly(); checkValid(); Collection<IgniteTxEntry> commitEntries = (near() || cctx.snapshot().needTxReadLogging()) ? allEntries() : writeEntries(); boolean empty = F.isEmpty(commitEntries) && !queryEnlisted(); if (!empty || colocated()) cctx.tm().addCommittedTx(this); batchStoreCommit(writeEntries()); AffinityTopologyVersion topVer = topologyVersion(); if (!evictNearEntry(txEntry, false)) { if (cacheCtx.isNear() && cacheCtx.dr().receiveEnabled()) { cached.markObsolete(xidVer); boolean updateNearCache = updateNearCache(cacheCtx, txEntry.key(), topVer); boolean evt = !isNearLocallyMapped(txEntry, false); IgniteBiTuple<GridCacheOperation, CacheObject> res = applyTransformClosures(txEntry,
) throws IgniteCheckedException { for (KeyCacheObject k : keys) { IgniteTxEntry txEntry = entry(cacheCtx.txKey(k)); assert cached.detached() || cached.lockedByThread(threadId) || isRollbackOnly() : "Transaction lock is not acquired [entry=" + cached + ", tx=" + this + ", nodeId=" + cctx.localNodeId() + ", threadId=" + threadId + ']'; boolean hasPrevVal = txEntry.hasPreviousValue(); if (onePhaseCommit()) filter = txEntry.filters(); /*event*/!invoke && !dht(), CU.subjectId(this, cctx), null, resolveTaskName(), null, txEntry.keepBinary(), assert optimistic() : txEntry; addInvokeResult(txEntry, v, ret, ver); if (onePhaseCommit()) txEntry.filtersPassed(pass); txEntry.cached(entryEx(cached.context(), txEntry.txKey(), topologyVersion()));
checkInternal(key); IgniteTxEntry old = entry(key); assert drExpireTime >= 0L; entryTtlDr(key, drTtl, drExpireTime); entryExpiry(key, expiryPlc); updateExplicitVersion(txEntry, entry); log.debug("Got removed entry in transaction newEntry method (will retry): " + entry); entry = entryEx(entry.context(), txEntry.txKey(), topologyVersion());
/** * Checks transaction expiration. * * @throws IgniteCheckedException If transaction check failed. */ protected void checkValid() throws IgniteCheckedException { checkValid(true); }
/** {@inheritDoc} */ @Override public String toString() { return GridToStringBuilder.toString(IgniteTxLocalAdapter.class, this, "super", super.toString(), "size", allEntries().size()); }
/** {@inheritDoc} */ @Override public void userRollback(boolean clearThreadMap) throws IgniteCheckedException { TransactionState state = state(); if (state != ROLLING_BACK && state != ROLLED_BACK) { setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for rollback [state=" + state + ", tx=" + this + ']'); } if (near()) { // Must evict near entries before rolling back from // transaction manager, so they will be removed from cache. for (IgniteTxEntry e : allEntries()) evictNearEntry(e, false); } if (DONE_FLAG_UPD.compareAndSet(this, 0, 1)) { cctx.tm().rollbackTx(this, clearThreadMap, forceSkipCompletedVers); cctx.mvccCaching().onTxFinished(this, false); if (!internal()) { Collection<CacheStoreManager> stores = txState.stores(cctx); if (stores != null && !stores.isEmpty()) { assert isWriteToStoreFromDhtValid(stores) : "isWriteToStoreFromDht can't be different within one transaction"; boolean isWriteToStoreFromDht = F.first(stores).isWriteToStoreFromDht(); if (!stores.isEmpty() && (near() || isWriteToStoreFromDht)) sessionEnd(stores, false); } } } }
/** * @param entries Entries to lock or {@code null} if use default {@link IgniteInternalTx#optimisticLockEntries()}. * @throws IgniteCheckedException If prepare step failed. */ @SuppressWarnings({"CatchGenericClass"}) public void userPrepare(@Nullable Collection<IgniteTxEntry> entries) throws IgniteCheckedException { if (state() != PREPARING) { if (remainingTime() == -1) throw new IgniteTxTimeoutCheckedException("Transaction timed out: " + this); TransactionState state = state(); setRollbackOnly(); throw new IgniteCheckedException("Invalid transaction state for prepare [state=" + state + ", tx=" + this + ']'); } checkValid(); try { cctx.tm().prepareTx(this, entries); calculatePartitionUpdateCounters(); } catch (IgniteCheckedException e) { throw e; } catch (Throwable e) { setRollbackOnly(); if (e instanceof Error) throw e; throw new IgniteCheckedException("Transaction validation produced a runtime exception: " + this, e); } }