/** {@inheritDoc} */ @Override public IgnitePair<Long> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception { GridCacheAdapter<?, ?> internalCache = internalCache0(cache); if (internalCache.context().isNear()) internalCache = internalCache.context().near().dht(); GridCacheEntryEx entry = internalCache.entryEx(key); entry.unswap(); if (!entry.hasValue()) { assertEquals(0, entry.ttl()); assertEquals(0, entry.expireTime()); return null; } IgnitePair<Long> pair = new IgnitePair<>(entry.ttl(), entry.expireTime()); if (!entry.isNear()) entry.context().cache().removeEntry(entry); return pair; } }
/** * @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 + ']'); }
/** * @param entry Entry. * @return Value. */ @Nullable protected CacheObject peekVisibleValue(GridCacheEntryEx entry) { return locked ? entry.rawGet() : entry.peekVisibleValue(); }
/** {@inheritDoc} */ @Override public void onDeferredDelete(GridCacheEntryEx entry, GridCacheVersion ver) { assert entry.isDht(); GridDhtLocalPartition part = topology().localPartition(entry.partition(), AffinityTopologyVersion.NONE, false); if (part != null) part.onDeferredDelete(entry.context().cacheId(), entry.key(), ver); }
if (!entry.lockedBy(ver)) { if (log.isDebugEnabled()) log.debug("Transaction does not own lock for entry (will wait) [entry=" + entry + cached.markObsolete(xidVer); txEntry.cached().unswap(false); GridCacheVersion dhtVer = cached.isNear() ? writeVersion() : null; cached.innerRemove(this, eventNodeId(), nodeId, GridCacheUpdateTxResult updRes = cached.innerSet(this, eventNodeId(), nodeId, CacheObject val0 = cached.valueBytes(); cached.expireTime(), cached.ttl(), nodeId, topVer); GridCacheUpdateTxResult updRes = cached.innerRemove(this, eventNodeId(), nodeId,
cached.markObsolete(xidVer); if (cached.detached()) break; txEntry.cached().unswap(false); txEntry.cached().unswap(false); Duration duration = cached.hasValue() ? expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); Duration duration = cached.hasValue() ? expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); GridCacheUpdateTxResult updRes = cached.innerSet( this, eventNodeId(), topVer, null, cached.detached() ? DR_NONE : drType, txEntry.conflictExpireTime(), cached.isNear() ? null : explicitVer, CU.subjectId(this, cctx), resolveTaskName(), updateNearEntrySafely(cacheCtx, txEntry.key(), entry -> entry.innerSet( null,
/** {@inheritDoc} */ @Override public void batchEvict(Collection<?> keys, @Nullable GridCacheVersion obsoleteVer) throws IgniteCheckedException { boolean recordable = cctx.events().isRecordable(EVT_CACHE_ENTRY_EVICTED); GridCacheAdapter cache = cctx.cache(); // Get all participating entries to avoid deadlock. for (Object k : keys) { KeyCacheObject cacheKey = cctx.toCacheKeyObject(k); GridCacheEntryEx entry = cache.peekEx(cacheKey); if (entry != null && entry.evictInternal(GridCacheVersionManager.EVICT_VER, null, false)) { if (plcEnabled) notifyPolicy(entry); if (recordable) cctx.events().addEvent(entry.partition(), entry.key(), cctx.nodeId(), null, null, null, EVT_CACHE_ENTRY_EVICTED, null, false, entry.rawGet(), entry.hasValue(), null, null, null, false); } } }
assert cached.detached() || cached.lockedByThread(threadId) || isRollbackOnly() : "Transaction lock is not acquired [entry=" + cached + ", tx=" + this + ", nodeId=" + cctx.localNodeId() + ", threadId=" + threadId + ']'; !txEntry.skipStore(); v = cached.innerGet( null, this, v = cached.rawGet(); ver = cached.version(); ret.success(pass && (!retval ? !rmv || cached.hasValue() || v != null : !rmv || v != null)); log.debug("Got removed entry in putAllAsync method (will retry): " + cached); txEntry.cached(entryEx(cached.context(), txEntry.txKey(), topologyVersion()));
ver = cached.isNear() ? ((GridNearCacheEntry)cached).dhtVersion() : cached.version(); getRes = txEntry.cached().innerGetVersioned( null, this, val = txEntry.cached().innerGet( null, this, missed.put(key, txEntry.cached().version()); GridCacheVersion ver = entry.version(); entry.innerGetVersioned( null, this, val = entry.innerGet( null, this, if (entry != null && readCommitted()) { if (cacheCtx.isNear()) { if (cacheCtx.affinity().partitionBelongs(cacheCtx.localNode(), entry.partition(), topVer)) { if (entry.markObsolete(xidVer)) cacheCtx.cache().removeEntry(entry);
@Override public void applyx(GridCacheEntryEx entry, GridCacheVersion obsoleteVer) { boolean touch = !entry.isNear(); while (true) { try { if (log.isTraceEnabled()) log.trace("Trying to remove expired entry from cache: " + entry); if (entry.onTtlExpired(obsoleteVer)) touch = false; break; } catch (GridCacheEntryRemovedException ignore) { entry = entry.context().cache().entryEx(entry.key()); touch = true; } } if (touch) entry.touch(); } };
txEntry.conflictExpireTime() == CU.EXPIRE_TIME_CALCULATE) { if (expiry != null) { cached.unswap(true); Duration duration = cached.hasValue() ? expiry.getExpiryForUpdate() : expiry.getExpiryForCreation(); val = oldVal = cached.innerGet( null, tx, txEntry.cached().version(), keepBinary, txEntry.cached()); filterFailedKeys = new ArrayList<>(); filterFailedKeys.add(cached.txKey()); ret.success(txEntry.op() != DELETE || cached.hasValue()); oldVal = cached.innerGet( null, tx,
skip = e.cached().isNear() || e.cached().detached() || !e.context().affinity().primaryByPartition(e.cached().partition(), topologyVersion()).isLocal(); e.cached().unswap(false); cacheCtx, key, e.cached().rawGet(), e.keepBinary()), cacheCtx.cacheObjectContext().unwrapBinaryIfNeeded(val, e.keepBinary(), false)); new CacheLazyEntry(cacheCtx, key, e.cached().rawGet(), e.keepBinary()));
assertFalse(entry.lockedByAny()); assertTrue(entry.localCandidates().isEmpty()); assertTrue(entry.remoteMvccSnapshot().isEmpty());
GridCacheEntryEx e = cache.entryEx(key); if (e != null && e.deleted()) { assertEquals(0, e.ttl()); assertTrue("Not found " + key, !cache.affinity().isPrimaryOrBackup(grid.localNode(), key)); else { e.unswap(); assertTrue(e.expireTime() > 0); else assertEquals(0, e.expireTime());
/** * @param e Entry to notify eviction policy. */ private void notifyPolicy(GridCacheEntryEx e) { assert plcEnabled; assert plc != null; assert !e.isInternal() : "Invalid entry for policy notification: " + e; assert e.context() == cctx : "Entry from another cache context passed to eviction manager: [" + "entry=" + e + ", cctx=" + cctx + ", entryCtx=" + e.context() + "]"; if (log.isDebugEnabled()) log.debug("Notifying eviction policy with entry: " + e); if (filter == null || filter.evictAllowed(e.wrapLazyValue(cctx.keepBinary()))) plc.onEntryAccessed(e.obsoleteOrDeleted(), e.wrapEviction()); }
/** {@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()); }