/** {@inheritDoc} */ @Override protected Map<String, VisorCacheConfiguration> run(VisorCacheConfigurationCollectorTaskArg arg) { Collection<IgniteCacheProxy<?, ?>> caches = ignite.context().cache().jcaches(); Pattern ptrn = arg.getRegex() != null ? Pattern.compile(arg.getRegex()) : null; boolean all = F.isEmpty(arg.getCacheNames()); boolean hasPtrn = ptrn != null; Map<String, VisorCacheConfiguration> res = U.newHashMap(caches.size()); for (IgniteCacheProxy<?, ?> cache : caches) { String cacheName = cache.getName(); boolean matched = hasPtrn ? ptrn.matcher(cacheName).find() : all || arg.getCacheNames().contains(cacheName); if (!VisorTaskUtils.isRestartingCache(ignite, cacheName) && matched) { VisorCacheConfiguration cfg = config(cache.getConfiguration(CacheConfiguration.class), cache.context().dynamicDeploymentId()); res.put(cacheName, cfg); } } return res; }
/** {@inheritDoc} */ @Override protected Collection<VisorCacheMetrics> run(final VisorCacheMetricsCollectorTaskArg arg) { assert arg != null; boolean showSysCaches = arg.isShowSystemCaches(); Collection<String> cacheNames = arg.getCacheNames(); assert cacheNames != null; GridCacheProcessor cacheProcessor = ignite.context().cache(); Collection<IgniteCacheProxy<?, ?>> caches = cacheProcessor.jcaches(); Collection<VisorCacheMetrics> res = new ArrayList<>(caches.size()); boolean allCaches = cacheNames.isEmpty(); for (IgniteCacheProxy ca : caches) { String cacheName = ca.getName(); if (!VisorTaskUtils.isRestartingCache(ignite, cacheName)) { GridCacheContext ctx = ca.context(); if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) res.add(cm); } } } return res; }
IgniteKernal g0 = (IgniteKernal)g; for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) { CacheConfiguration cfg = c.context().config();
for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) { CacheConfiguration cfg = c.context().config();
/** * @throws Exception if fail. */ @Test public void testDeActivateCheckCacheDestroy() throws Exception { String chName = "myCache"; Ignite ig1 = primary(0); Ignite ig2 = primary(1); Ignite ig3 = primary(2); ig1.getOrCreateCache(chName); assertTrue(ig1.active()); assertTrue(ig2.active()); assertTrue(ig3.active()); ig1.active(false); assertTrue(!ig1.active()); assertTrue(!ig2.active()); assertTrue(!ig3.active()); IgniteEx ex = (IgniteEx)ig1; GridCacheProcessor cache = ex.context().cache(); assertTrue(F.isEmpty(cache.jcaches())); } }
/** {@inheritDoc} */ @Override protected Map<String, VisorCacheConfiguration> run(VisorCacheConfigurationCollectorTaskArg arg) { Collection<IgniteCacheProxy<?, ?>> caches = ignite.context().cache().jcaches(); Collection<String> cacheNames = arg.getCacheNames(); boolean all = F.isEmpty(cacheNames); Map<String, VisorCacheConfiguration> res = U.newHashMap(all ? caches.size() : cacheNames.size()); for (IgniteCacheProxy<?, ?> cache : caches) { String cacheName = cache.getName(); if (all || cacheNames.contains(cacheName)) { res.put(cacheName, config(cache.getConfiguration(CacheConfiguration.class), cache.context().dynamicDeploymentId())); } } return res; }
/** {@inheritDoc} */ @Override protected Collection<VisorCacheMetrics> run(final VisorCacheMetricsCollectorTaskArg arg) { assert arg != null; boolean showSysCaches = arg.isShowSystemCaches(); Collection<String> cacheNames = arg.getCacheNames(); assert cacheNames != null; GridCacheProcessor cacheProcessor = ignite.context().cache(); Collection<IgniteCacheProxy<?, ?>> caches = cacheProcessor.jcaches(); Collection<VisorCacheMetrics> res = new ArrayList<>(caches.size()); boolean allCaches = cacheNames.isEmpty(); for (IgniteCacheProxy ca : caches) { GridCacheContext ctx = ca.context(); if (ctx.started() && (ctx.affinityNode() || ctx.isNear())) { String cacheName = ca.getName(); VisorCacheMetrics cm = new VisorCacheMetrics(ignite, cacheName); if ((allCaches || cacheNames.contains(cacheName)) && (showSysCaches || !cm.isSystem())) res.add(cm); } } return res; }