/** * */ private void onException() { for (IgniteTxEntry txEntry : allEntries()) { GridCacheEntryEx cached0 = txEntry.cached(); if (cached0 != null) cached0.touch(); } }
/** * Releases java-level locks on cache entries. * * @param locked Locked entries. */ private void unlockEntries(Iterable<GridCacheEntryEx> locked) { for (GridCacheEntryEx entry : locked) entry.unlockEntry(); AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion(); for (GridCacheEntryEx entry : locked) entry.touch(); }
@Override public IgniteInternalFuture<Map<K, V>> apply(Map<K, V> map, Exception e) { if (e != null) { clearReservationsIfNeeded(topVer, loadKeys, loaded, tx0); return new GridFinishedFuture<>(e); } if (tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED)) { Collection<KeyCacheObject> notFound = new HashSet<>(loadKeys.keySet()); notFound.removeAll(loaded); // Touch entries that were not found in store. for (KeyCacheObject key : notFound) { GridCacheEntryEx entry = peekEx(key); if (entry != null) entry.touch(); } } // There were no misses. return new GridFinishedFuture<>(Collections.<K, V>emptyMap()); } },
/** * @param topVer Affinity topology version for which load was performed. * @param loadKeys Keys to load. * @param loaded Actually loaded keys. * @param tx0 Transaction within which the load was run, if any. */ private void clearReservationsIfNeeded( AffinityTopologyVersion topVer, Map<KeyCacheObject, EntryGetResult> loadKeys, Collection<KeyCacheObject> loaded, IgniteTxLocalAdapter tx0 ) { if (loaded.size() != loadKeys.size()) { boolean needTouch = tx0 == null || (!tx0.implicit() && tx0.isolation() == READ_COMMITTED); for (Map.Entry<KeyCacheObject, EntryGetResult> e : loadKeys.entrySet()) { if (loaded.contains(e.getKey())) continue; if (needTouch || e.getValue().reserved()) { GridCacheEntryEx entry = peekEx(e.getKey()); if (entry != null) { if (e.getValue().reserved()) entry.clearReserveForLoad(e.getValue().version()); if (needTouch) entry.touch(); } } } } }
entry.touch();
/** * @param key Key. * @param heap Read heap flag. * @param offheap Read offheap flag. * @return Value. * @throws GridCacheEntryRemovedException If entry removed. * @throws IgniteCheckedException If failed. */ @SuppressWarnings("ConstantConditions") @Nullable private CacheObject localCachePeek0(KeyCacheObject key, boolean heap, boolean offheap) throws GridCacheEntryRemovedException, IgniteCheckedException { assert ctx.isLocal(); assert heap || offheap; GridCacheEntryEx e = offheap ? entryEx(key) : peekEx(key); if (e != null) { try { return e.peek(heap, offheap, AffinityTopologyVersion.NONE, null); } finally { e.touch(); } } return null; }
entry.touch();
/** * Process single key. * * @param key Key. * @param clo Closure. * @throws IgniteCheckedException If failed. */ private void processKey(KeyCacheObject key, SchemaIndexCacheVisitorClosure clo) throws IgniteCheckedException { while (true) { try { checkCancelled(); GridCacheEntryEx entry = cctx.cache().entryEx(key); try { entry.updateIndex(rowFilter, clo); } finally { entry.touch(); } break; } catch (GridDhtInvalidPartitionException ignore) { break; } catch (GridCacheEntryRemovedException ignored) { // No-op. } } }
@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(); } };
entry.touch();
false); entry.touch();
entry.touch();
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(DEFAULT_CACHE_NAME).context(); int size = 0; if (ctx.isNear()) ctx = ctx.near().dht().context(); for (String key : keys) { if (ctx.affinity().keyLocalNode(key, ctx.discovery().topologyVersionEx())) { GridCacheEntryEx e = ctx.cache().entryEx(key); assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']'; assert !e.deleted() : "Entry is deleted: " + e; size++; e.touch(); } } assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL)); } }
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(cacheName).context(); int size = 0; if (ctx.isNear()) ctx = ctx.near().dht().context(); for (String key : keys) { if (ctx.affinity().keyLocalNode(key, ctx.discovery().topologyVersionEx())) { GridCacheEntryEx e = ctx.cache().entryEx(key); assert e != null : "Entry is null [idx=" + idx + ", key=" + key + ", ctx=" + ctx + ']'; assert !e.deleted() : "Entry is deleted: " + e; size++; e.touch(); } } assertEquals("Incorrect size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL)); } }
entry.touch();
dhtEntry.touch();
entry.touch();