/** {@inheritDoc} */ @Override public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs) { checkIgnite(); return g.getOrCreateCaches(cacheCfgs); }
@Override public Void call() throws Exception { Ignite node = ignite(idx.incrementAndGet() % NODES); b.await(); boolean sleep = iter % 2 == 0; if (sleep) Thread.sleep(ThreadLocalRandom.current().nextLong(100) + 1); switch (op) { case GET_OR_CREATE_CACHE: node.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)); break; case GET_OR_CREATE_CACHES: node.getOrCreateCaches(cacheConfigurations()); break; } return null; } }, THREADS, "start-cache");
@Override public void apply(Integer idx) { try { b.await(); Ignite node = startGrid(idx + SRVS); if (createCache) { for (int c = 0; c < 5; c++) { for (IgniteCache cache : node.getOrCreateCaches(cacheConfigurations())) { boolean updated = false; while (!updated) { try { cache.put(c, c); updated = true; } catch (Exception e) { assertMvccWriteConflict(e); } } assertEquals(c, cache.get(c)); } } } } catch (Exception e) { throw new IgniteException(e); } } }, CLIENTS, "start-client");
Collection<IgniteCache> caches = client.getOrCreateCaches(cfgs);
/** * @param ig Ig. */ private void loadData(Ignite ig) { List<CacheConfiguration> configs = Stream.of( F.t(CACHE_1, GROUP_1), F.t(CACHE_2, GROUP_1), F.t(CACHE_3, GROUP_2), F.t(CACHE_4, GROUP_2) ).map(names -> new CacheConfiguration<>(names.get1()) .setGroupName(names.get2()) .setRebalanceBatchSize(REBALANCE_BATCH_SIZE) .setCacheMode(CacheMode.REPLICATED) .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL) ).collect(Collectors.toList()); ig.getOrCreateCaches(configs); configs.forEach(cfg -> { try (IgniteDataStreamer<Object, Object> streamer = ig.dataStreamer(cfg.getName())) { for (int i = 0; i < KEYS_SIZE; i++) streamer.addData(i, new byte[1024]); streamer.flush(); } }); }
caches = client.getOrCreateCaches(cacheConfigurations(grp, atomicityMode)); else { caches = new ArrayList<>();
srv.getOrCreateCaches(cacheConfigurations()); for (IgniteCache cache : node.getOrCreateCaches(cacheConfigurations())) { cache.put(c, c);
/** * @throws Exception If failed. */ @Test public void testStartClientCachesOnCoordinatorWithGroup() throws Exception { startGrids(3); List<CacheConfiguration> ccfgs = cacheConfigurations("testGrp", ATOMIC); for (CacheConfiguration ccfg : ccfgs) ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0)))); ignite(1).createCaches(ccfgs); ccfgs = cacheConfigurations("testGrp", ATOMIC); for (CacheConfiguration ccfg : ccfgs) ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0)))); for (IgniteCache<Object, Object> cache : ignite(0).getOrCreateCaches(ccfgs)) { cache.put(1, 1); assertEquals(1, cache.get(1)); cache.close(); } startGrid(4); }
ignite(0).getOrCreateCaches(Arrays.asList(configurations2()));
/** {@inheritDoc} */ @Override public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs) { checkIgnite(); return g.getOrCreateCaches(cacheCfgs); }