/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <T> T get(Object key, Class<T> type) { Object val = cache.get(key); if (NULL.equals(val)) val = null; if (val != null && type != null && !type.isInstance(val)) throw new IllegalStateException("Cached value is not of required type [cacheName=" + cache.getName() + ", key=" + key + ", val=" + val + ", requiredType=" + type + ']'); return (T)val; }
/** {@inheritDoc} */ @Override public String toString() { return "TestConfig [" + "idx=" + idx + ", testedCache=" + testedCache.getName() + ", personCache=" + personCache + ", accCache=" + accCache + ", orgCache=" + orgCache + ", qry=" + qry + ']'; } }
/** {@inheritDoc} */ @Override public String call() throws Exception { return cache().getName(); } }
@Override public boolean apply() { for (Object key : newVals.keySet()) { if (primaryCache(key, cache.getName()).get(key) != null) return false; } return true; } }, 5000);
/** * @param cache Cache. * @return Affinity. */ public static <K> Affinity<K> affinity(IgniteCache<K, ?> cache) { return cache.unwrap(Ignite.class).affinity(cache.getName()); }
/** */ private void verifyCache(IgniteCache cache, BiFunction<String, Integer, String> generatingFunc) { int size = cache.size(CachePeekMode.PRIMARY); String cacheName = cache.getName(); for (int i = 0; i < size; i++) { String value = (String) cache.get(i); assertEquals(generatingFunc.apply(cacheName, i), value); } } }
/** * @param cache Cache. * @return Cache. */ protected static <K, V> GridCacheAdapter<K, V> internalCache0(IgniteCache<K, V> cache) { if (isMultiJvmObject(cache)) throw new UnsupportedOperationException("Operation can't be supported automatically for multi jvm " + "(send closure instead)."); return ((IgniteKernal)cache.unwrap(Ignite.class)).internalCache(cache.getName()); }
/** * */ public void consistencyCheck(IgniteEx ignite) { IgniteCache<Integer, TestValue> cache = ignite.getOrCreateCache(cacheName); for (int key = 0; key < KEYS_SPACE; key++) { TestValue expectedVal = locCache.get(key); TestValue actualVal = cache.get(key); Assert.assertEquals("Consistency check failed for: " + cache.getName() + ", key=" + key, expectedVal, actualVal); } }
@Override public void run(IgniteServices services, String svcName, TestService svc) { IgniteCache<Object, Object> cache = grid(testedNodeIdx).getOrCreateCache(CACHE_NAME); try { services.deployKeyAffinitySingleton(svcName, (Service)svc, cache.getName(), primaryKey(cache)); } catch (IgniteCheckedException e) { throw new IgniteException(e); } } }));
/** * @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(); }
@Override public CacheConfiguration call(Ignite ignite, IgniteCache<K, V> cache) throws Exception { return ((IgniteKernal)ignite).<K, V>internalCache(cache.getName()).context().config(); } });
/** * @param cache Cache. * @param cnt Count. */ private void readCacheData(IgniteCache<Integer, Integer> cache, int cnt) { for (int i = 0; i < cnt; i++) grid(i % GRID_CNT).cache(cache.getName()).get(i); }
/** * @param cache Cache. * @return Near cache. */ protected static <K, V> GridNearCacheAdapter<K, V> near(IgniteCache<K, V> cache) { return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context().near(); }
/** * @param cache Cache. */ protected <K, V> GridCacheAdapter<K, V> cacheFromCtx(IgniteCache<K, V> cache) { return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context().cache(); }
/** * @param cache Cache. * @return Colocated cache. */ protected static <K, V> GridDhtColocatedCache<K, V> colocated(IgniteCache<K, V> cache) { return ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context().colocated(); }
/** * @param cache Cache. * @throws Exception If failed. */ private void checkDestroyed(IgniteCache<Object, Object> cache) throws Exception { checkUsageFails(cache); awaitPartitionMapExchange(); String cacheName = cache.getName(); for (int i = 0; i < 3; i++) assertNull("Unexpected cache for node: " + i, grid(i).cache(cacheName)); }
/** {@inheritDoc} */ @Override protected void initCacheAndDbData() throws Exception { Integer k1 = primaryKey(ignite(0).cache(pCache.getName())); Integer k2 = primaryKey(ignite(1).cache(pCache.getName())); Organization org1 = new Organization(k1, "org", "org1"); Organization org2 = new Organization(k2, "org", "org2"); pCache.put(k1, org1); pCache.put(k2, org2); insertInDb(org1); insertInDb(org2); }
/** * @param cache Cache. * @return DHT cache. */ protected static <K, V> GridDhtCacheAdapter<K, V> dht(IgniteCache<K, V> cache) { return nearEnabled(cache) ? near(cache).dht() : ((IgniteKernal)cache.unwrap(Ignite.class)).<K, V>internalCache(cache.getName()).context().dht(); }
@Override public void apply(Integer idx) { for (int i = 0; i < 100; i++) { CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setName("cache-" + idx + "-" + i); ccfg.setEvictionPolicy(new LruEvictionPolicy(1000)); ccfg.setOnheapCacheEnabled(true); IgniteCache<Object, Object> cache = ignite.createCache(ccfg); for (int k = 0; k < 5000; k++) cache.put(k, new byte[1024]); ignite.destroyCache(cache.getName()); } } }, 5, "cache-thread");