/** * Adds explicit version if there is one. * * @param e Transaction entry. */ protected void addExplicit(IgniteTxEntry e) { if (e.explicitVersion() != null) { if (explicitVers == null) explicitVers = new LinkedList<>(); if (!explicitVers.contains(e.explicitVersion())) { explicitVers.add(e.explicitVersion()); if (log.isDebugEnabled()) log.debug("Added explicit version to transaction [explicitVer=" + e.explicitVersion() + ", tx=" + this + ']'); // Register alternate version with TM. cctx.tm().addAlternateVersion(e.explicitVersion(), this); } } }
GridCacheVersion doneVer = txEntry.explicitVersion() != null ? txEntry.explicitVersion() : xidVer;
if (tx.optimistic() && txEntry.explicitVersion() == null) { synchronized (this) { lockKeys.add(txEntry.txKey()); assert txEntry.explicitVersion() == null || entry.lockedBy(txEntry.explicitVersion());
/** {@inheritDoc} */ @Override public boolean ownsLockUnsafe(GridCacheEntryEx entry) { GridCacheContext cacheCtx = entry.context(); IgniteTxEntry txEntry = entry(entry.txKey()); GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); return local() && !cacheCtx.isDht() ? entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) : // If candidate is not there, then lock was explicit. // Otherwise, check if entry is owned by version. !entry.hasLockCandidateUnsafe(xidVersion()) || entry.lockedByUnsafe(xidVersion()); }
/** {@inheritDoc} */ @Override public boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException { GridCacheContext<?, ?> cacheCtx = entry.context(); IgniteTxEntry txEntry = entry(entry.txKey()); GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); return local() && !cacheCtx.isDht() ? entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) : // If candidate is not there, then lock was explicit. // Otherwise, check if entry is owned by version. !entry.hasLockCandidate(xidVersion()) || entry.lockedBy(xidVersion()); }
/** {@inheritDoc} */ @Override protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry) throws GridCacheEntryRemovedException { if (entry.detached()) { GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId(), entry.txKey()); if (cand != null && !xidVersion().equals(cand.version())) { GridCacheVersion candVer = cand.version(); txEntry.explicitVersion(candVer); if (candVer.compareTo(minVer) < 0) minVer = candVer; } } else super.updateExplicitVersion(txEntry, entry); }
/** * Updates explicit version for tx entry based on current entry lock owner. * * @param txEntry Tx entry to update. * @param entry Entry. * @throws GridCacheEntryRemovedException If entry was concurrently removed. */ protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry) throws GridCacheEntryRemovedException { if (!entry.context().isDht()) { // All put operations must wait for async locks to complete, // so it is safe to get acquired locks. GridCacheMvccCandidate explicitCand = entry.localOwner(); if (explicitCand == null) explicitCand = cctx.mvcc().explicitLock(threadId(), entry.txKey()); if (explicitCand != null) { GridCacheVersion explicitVer = explicitCand.version(); boolean locCand = false; if (explicitCand.nearLocal() || explicitCand.local()) locCand = cctx.localNodeId().equals(explicitCand.nodeId()); else if (explicitCand.dhtLocal()) locCand = cctx.localNodeId().equals(explicitCand.otherNodeId()); if (!explicitVer.equals(xidVer) && explicitCand.threadId() == threadId && !explicitCand.tx() && locCand) { txEntry.explicitVersion(explicitVer); if (explicitVer.isLess(minVer)) minVer = explicitVer; } } } }
try { if (e.explicitVersion() != null && !e.explicitVersion().equals(xidVer)) { if (dhtEntryMap == null) dhtEntryMap = new GridLeanMap<>(); e.explicitVersion(), log, dhtEntryMap,
GridCacheVersion explicit = txEntry.explicitVersion();
GridCacheVersion explicit = existing.explicitVersion(); throw new IgniteCheckedException("Failed to find dht mapping for explicit entry version: " + existing); existing.explicitVersion(dhtVer);
if (entry.explicitVersion() == null && !remap) { if (keyLockFut == null) { keyLockFut = new KeyLockFuture(); if (entry.explicitVersion() != null) { tx.markExplicit(primary.id());
if (entry.explicitVersion() == null) { if (keyLockFut == null) { keyLockFut = new KeyLockFuture(); if (entry.explicitVersion() != null) { tx.markExplicit(primary.id());
for (IgniteTxEntry entry : nearWrites) { try { if (entry.explicitVersion() == null) { GridCacheMvccCandidate added = entry.cached().candidate(version()); if (CU.writes().apply(entry)) { try { if (entry.explicitVersion() == null) { GridCacheMvccCandidate added = entry.cached().candidate(version());
if (!txEntry1.markPrepared() || txEntry1.explicitVersion() != null) continue;
GridCacheVersion ver = txEntry.explicitVersion() != null ? txEntry.explicitVersion() : xidVer;
/** * Adds explicit version if there is one. * * @param e Transaction entry. */ protected void addExplicit(IgniteTxEntry e) { if (e.explicitVersion() != null) { if (explicitVers == null) explicitVers = new LinkedList<>(); if (!explicitVers.contains(e.explicitVersion())) { explicitVers.add(e.explicitVersion()); if (log.isDebugEnabled()) log.debug("Added explicit version to transaction [explicitVer=" + e.explicitVersion() + ", tx=" + this + ']'); // Register alternate version with TM. cctx.tm().addAlternateVersion(e.explicitVersion(), this); } } }
/** {@inheritDoc} */ @SuppressWarnings("SimplifiableIfStatement") @Override public boolean ownsLock(GridCacheEntryEx entry) throws GridCacheEntryRemovedException { GridCacheContext<?, ?> cacheCtx = entry.context(); IgniteTxEntry txEntry = entry(entry.txKey()); GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); return local() && !cacheCtx.isDht() ? entry.lockedByThread(threadId()) || (explicit != null && entry.lockedBy(explicit)) : // If candidate is not there, then lock was explicit. // Otherwise, check if entry is owned by version. !entry.hasLockCandidate(xidVersion()) || entry.lockedBy(xidVersion()); }
/** {@inheritDoc} */ @SuppressWarnings("SimplifiableIfStatement") @Override public boolean ownsLockUnsafe(GridCacheEntryEx entry) { GridCacheContext cacheCtx = entry.context(); IgniteTxEntry txEntry = entry(entry.txKey()); GridCacheVersion explicit = txEntry == null ? null : txEntry.explicitVersion(); return local() && !cacheCtx.isDht() ? entry.lockedByThreadUnsafe(threadId()) || (explicit != null && entry.lockedByUnsafe(explicit)) : // If candidate is not there, then lock was explicit. // Otherwise, check if entry is owned by version. !entry.hasLockCandidateUnsafe(xidVersion()) || entry.lockedByUnsafe(xidVersion()); }
/** {@inheritDoc} */ @Override protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry) throws GridCacheEntryRemovedException { if (entry.detached()) { GridCacheMvccCandidate cand = cctx.mvcc().explicitLock(threadId(), entry.txKey()); if (cand != null && !xidVersion().equals(cand.version())) { GridCacheVersion candVer = cand.version(); txEntry.explicitVersion(candVer); if (candVer.compareTo(minVer) < 0) minVer = candVer; } } else super.updateExplicitVersion(txEntry, entry); }
/** * Updates explicit version for tx entry based on current entry lock owner. * * @param txEntry Tx entry to update. * @param entry Entry. * @throws GridCacheEntryRemovedException If entry was concurrently removed. */ protected void updateExplicitVersion(IgniteTxEntry txEntry, GridCacheEntryEx entry) throws GridCacheEntryRemovedException { if (!entry.context().isDht()) { // All put operations must wait for async locks to complete, // so it is safe to get acquired locks. GridCacheMvccCandidate explicitCand = entry.localOwner(); if (explicitCand == null) explicitCand = cctx.mvcc().explicitLock(threadId(), entry.txKey()); if (explicitCand != null) { GridCacheVersion explicitVer = explicitCand.version(); boolean locCand = false; if (explicitCand.nearLocal() || explicitCand.local()) locCand = cctx.localNodeId().equals(explicitCand.nodeId()); else if (explicitCand.dhtLocal()) locCand = cctx.localNodeId().equals(explicitCand.otherNodeId()); if (!explicitVer.equals(xidVer) && explicitCand.threadId() == threadId && !explicitCand.tx() && locCand) { txEntry.explicitVersion(explicitVer); if (explicitVer.isLess(minVer)) minVer = explicitVer; } } } }