/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (Exception e) { throw new RuntimeException(e.getMessage()); } } }
/** * @param cache Cache. * @return Near cache. */ private static <K, V> GridNearCacheAdapter<K, V> near(GridCacheAdapter<K, V> cache) { return cache.context().near(); }
/** * @param cacheName Cache name. * @return Cache object context. */ private CacheObjectContext cacheObjectContext(String cacheName) { return ctx.cache().internalCache(cacheName).context().cacheObjectContext(); }
/** {@inheritDoc} */ @Override public void disableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), false); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } } }
/** * @return Cache object context. */ private CacheObjectContext objectContext() { if (ctx == null) return null; return ctx.cache().internalCache(cacheName).context().cacheObjectContext(); }
/** {@inheritDoc} */ @Override public void enableStatistics() { try { cache.context().shared().cache().enableStatistics(Collections.singleton(cache.name()), true); } catch (IgniteCheckedException e) { throw new RuntimeException(e.getMessage()); } }
/** {@inheritDoc} */ @Override public long getNonHeapMemoryUsed() { Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches(); long nonHeapUsed = vmMetrics.getNonHeapMemoryUsed(); for (GridCacheAdapter<?, ?> cache : caches) if (cache.context().statisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) nonHeapUsed += cache.metrics0().getOffHeapAllocatedSize(); return nonHeapUsed; }
/** {@inheritDoc} */ @Override public Void call() throws IgniteCheckedException { assert ignite != null; GridCacheAdapter cache = ((IgniteKernal)ignite).context().cache().internalCache(cacheName); // On non-affinity node cache starts on demand, so it may not be running. if (cache != null) cache.context().dataStructures().blockSet(setId); return null; }
/** * @param idx Grid index. * @param cache Cache name. * @return Near cache. */ protected <K, V> GridNearCacheAdapter<K, V> near(int idx, String cache) { return ((IgniteKernal)grid(idx)).<K, V>internalCache(cache).context().near(); }
/** * @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 cache Cache. * @return Cache context. */ public static <K, V> GridCacheContext<K, V> cacheContext(IgniteCache<K, V> cache) { return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context(); }
/** * @param nodeId Node ID. * @param key Key. * @return Near entry. */ @Nullable private static GridCacheEntryEx nearEntry(UUID nodeId, Object key) { Ignite g = G.ignite(nodeId); GridNearCacheAdapter<Object, Integer> near = ((IgniteKernal)g).<Object, Integer>internalCache(DEFAULT_CACHE_NAME).context().near(); return near.peekEx(key); }
/** * @param idx Index of grid. * @return Cache context. */ protected GridCacheContext<String, Integer> context(final int idx) { if (isRemoteJvm(idx) && !isRemoteJvm()) throw new UnsupportedOperationException("Operation can't be done automatically via proxy. " + "Send task with this logic on remote jvm instead."); return ((IgniteKernal)grid(idx)).<String, Integer>internalCache(DEFAULT_CACHE_NAME).context(); }
@Override public void run() { for (GridCacheMvccCandidate cand : cands) { boolean b = grid.<String, String>internalCache(DEFAULT_CACHE_NAME).context().mvcc().addNext(ctx, cand); assert b; } info("Link thread finished."); } }, 1);
/** * @param idx Index of grid. * @return Cache context. */ protected GridCacheContext<String, Integer> context(final int idx) { if (isRemoteJvm(idx) && !isRemoteJvm()) throw new UnsupportedOperationException("Operation can't be done automatically via proxy. " + "Send task with this logic on remote jvm instead."); return ((IgniteKernal)grid(idx)).<String, Integer>internalCache(cacheName()).context(); }
/** {@inheritDoc} */ @Override public void run(int idx) throws Exception { GridCacheContext<String, Integer> ctx = ((IgniteKernal)ignite).<String, Integer>internalCache(cacheName).context(); int size = 0; for (String key : map.keySet()) if (ctx.affinity().keyLocalNode(key, ctx.discovery().topologyVersionEx())) size++; assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(ctx.name()).localSize(ALL)); } }
@Override public void apply(IgniteEx ig) { Assert.assertNull(ig.context().cache().cache(cache1)); Assert.assertNull(ig.context().cache().cache(cache2)); Map<String, GridCacheAdapter> caches = caches(ig); for (GridCacheAdapter cacheAdapter : caches.values()) Assert.assertTrue("Cache should be in recovery mode: " + cacheAdapter.context(), cacheAdapter.context().isRecoveryMode()); } });
/** {@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; for (String key : keys) if (ctx.affinity().keyLocalNode(key, ctx.discovery().topologyVersionEx())) size++; assertEquals("Incorrect key size on cache #" + idx, size, ignite.cache(DEFAULT_CACHE_NAME).localSize(ALL)); } }
/** * @param nodes Number of nodes. */ final void checkNoCaches(int nodes) { for (int i = 0; i < nodes; i++) { grid(i).context().state().publicApiActiveState(true); GridCacheProcessor cache = ((IgniteEx)ignite(i)).context().cache(); assertTrue(cache.caches().isEmpty()); assertTrue(cache.internalCaches().stream().allMatch(c -> c.context().isRecoveryMode())); } } }