/** * @param entry Adds entry. */ public void add(IgniteTxEntry entry) { if (entries.add(entry) && entry.context().isNear()) nearEntries++; }
/** * @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(); }
/** * @param cacheCtx Cache context. * @param ver Lock version to check. * @return {@code True} if lock had been removed. */ public boolean isRemoved(GridCacheContext cacheCtx, GridCacheVersion ver) { return !cacheCtx.isNear() && !cacheCtx.isLocal() && ver != null && rmvLocks.contains(ver); }
/** * @param cache Cache. * @throws IgniteCheckedException If cache without near cache was already started. */ private void checkNearCacheStarted(IgniteCacheProxy<?, ?> cache) throws IgniteCheckedException { if (!cache.context().isNear()) throw new IgniteCheckedException("Failed to start near cache " + "(a cache with the same name without near cache is already started)"); }
/** * @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 int getTxDhtCommittedVersionsSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().completedVersionsSize() : -1; }
/** {@inheritDoc} */ @Override public int getTxDhtRolledbackVersionsSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().completedVersionsSize() : -1; }
/** {@inheritDoc} */ @Override protected void stop0(boolean cancel, boolean destroy) { cleanup(cctx.config(), plc, cctx.isNear()); }
/** {@inheritDoc} */ @Override public int getTxDhtXidMapSize() { return cctx.isNear() && dhtCtx != null ? dhtCtx.tm().idMapSize() : -1; }
/** * @param statisticsEnabled Statistics enabled flag. */ public void statisticsEnabled(boolean statisticsEnabled) { this.statisticsEnabled = statisticsEnabled; if (isNear()) near().dht().context().statisticsEnabled = statisticsEnabled; }
/** * @param tx Transaction. * @return {@code True} if should notify continuous query manager. */ public boolean notifyContinuousQueries(@Nullable IgniteInternalTx tx) { return cctx.isLocal() || cctx.isReplicated() || (!cctx.isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())); }
/** {@inheritDoc} */ @Override public void run() { for (GridCacheEntryEx gridCacheEntryEx : cache.entries()) clearEntry(gridCacheEntryEx); if (!ctx.isNear()) { if (id == 0) ctx.offheap().clearCache(ctx, readers); } }
/** * @param cacheCtx Cache context. * @param ver Obsolete entry version. * @return {@code True} if added. */ public boolean addRemoved(GridCacheContext cacheCtx, GridCacheVersion ver) { if (cacheCtx.isNear() || cacheCtx.isLocal()) return true; boolean ret = rmvLocks.add(ver); if (log.isDebugEnabled()) log.debug("Added removed lock version: " + ver); return ret; }
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { assertTrue(((IgniteKernal)ignite).internalCache(DEFAULT_CACHE_NAME).context().isNear()); } }
/** * @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); }
/** * Creates cache metrics; * * @param cctx Cache context. */ public CacheMetricsImpl(GridCacheContext<?, ?> cctx) { assert cctx != null; this.cctx = cctx; if (cctx.isNear()) dhtCtx = cctx.near().dht().context(); if (cctx.store().store() instanceof GridCacheWriteBehindStore) store = (GridCacheWriteBehindStore)cctx.store().store(); delegate = null; }
/** * @return {@code true} if near cache should be enabled. */ protected boolean nearEnabled() { return grid(testedNodeIdx).cachex(cacheName()).context().isNear(); }
/** * Prints memory stats. */ public void printMemoryStats() { if (ctx.isNear()) { X.println(">>> Near cache size: " + size()); ctx.near().dht().printMemoryStats(); } else if (ctx.isDht()) X.println(">>> DHT cache size: " + size()); else X.println(">>> Cache size: " + size()); }
/** {@inheritDoc} */ @Override protected void start0() throws IgniteCheckedException { dhtCtx = cctx.isNear() ? cctx.near().dht().context() : cctx; boolean cleanupDisabled = cctx.kernalContext().isDaemon() || !cctx.config().isEagerTtl() || CU.isUtilityCache(cctx.name()) || cctx.dataStructuresCache() || (cctx.kernalContext().clientNode() && cctx.config().getNearConfiguration() == null); if (cleanupDisabled) return; eagerTtlEnabled = true; cctx.shared().ttl().register(this); pendingEntries = (!cctx.isLocal() && cctx.config().getNearConfiguration() != null) ? new GridConcurrentSkipListSetEx() : null; }
/** {@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; } }