本文整理了Java中org.apache.ignite.Ignite.createCaches()
方法的一些代码示例,展示了Ignite.createCaches()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.createCaches()
方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:createCaches
[英]Dynamically starts new caches with the given cache configurations.
If local node is an affinity node, this method will return the instance of started caches. Otherwise, it will create a client caches on local node.
If for one of configurations a cache with the same name already exists in the grid, an exception will be thrown regardless whether the given configuration matches the configuration of the existing cache or not.
[中]使用给定的缓存配置动态启动新缓存。
如果本地节点是关联节点,则此方法将返回已启动缓存的实例。否则,它将在本地节点上创建客户端缓存。
如果对于其中一个配置,网格中已存在同名缓存,则无论给定配置是否与现有缓存的配置匹配,都将引发异常。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public Collection<IgniteCache> createCaches(Collection<CacheConfiguration> cacheCfgs) {
checkIgnite();
return g.createCaches(cacheCfgs);
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite.
*/
protected void startCachesDynamically(Ignite ignite) {
List<CacheConfiguration> ccfg = new ArrayList<>(CACHES);
for (int i = 0; i < CACHES; i++)
ccfg.add(new CacheConfiguration<>(cacheName(i))
.setBackups(1)
.setAffinity(new RendezvousAffinityFunction(false, 32)));
ignite.createCaches(ccfg);
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite instance.
*/
protected void startGroupCachesDynamically(Ignite ignite) {
List<CacheConfiguration> ccfg = new ArrayList<>(CACHES);
for (int i = 0; i < CACHES; i++)
ccfg.add(new CacheConfiguration<>(cacheName(i))
.setGroupName(i % 2 == 0 ? "grp-even" : "grp-odd")
.setBackups(1)
.setAffinity(new RendezvousAffinityFunction(false, 32)));
ignite.createCaches(ccfg);
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite instance.
*/
private void startCaches(Ignite ignite) {
List<CacheConfiguration> ccfg = new ArrayList<>(CACHES);
for (int i = 0; i < CACHES; i++) {
ccfg.add(new CacheConfiguration<>(cacheName(i))
.setGroupName(i % 2 == 0 ? ODD_GROUP_NAME : EVEN_GROUP_NAME)
.setBackups(1)
.setAffinity(new RendezvousAffinityFunction(false, 32)));
}
ignite.createCaches(ccfg);
}
代码示例来源:origin: apache/ignite
/** */
private Map<Integer, Integer> startGridsAndLoadData(int srvs) throws Exception {
Ignite srv = startGrids(srvs);
srv.active(true);
srv.createCaches(Arrays.asList(cacheConfigurations1()));
Map<Integer, Integer> cacheData = new LinkedHashMap<>();
for (int i = 1; i <= 100; i++) {
for (CacheConfiguration ccfg : cacheConfigurations1()) {
srv.cache(ccfg.getName()).put(-i, i);
cacheData.put(-i, i);
}
}
return cacheData;
}
代码示例来源:origin: apache/ignite
srv.createCaches(cacheConfigurations(null, ATOMIC));
代码示例来源:origin: apache/ignite
srv0.createCaches(ccfgs);
代码示例来源:origin: apache/ignite
srv.createCaches(cacheConfigurations(grp, atomicityMode));
代码示例来源:origin: apache/ignite
ignite.createCaches(ccfgs);
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testCreateDropCache2() throws Exception {
CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1)
.setIndexedTypes(Integer.class, Person.class);
CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, "c2", PARTITIONED, ATOMIC, 1)
.setIndexedTypes(Integer.class, Person.class);
Ignite ignite = startGrid();
ignite.active(true);
ignite.createCaches(Arrays.asList(ccfg1, ccfg2));
ignite.cache("c1").destroy();
ignite.createCache(ccfg1);
stopGrid();
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testCreateDropCache1() throws Exception {
CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, "c1", PARTITIONED, ATOMIC, 1);
CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, "c2", PARTITIONED, ATOMIC, 1);
Ignite ignite = startGrid();
ignite.active(true);
ignite.createCaches(Arrays.asList(ccfg1, ccfg2));
ignite.cache("c1").destroy();
ignite.cache("c2").destroy();
ignite.createCache(ccfg1);
ignite.createCache(ccfg2);
stopGrid();
}
代码示例来源:origin: apache/ignite
@Override public Object call() throws Exception {
final Ignite kernal = grid(0);
CacheConfiguration ccfgDynamic = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfgDynamic.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfgDynamic.setName(DYNAMIC_CACHE_NAME);
ccfgDynamic.setNodeFilter(NODE_FILTER);
CacheConfiguration ccfgStatic = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfgStatic.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
// Cache is already configured, should fail.
ccfgStatic.setName(STATIC_CACHE_NAME);
ccfgStatic.setNodeFilter(NODE_FILTER);
return kernal.createCaches(F.asList(ccfgDynamic, ccfgStatic));
}
}, CacheExistsException.class, null);
代码示例来源:origin: apache/ignite
caches.add(c3);
ignite(0).createCaches(caches);
代码示例来源:origin: apache/ignite
node.createCaches(Arrays.asList(ccfgs1));
代码示例来源:origin: apache/ignite
node.createCaches(Arrays.asList(ccfgs1));
代码示例来源:origin: apache/ignite
/**
* @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);
}
代码示例来源:origin: apache/ignite
/**
* @param cacheMode Cache mode.
* @param atomicityMode Atomicity mode.
* @throws Exception If failed.
*/
private void loadCache(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws Exception {
int keys = 100;
boolean loc = cacheMode == LOCAL;
Map<Integer, Integer> data1 = generateDataMap(keys);
Map<Integer, Integer> data2 = generateDataMap(keys);
Factory<? extends CacheStore<Integer, Integer>> fctr1 =
FactoryBuilder.factoryOf(new MapBasedStore<>(data1));
Factory<? extends CacheStore<Integer, Integer>> fctr2 =
FactoryBuilder.factoryOf(new MapBasedStore<>(data2));
CacheConfiguration ccfg1 = cacheConfiguration(GROUP1, CACHE1, cacheMode, atomicityMode, 1, false)
.setCacheStoreFactory(fctr1);
CacheConfiguration ccfg2 = cacheConfiguration(GROUP1, CACHE2, cacheMode, atomicityMode, 1, false)
.setCacheStoreFactory(fctr2);
Ignite node = startGrids(loc ? 1 : 4);
node.createCaches(F.asList(ccfg1, ccfg2));
IgniteCache<Integer, Integer> cache1 = node.cache(CACHE1);
IgniteCache<Integer, Integer> cache2 = node.cache(CACHE2);
cache1.loadCache(null);
checkCacheData(data1, CACHE1);
assertEquals(0, cache2.size());
cache2.loadCache(null);
checkCacheData(data2, CACHE2);
}
代码示例来源:origin: apache/ignite
node.createCaches(Arrays.asList(ccfgs));
代码示例来源:origin: org.apache.ignite/ignite-spring
/** {@inheritDoc} */
@Override public Collection<IgniteCache> createCaches(Collection<CacheConfiguration> cacheCfgs) {
checkIgnite();
return g.createCaches(cacheCfgs);
}
内容来源于网络,如有侵权,请联系作者删除!