/** * @param cacheName Name of the cache. * @return Instance on the named cache. * @throws IgniteCheckedException If cache not found. */ protected IgniteInternalCache<Object, Object> localCache(String cacheName) throws IgniteCheckedException { IgniteInternalCache<Object, Object> cache = ctx.cache().cache(cacheName); if (cache == null) throw new IgniteCheckedException( "Failed to find cache for given cache name: " + cacheName); return cache; }
/** * */ private void assertCachesAfterStop(IgniteEx igniteEx) { assertNull(igniteEx .context() .cache() .cacheGroup(CU.cacheId(STATIC_CACHE_CACHE_GROUP_NAME))); assertTrue(igniteEx.context().cache().cacheGroups().isEmpty()); for (int i = 0; i < CACHES_COUNT; i++) { assertNull(igniteEx.context().cache().cache(STATIC_CACHE_PREFIX + i)); assertNull(igniteEx.context().cache().internalCache(STATIC_CACHE_PREFIX + i)); } }
@Override public <K> boolean containsKey(String cacheName, K key) { return ctx.cache().cache(cacheName).containsKey(key); }
/** {@inheritDoc} */ @Nullable @Override public final Object execute() { if (!waitAffinityReadyFuture()) return null; IgniteInternalCache cache = ((IgniteEx)ignite).context().cache().cache(cacheName); return localExecute(cache); }
@Override public int partition(String cacheName, Object key) { return ctx.cache().cache(cacheName).affinity().partition(key); }
/** * Extract system cache from kernal. * * @param ignite Ignite instance. * @param cacheName System cache name. * @return Internal cache instance. */ protected IgniteInternalCache<Object, Object> getSystemCache(final Ignite ignite, final String cacheName) { return ((IgniteKernal) ignite).context().cache().cache(cacheName); }
/** {@inheritDoc} */ @Override public <K, V> IgniteInternalCache<K, V> cachex(String name) { CU.validateCacheName(name); guard(); try { checkClusterState(); return ctx.cache().cache(name); } finally { unguard(); } }
@Override public boolean apply() { return expCache == (node.context().cache().cache(cacheName) != null); } }, 1000));
/** * @param node Node. * @param cacheName Cache name. */ private void checkCache(Ignite node, final String cacheName) { assertNotNull(((IgniteKernal)node).context().cache().cache(cacheName)); } }
@Override public boolean apply() { for (Ignite g : G.allGrids()) { IgniteInternalCache<Object, Object> cache = ((IgniteEx)g).context().cache().cache(cacheName); if (cache != null) return false; } return true; } }, getTestTimeout());
/** {@inheritDoc} */ @Override public void run() { IgniteInternalCache cache = ignite.context().cache().cache(name); try { cache.context().offheap().preloadPartition(part); } catch (IgniteCheckedException e) { log.error("Failed to preload the partition [cache=" + name + ", partition=" + part + ']', e); throw new IgniteException(e); } } }
/** * @param node Node. * @param cacheName Cache name. */ private void checkCache(Ignite node, final String cacheName) { assertNotNull(((IgniteKernal)node).context().cache().cache(cacheName)); } }
@Override public void apply(IgniteEx ig) { Map<String, DynamicCacheDescriptor> desc = cacheDescriptors(ig); Assert.assertEquals(1, desc.size()); Assert.assertTrue(desc.containsKey(CU.UTILITY_CACHE_NAME)); Assert.assertNull(ig.context().cache().cache(cache1)); Assert.assertNull(ig.context().cache().cache(cache2)); Map<String, GridCacheAdapter> caches = caches(ig); Assert.assertEquals(1, caches.size()); Assert.assertTrue(caches.containsKey(CU.UTILITY_CACHE_NAME)); } });
@Override public void apply(IgniteEx ig) { Map<String, DynamicCacheDescriptor> desc = cacheDescriptors(ig); Assert.assertEquals(3, desc.size()); Assert.assertTrue(desc.containsKey(CU.UTILITY_CACHE_NAME)); Assert.assertTrue(desc.containsKey(cache1)); Assert.assertTrue(desc.containsKey(cache2)); Assert.assertNotNull(ig.context().cache().cache(cache1)); Assert.assertNotNull(ig.context().cache().cache(cache2)); Map<String, GridCacheAdapter> caches = caches(ig); Assert.assertEquals(3, caches.size()); Assert.assertTrue(caches.containsKey(CU.UTILITY_CACHE_NAME)); Assert.assertTrue(caches.containsKey(cache1)); Assert.assertTrue(caches.containsKey(cache2)); } });
@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()); } });
@Override public boolean apply() { for (int i = 0; i < NODES; i++) { final GridDhtPartitionTopology top = ((IgniteKernal)ignite(i)).context().cache().cache(DEFAULT_CACHE_NAME).context().topology(); for (GridDhtLocalPartition p : top.currentLocalPartitions()) { Collection<Object> rmvQueue = GridTestUtils.getFieldValue(p, "rmvQueue"); if (!rmvQueue.isEmpty() || p.dataStore().fullSize() != 0) return false; } } return true; } }, 5000);
/** * @param cacheName Cache name. * @throws Exception If failed. */ private void checkCacheInitialization(final String cacheName) throws Exception { Ignite client = grid("client"); checkFailedCache(client, cacheName); checkFineCache(client, CACHE_NAME + 1); assertNull(((IgniteKernal)client).context().cache().cache(cacheName)); checkFineCache(client, CACHE_NAME + 2); }
/** */ @Test public void testDynamicTableCreateNotNullFieldsAllowed() throws Exception { executeSql("CREATE TABLE test(id INT PRIMARY KEY, field INT NOT NULL)"); String cacheName = QueryUtils.createTableCacheName("PUBLIC", "TEST"); IgniteEx client = grid(NODE_CLIENT); CacheConfiguration ccfg = client.context().cache().cache(cacheName).configuration(); QueryEntity qe = (QueryEntity)F.first(ccfg.getQueryEntities()); assertEquals(Collections.singleton("FIELD"), qe.getNotNullFields()); checkState("PUBLIC", "TEST", "FIELD"); }