/** * @return Key. */ public IgniteTxKey key() { GridCacheEntryEx parent0 = parent; if (parent0 == null) throw new IllegalStateException("Parent entry was not initialized for MVCC candidate: " + this); return parent0.txKey(); }
/** {@inheritDoc} */ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) { if (log.isDebugEnabled()) log.debug("Transaction future received owner changed callback: " + entry); boolean rmv; synchronized (this) { rmv = lockKeys.remove(entry.txKey()); } return rmv && mapIfLocked(); }
/** * @param entry Entry. */ @SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter"}) void recheck(@Nullable GridCacheEntryEx entry) { if (entry == null) return; if (exchLog.isDebugEnabled()) exchLog.debug("Rechecking entry for completion [entry=" + entry + ", finFut=" + this + ']'); Collection<GridCacheMvccCandidate> cands = pendingLocks.get(entry.txKey()); if (cands != null) { synchronized (cands) { for (Iterator<GridCacheMvccCandidate> it = cands.iterator(); it.hasNext(); ) { GridCacheMvccCandidate cand = it.next(); // Check exclude ID again, as key could have been reassigned. if (cand.removed()) it.remove(); } if (cands.isEmpty()) pendingLocks.remove(entry.txKey()); if (pendingLocks.isEmpty()) { onDone(); if (exchLog.isDebugEnabled()) exchLog.debug("Finish lock future is done: " + this); } } } }
/** * @param nodeId Node ID. * @param entry Entry to remove. * @param map Map to remove from. * @return {@code True} if was removed. */ private boolean removeMapping(UUID nodeId, @Nullable GridCacheEntryEx entry, Map<UUID, GridDistributedTxMapping> map) { if (entry != null) { if (log.isDebugEnabled()) log.debug("Removing mapping for entry [nodeId=" + nodeId + ", entry=" + entry + ']'); IgniteTxEntry txEntry = entry(entry.txKey()); if (txEntry == null) return false; GridDistributedTxMapping m = map.get(nodeId); boolean ret = m != null && m.removeEntry(txEntry); if (m != null && m.empty()) map.remove(nodeId); return ret; } else return map.remove(nodeId) != null; }
/** {@inheritDoc} */ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) { if (log.isDebugEnabled()) log.debug("Transaction future received owner changed callback: " + entry); if (tx.remainingTime() == -1) return false; if ((entry.context().isNear() || entry.context().isLocal()) && owner != null && tx.hasWriteKey(entry.txKey())) { if (keyLockFut != null) keyLockFut.onKeyLocked(entry.txKey()); return true; } return false; }
/** * @param topVer Topology version. * @param entries Entries. */ FinishLockFuture(Iterable<GridDistributedCacheEntry> entries, AffinityTopologyVersion topVer) { assert topVer.compareTo(AffinityTopologyVersion.ZERO) > 0; this.topVer = topVer; for (GridCacheEntryEx entry : entries) { // Either local or near local candidates. try { Collection<GridCacheMvccCandidate> locs = entry.localCandidates(); if (!F.isEmpty(locs)) { Collection<GridCacheMvccCandidate> cands = new ConcurrentLinkedQueue<>(); cands.addAll(F.view(locs, versionFilter())); if (!F.isEmpty(cands)) pendingLocks.put(entry.txKey(), cands); } } catch (GridCacheEntryRemovedException ignored) { if (exchLog.isDebugEnabled()) exchLog.debug("Got removed entry when adding it to finish lock future (will ignore): " + entry); } } if (exchLog.isDebugEnabled()) exchLog.debug("Pending lock set [topVer=" + topVer + ", locks=" + pendingLocks + ']'); }
/** {@inheritDoc} */ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) { if (!hasWriteKey(entry.txKey())) return false; try { commitIfLocked(); return true; } catch (IgniteCheckedException e) { U.error(log, "Failed to commit remote transaction: " + this, e); invalidate(true); systemInvalidate(true); rollbackRemoteTx(); return false; } }
/** {@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); }
/** {@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 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()); }
/** * 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; } } } }
assert invokeArgs == null || op == TRANSFORM; IgniteTxKey key = entry.txKey();
IgniteTxEntry txEntry = entry(entry.txKey());
filterFailedKeys = new ArrayList<>(); filterFailedKeys.add(cached.txKey());
/** * @return Key. */ public IgniteTxKey key() { GridCacheEntryEx parent0 = parent; if (parent0 == null) throw new IllegalStateException("Parent entry was not initialized for MVCC candidate: " + this); return parent0.txKey(); }
/** {@inheritDoc} */ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) { if (log.isDebugEnabled()) log.debug("Transaction future received owner changed callback: " + entry); boolean rmv; synchronized (this) { rmv = lockKeys.remove(entry.txKey()); } return rmv && mapIfLocked(); }
/** {@inheritDoc} */ @Override public boolean onOwnerChanged(GridCacheEntryEx entry, GridCacheMvccCandidate owner) { if (log.isDebugEnabled()) log.debug("Transaction future received owner changed callback: " + entry); if (tx.remainingTime() == -1) return false; if ((entry.context().isNear() || entry.context().isLocal()) && owner != null && tx.hasWriteKey(entry.txKey())) { if (keyLockFut != null) keyLockFut.onKeyLocked(entry.txKey()); return true; } return false; }
/** {@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()); }