/** {@inheritDoc} */ @Override public Map<Integer, CacheMetrics> cacheMetrics() { try { if (disableCacheMetricsUpdate) return Collections.emptyMap(); /** Caches should not be accessed while state transition is in progress. */ if (ctx.state().clusterState().transition()) return Collections.emptyMap(); Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches(); if (!F.isEmpty(caches)) { Map<Integer, CacheMetrics> metrics = U.newHashMap(caches.size()); for (GridCacheAdapter<?, ?> cache : caches) { if (cache.context().statisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) metrics.put(cache.context().cacheId(), cache.localMetrics()); } return metrics; } } catch (Exception e) { U.warn(log, "Failed to compute cache metrics", e); } return Collections.emptyMap(); } };
/** * @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())); } } }
/** {@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 Map<Integer, CacheMetrics> cacheMetrics() { try { /** Caches should not be accessed while state transition is in progress. */ if (ctx.state().clusterState().transition()) return Collections.emptyMap(); Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches(); if (!F.isEmpty(caches)) { Map<Integer, CacheMetrics> metrics = U.newHashMap(caches.size()); for (GridCacheAdapter<?, ?> cache : caches) { if (cache.context().statisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) metrics.put(cache.context().cacheId(), cache.localMetrics()); } return metrics; } } catch (Exception e) { U.warn(log, "Failed to compute cache metrics", e); } return Collections.emptyMap(); } };
/** {@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; }