/** * @return Near cache. */ private GridDhtCacheAdapter<K, V> cache() { return cctx.dht(); }
/** {@inheritDoc} */ @Override public boolean onDone(@Nullable Collection<K> res, @Nullable Throwable err) { if (super.onDone(res, err)) { if (trackable) cctx.dht().removeFuture(this); return true; } return false; }
/** * @return DHT cache. */ public GridDhtCacheAdapter dhtCache() { GridCacheAdapter<K, V> cache = this.cache; if (cache == null) throw new IllegalStateException("Cache stopped: " + cacheName); return isNear() ? ((GridNearCacheAdapter<K, V>)cache).dht() : dht(); }
/** * Sets thread local cache operation context. * * @param opCtx Operation context. */ public void operationContextPerCall(@Nullable CacheOperationContext opCtx) { if (nearContext()) dht().near().context().opCtxPerCall.set(opCtx); else opCtxPerCall.set(opCtx); }
/** * Gets thread local cache operation context. * * @return Operation context per call. */ public CacheOperationContext operationContextPerCall() { return nearContext() ? dht().near().context().opCtxPerCall.get() : opCtxPerCall.get(); }
/** * @return {@code True} if need check near cache context. */ private boolean nearContext() { return isDht() || (isDhtAtomic() && dht().near() != null); }
/** * Updates near cache. * * @param req Update request. * @param res Update response. */ private void updateNear(GridNearAtomicAbstractUpdateRequest req, GridNearAtomicUpdateResponse res) { assert nearEnabled; if (res.remapTopologyVersion() != null) return; GridNearAtomicCache near = (GridNearAtomicCache)cctx.dht().near(); near.processNearAtomicUpdateResponse(req, res); }
/** * Updates near cache. * * @param req Update request. * @param res Update response. */ private void updateNear(GridNearAtomicAbstractUpdateRequest req, GridNearAtomicUpdateResponse res) { assert nearEnabled; if (res.remapTopologyVersion() != null) return; GridNearAtomicCache near = (GridNearAtomicCache)cctx.dht().near(); near.processNearAtomicUpdateResponse(req, res); }
/** * @return {@code true} if the skip store flag is set. */ public boolean skipStore() { if (nearContext()) return dht().near().context().skipStore(); CacheOperationContext opCtx = opCtxPerCall.get(); return (opCtx != null && opCtx.skipStore()); }
/** {@inheritDoc} */ @Override public boolean onDone(Object res, Throwable err) { if (super.onDone(res, err)) { // Don't forget to clean up. if (trackable) cctx.mvcc().removeFuture(futId); cctx.dht().sendTtlUpdateRequest(expiryPlc); return true; } return false; }
/** * @param cacheCtx Context. * @param key Key * @param ver Version. * @throws IgniteCheckedException If invalidate failed. */ private void invalidateNearEntry(GridCacheContext cacheCtx, KeyCacheObject key, GridCacheVersion ver) throws IgniteCheckedException { GridNearCacheAdapter near = cacheCtx.isNear() ? cacheCtx.near() : cacheCtx.dht().near(); GridCacheEntryEx nearEntry = near.peekEx(key); if (nearEntry != null) nearEntry.invalidate(ver); }
/** {@inheritDoc} */ @Override @Nullable protected IgniteInternalFuture<Boolean> addReader(long msgId, GridDhtCacheEntry cached, IgniteTxEntry entry, AffinityTopologyVersion topVer) { // Don't add local node as reader. if (entry.addReader() && !cctx.localNodeId().equals(nearNodeId)) { GridCacheContext cacheCtx = cached.context(); while (true) { try { return cached.addReader(nearNodeId, msgId, topVer); } catch (GridCacheEntryRemovedException ignore) { if (log.isDebugEnabled()) log.debug("Got removed entry when adding to DHT local transaction: " + cached); cached = cacheCtx.dht().entryExx(entry.key(), topVer); } } } return null; }
/** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { CacheMetricsImpl m = new CacheMetricsImpl(ctx); m.delegate(ctx.dht().near().metrics0()); metrics = m; ctx.dr().resetMetrics(); super.start(); }
/** * @param g Grid. * @return Topology. */ private GridDhtPartitionTopology topology(Ignite g) { GridCacheAdapter<Integer, String> internalCache = ((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME); return internalCache.isNear() ? ((GridNearCacheAdapter<Integer, String>)internalCache).dht().topology() : internalCache.context().dht().topology(); }
/** * @return DHT cache. */ protected <K, V> GridDhtCacheAdapter<K, V> dht() { GridCacheAdapter<K, V> internalCache = ((IgniteKernal)grid()).internalCache(DEFAULT_CACHE_NAME); return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); }
/** * @param idx Grid index. * @return DHT cache. */ protected <K, V> GridDhtCacheAdapter<K, V> dht(int idx) { GridCacheAdapter<K, V> internalCache = ((IgniteKernal)grid(idx)).internalCache(DEFAULT_CACHE_NAME); return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); }
/** * @param idx Grid index. * @param cache Cache name. * @return DHT cache. */ protected <K, V> GridDhtCacheAdapter<K, V> dht(int idx, String cache) { GridCacheAdapter<K, V> internalCache = ((IgniteKernal)grid(idx)).internalCache(cache); return internalCache.isNear() ? internalCache.context().near().dht() : internalCache.context().dht(); }
/** * @param cache Cache. * @return DHT cache. */ protected static <K, V> GridDhtCacheAdapter<K, V> dht(IgniteCache<K, V> cache) { return nearEnabled(cache) ? near(cache).dht() : ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context().dht(); }
/** * @param entry Write entry. * @param ldr Class loader. * @throws IgniteCheckedException If failed. */ public void addWrite(IgniteTxEntry entry, ClassLoader ldr) throws IgniteCheckedException { entry.unmarshal(cctx, false, ldr); GridCacheContext cacheCtx = entry.context(); try { GridDhtCacheEntry cached = cacheCtx.dht().entryExx(entry.key(), topologyVersion()); checkInternal(entry.txKey()); // Initialize cache entry. entry.cached(cached); txState.addWriteEntry(entry.txKey(), entry); addExplicit(entry); } catch (GridDhtInvalidPartitionException e) { addInvalidPartition(cacheCtx, e.partition()); } }
/** * @param node Node. * @param key Key. * @return Extracts update counter of partition which key belongs to. */ private long getUpdateCounter(IgniteEx node, Integer key) { int partId = node.cachex(DEFAULT_CACHE_NAME).context().affinity().partition(key); GridDhtLocalPartition part = node.cachex(DEFAULT_CACHE_NAME).context().dht().topology().localPartition(partId); assert part != null; return part.updateCounter(); } }