/** {@inheritDoc} */ @Override protected Void run(Void arg) { for (String cacheName : ignite.cacheNames()) { IgniteCache cache = ignite.cache(cacheName); if (cache == null) throw new IllegalStateException("Failed to find cache for name: " + cacheName); cache.resetQueryDetailMetrics(); } return null; }
/** * @param ignite Ignite. */ public AggregateCacheLoader(IgniteEx ignite) { this.ignite = ignite; List<CacheLoader> cacheLoaders = new ArrayList<>(); for (String cacheName : ignite.cacheNames()) cacheLoaders.add(new CacheLoader(ignite, cacheName)); this.cacheLoaders = cacheLoaders; }
/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { Collection<String> names = ctx.kernalContext().grid().cacheNames(); return new ClientCacheGetNamesResponse(requestId(), names); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); mbSrv.clear(); for (String cacheName : grid(0).cacheNames()) { if (!(EXISTING_CACHE_NAME.equals(cacheName) || DEFAULT_CACHE_NAME.equals(cacheName))) grid(0).cache(cacheName).destroy(); } }
/** * @throws Exception In case of failure. */ @Test public void testCacheNames() throws Exception { try { startGridsMultiThreaded(2); Collection<String> names = grid(0).cacheNames(); assertEquals(2, names.size()); for (String name : names) assertTrue(name.equals(CACHE_NAME_1) || name.equals(CACHE_NAME_2)); } finally { stopAllGrids(); } } }
/** * @throws Exception In case of failure. */ @Test public void testCacheNames() throws Exception { try { startGridsMultiThreaded(2); Collection<String> names = grid(0).cacheNames(); assertEquals(3, names.size()); for (String name : names) assertTrue(DEFAULT_CACHE_NAME.equals(name) || name.equals("replicated") || name.equals("partitioned")); client = true; Ignite client = startGrid(2); names = client.cacheNames(); assertEquals(3, names.size()); } finally { stopAllGrids(); } } }
/** * @param tabName Table name. * @return QueryEntity of table. */ private QueryEntity findTableInfo(String tabName) { IgniteEx ignite = grid(0); Collection<String> cacheNames = ignite.cacheNames(); for (String cacheName : cacheNames) { CacheConfiguration ccfg = ignite.cache(cacheName).getConfiguration(CacheConfiguration.class); Collection<QueryEntity> entities = ccfg.getQueryEntities(); for (QueryEntity entity : entities) if (entity.getTableName().equalsIgnoreCase(tabName)) return entity; } return null; }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { for(String cacheName : grid(0).cacheNames()) { info("Clear cache: " + cacheName); grid(0).cache(cacheName).clear(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { stmt.close(); conn.close(); // Destroy all SQL caches after test. for (String cacheName : grid(0).cacheNames()) { DynamicCacheDescriptor cacheDesc = grid(0).context().cache().cacheDescriptor(cacheName); if (cacheDesc != null && cacheDesc.sql()) grid(0).destroyCache0(cacheName, true); } super.afterTest(); }
/** * Checks that cache contexts have consistent parameters after recovery finished and nodes have joined to topology. */ private void checkCacheContextsConsistencyAfterRecovery() throws Exception { IgniteEx crd = grid(0); Collection<String> cacheNames = crd.cacheNames(); for (String cacheName : cacheNames) { for (int nodeIdx = 1; nodeIdx < 3; nodeIdx++) { IgniteEx node = grid(nodeIdx); GridCacheContext one = cacheContext(crd, cacheName); GridCacheContext other = cacheContext(node, cacheName); checkCacheContextsConsistency(one, other); } } }
for (String cacheName : grid(0).cacheNames()) ((IgniteKernal)grid(0)).getCache(cacheName).getAndPut(new GridCacheInternalKeyImpl("LONG", ""), new GridCacheAtomicLongValue(0));
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { conn.close(); // Destroy all SQL caches after test. for (String cacheName : grid(0).cacheNames()) { DynamicCacheDescriptor cacheDesc = grid(0).context().cache().cacheDescriptor(cacheName); if (cacheDesc != null && cacheDesc.sql()) grid(0).destroyCache0(cacheName, true); } super.afterTest(); }
/** * Compares checksums between primary and backup partitions of specified caches. * Works properly only on idle cluster - there may be false positive conflict reports if data in cluster is being * concurrently updated. * * @param ig Ignite instance. * @param caches Cache names (if null, all user caches will be verified). * @return Conflicts result. * @throws IgniteException If none caches or node found. */ protected IdleVerifyResultV2 idleVerify(Ignite ig, String... caches) { IgniteEx ig0 = (IgniteEx)ig; Set<String> cacheNames = new HashSet<>(); if (F.isEmpty(caches)) cacheNames.addAll(ig0.cacheNames()); else Collections.addAll(cacheNames, caches); if (cacheNames.isEmpty()) throw new IgniteException("None cache for checking."); ClusterNode node = !ig0.localNode().isClient() ? ig0.localNode() : ig0.cluster().forServers().forRandom().node(); if (node == null) throw new IgniteException("None server node for verification."); VisorIdleVerifyTaskArg taskArg = new VisorIdleVerifyTaskArg(cacheNames); return ig.compute().execute( VisorIdleVerifyTaskV2.class.getName(), new VisorTaskArgument<>(node.id(), taskArg, false) ); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); // Clean up all caches. for (int i = 0; i < GRID_CNT; i++) { for(String cacheName : grid(i).cacheNames()) { IgniteCache<Object, Object> c = grid(i).cache(cacheName); c.removeAll(); // Fix for tests where mapping was removed at primary node // but was not removed at others. // removeAll() removes mapping only when it presents at a primary node. // To remove all mappings used force remove by key. if (c.size() > 0) { for (Cache.Entry<Object, Object> e : c.localEntries()) c.remove(e.getKey()); } } } U.sleep(5000); for (int i = 0; i < GRID_CNT; i++) { for(String cacheName : grid(i).cacheNames()) { IgniteCache<Object, Object> c = grid(i).cache(cacheName); assertEquals(0, c.size(CachePeekMode.OFFHEAP)); assertEquals(0, c.size(CachePeekMode.PRIMARY)); assertEquals(0, c.size()); } } }
/** */ private void checkCacheDestroyed(IgniteEx grid, String encCacheName, String grpName, boolean keyShouldBeEmpty) throws Exception { awaitPartitionMapExchange(); Collection<String> cacheNames = grid.cacheNames(); for (String cacheName : cacheNames) { if (cacheName.equals(encCacheName)) fail(encCacheName + " should be destroyed."); } int grpId = CU.cacheGroupId(encCacheName, grpName); KeystoreEncryptionKey encKey = (KeystoreEncryptionKey)grid.context().encryption().groupKey(grpId); MetaStorage metaStore = grid.context().cache().context().database().metaStorage(); if (keyShouldBeEmpty) { assertNull(encKey); assertNull(metaStore.readRaw(ENCRYPTION_KEY_PREFIX + grpId)); } else { assertNotNull(encKey); assertNotNull(metaStore.readRaw(ENCRYPTION_KEY_PREFIX + grpId)); } } }
/** */ void checkEncryptedCaches(IgniteEx grid0, IgniteEx grid1) { Set<String> cacheNames = new HashSet<>(grid0.cacheNames()); cacheNames.addAll(grid1.cacheNames()); for (String cacheName : cacheNames) { CacheConfiguration ccfg = grid1.cache(cacheName).getConfiguration(CacheConfiguration.class); if (!ccfg.isEncryptionEnabled()) continue; IgniteInternalCache<?, ?> encrypted0 = grid0.cachex(cacheName); int grpId = CU.cacheGroupId(cacheName, ccfg.getGroupName()); assertNotNull(encrypted0); IgniteInternalCache<?, ?> encrypted1 = grid1.cachex(cacheName); assertNotNull(encrypted1); assertTrue(encrypted1.configuration().isEncryptionEnabled()); KeystoreEncryptionKey encKey0 = (KeystoreEncryptionKey)grid0.context().encryption().groupKey(grpId); assertNotNull(encKey0); assertNotNull(encKey0.key()); if (!grid1.configuration().isClientMode()) { KeystoreEncryptionKey encKey1 = (KeystoreEncryptionKey)grid1.context().encryption().groupKey(grpId); assertNotNull(encKey1); assertNotNull(encKey1.key()); assertEquals(encKey0.key(), encKey1.key()); } else assertNull(grid1.context().encryption().groupKey(grpId)); } checkData(grid0); }
/** {@inheritDoc} */ @Override protected Void run(Void arg) { for (String cacheName : ignite.cacheNames()) { IgniteCache cache = ignite.cache(cacheName); if (cache == null) throw new IllegalStateException("Failed to find cache for name: " + cacheName); cache.resetQueryDetailMetrics(); } return null; }
/** {@inheritDoc} */ @Override public ClientResponse process(ClientConnectionContext ctx) { Collection<String> names = ctx.kernalContext().grid().cacheNames(); return new ClientCacheGetNamesResponse(requestId(), names); } }