/** {@inheritDoc} */ @Override public void incrementPublicSize(CacheMapHolder hld, GridCacheEntryEx e) { assert cacheId == e.context().cacheId(); entryMap.size.incrementAndGet(); }
/** {@inheritDoc} */ @Override public void decrementPublicSize(CacheMapHolder hld, GridCacheEntryEx e) { assert cacheId == e.context().cacheId(); entryMap.size.decrementAndGet(); } }
/** * @param entry Cache entry. */ public void cached(GridCacheEntryEx entry) { assert entry == null || entry.context() == ctx : "Invalid entry assigned to tx entry [txEntry=" + this + ", entry=" + entry + ", ctxNear=" + ctx.isNear() + ", ctxDht=" + ctx.isDht() + ']'; this.entry = entry; }
/** {@inheritDoc} */ @Override public void incrementPublicSize(@Nullable CacheMapHolder hld, GridCacheEntryEx e) { if (grp.sharedGroup()) { if (hld == null) hld = cacheMapHolder(e.context()); hld.size.incrementAndGet(); } while (true) { long state = this.state.get(); if (this.state.compareAndSet(state, setSize(state, getSize(state) + 1))) return; } }
/** {@inheritDoc} */ @Override public void decrementPublicSize(@Nullable CacheMapHolder hld, GridCacheEntryEx e) { if (grp.sharedGroup()) { if (hld == null) hld = cacheMapHolder(e.context()); hld.size.decrementAndGet(); } while (true) { long state = this.state.get(); assert getPartState(state) != EVICTED; if (this.state.compareAndSet(state, setSize(state, getSize(state) - 1))) return; } }
/** {@inheritDoc} */ @Override public void incrementPublicSize(CacheMapHolder hld, GridCacheEntryEx e) { localPartition(e.context(), e.key(), AffinityTopologyVersion.NONE, true).incrementPublicSize(hld, e); }
/** {@inheritDoc} */ @Override public boolean removeEntry(GridCacheEntryEx entry) { GridDhtLocalPartition part = localPartition(entry.context(), entry.key(), AffinityTopologyVersion.NONE, false); if (part == null) return false; return part.removeEntry(entry); }
/** {@inheritDoc} */ @Override public void decrementPublicSize(CacheMapHolder hld, GridCacheEntryEx e) { localPartition(e.context(), e.key(), AffinityTopologyVersion.NONE, true).decrementPublicSize(hld, e); }
/** {@inheritDoc} */ @Override public K getKey() throws IllegalStateException { return cached.key().value(cached.context().cacheObjectContext(), false); }
/** * @return Peeks value. */ @Nullable public V peek() { try { CacheObject val = cached.peek(); return val != null ? val.<V>value(cached.context().cacheObjectContext(), false) : null; } catch (GridCacheEntryRemovedException ignored) { return null; } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
/** * @param entry Entry. * @return {@code True} if local node is current primary for given entry. */ private boolean primaryLocal(GridCacheEntryEx entry) { return entry.context().affinity().primaryByPartition(cctx.localNode(), entry.partition(), AffinityTopologyVersion.NONE); }
/** {@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} */ @Override public boolean apply(GridCacheEntryEx e) { CacheObject val = peekVisibleValue(e); GridCacheContext cctx = e.context(); if (this.val instanceof BinaryObject && val instanceof BinaryObject) return F.eq(val, this.val); Object thisVal = CU.value(this.val, cctx, false); Object cacheVal = CU.value(val, cctx, false); return F.eq(thisVal, cacheVal); }
/** * @param tx Transaction to notify evictions for. */ private void notifyEvictions(IgniteInternalTx tx) { if (tx.internal()) return; for (IgniteTxEntry txEntry : tx.allEntries()) txEntry.cached().context().evicts().touch(txEntry, tx.local()); }
/** {@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); }
/** {@inheritDoc} */ @Override public boolean evict() { GridCacheContext<K, V> ctx = cached.context(); try { assert ctx != null; CacheEvictionManager mgr = ctx.evicts(); if (mgr == null) { assert ctx.kernalContext().isStopping(); return false; } return mgr.evict(cached, null, false, null); } catch (IgniteCheckedException e) { U.error(ctx.grid().log(), "Failed to evict entry from cache: " + cached, e); return false; } }
/** {@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()); }
/** {@inheritDoc} */ @Override public IgnitePair<Long> call(Ignite ignite, IgniteCache<String, Integer> cache) throws Exception { GridCacheAdapter<?, ?> internalCache = internalCache0(cache); if (useDhtForNearCache && internalCache.context().isNear()) internalCache = internalCache.context().near().dht(); GridCacheEntryEx entry = internalCache.entryEx(key); entry.unswap(); IgnitePair<Long> pair = new IgnitePair<>(entry.ttl(), entry.expireTime()); if (!entry.isNear()) entry.context().cache().removeEntry(entry); return pair; } }