本文整理了Java中org.apache.ignite.Ignite.getOrCreateCache()
方法的一些代码示例,展示了Ignite.getOrCreateCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.getOrCreateCache()
方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:getOrCreateCache
[英]Gets existing cache with the given name or creates new one using template configuration.
[中]获取具有给定名称的现有缓存,或使用模板配置创建新缓存。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg) {
checkIgnite();
return g.getOrCreateCache(cacheCfg);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> getOrCreateCache(String cacheName) {
checkIgnite();
return g.getOrCreateCache(cacheName);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected Object getTargetRepository(RepositoryInformation metadata) {
return getTargetRepositoryViaReflection(metadata,
ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface())));
}
代码示例来源:origin: apache/ignite
@Override public Object call() throws Exception {
int idx = cnt.getAndIncrement();
try {
CacheConfiguration cfg = new CacheConfiguration(DYNAMIC_CACHE_NAME);
ignite(idx).getOrCreateCache(cfg);
}
catch (Exception e) {
err.compareAndSet(null, e);
}
return null;
}
}, nodeCount(), "starter");
代码示例来源:origin: apache/ignite
@Override public Object call() throws Exception {
ignite.getOrCreateCache(cacheConfiguration("NEW_CACHE"));
return null;
}
}, IgniteException.class, EXPECTED_MSG);
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
ignite.getOrCreateCache("test0");
ignite.getOrCreateCache("test1");
final IgniteCompute comp = ignite.compute();
for (int i = 0; i < MAX_JOB_COUNT; ++i) {
IgniteRunnable job = (IgniteRunnable)factory.create();
IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), 0, job);
fut.get();
}
}
});
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
ignite.getOrCreateCache("test0");
ignite.getOrCreateCache("test1");
final IgniteCompute comp = ignite.compute();
for (int i = 0; i < MAX_JOB_COUNT; ++i) {
IgniteRunnable job = (IgniteRunnable)factory.create();
comp.affinityRun(Arrays.asList("test0", "test1"), key(0), job);
}
}
});
代码示例来源:origin: apache/ignite
@Override public void run() {
srv.destroyCache(DEFAULT_CACHE_NAME);
srv.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
ignite(0).getOrCreateCache("noop");
}
代码示例来源:origin: apache/ignite
@Override public void test(Factory factory, Ignite ignite) throws Exception {
ignite.getOrCreateCache("test0");
ignite.getOrCreateCache("test1");
final IgniteCompute comp = ignite.compute();
for (int i = 0; i < MAX_JOB_COUNT; ++i) {
IgniteRunnable job = (IgniteRunnable)factory.create();
IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), key(0), job);
fut.get();
}
}
});
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
ignite = startGridsMultiThreaded(NODES_COUNT, false);
initCache = ignite.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
.setSqlSchema("PUBLIC")
);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
ignite = startGridsMultiThreaded(NODES_COUNT, false);
initCache = ignite.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
.setSqlSchema("PUBLIC")
);
}
代码示例来源:origin: apache/ignite
/**
* @param client Client.
* @param cacheName Cache name.
*/
private void checkFineCache(Ignite client, String cacheName) {
IgniteCache<Integer, String> cache = client.getOrCreateCache(cacheName);
cache.put(1, "1");
assertEquals("1", cache.get(1));
}
代码示例来源:origin: apache/ignite
/** */
private void createAndFillCache(Ignite srv) {
IgniteCache cache = srv.getOrCreateCache(cacheConfiguration());
for (int i = 0; i < ENTRIES_COUNT; i++)
cache.put(i, new TestValue(i, "str" + i));
}
代码示例来源:origin: apache/ignite
@Override public Boolean call() throws Exception {
Ignite node = startGrid(nodeId);
log.info("Getting cache.");
IgniteCache<Integer, Integer> cache = node.getOrCreateCache(cacheConfig());
log.info("Got cache.");
FILLED_LATCH.await();
log.info("Got Filled.");
cache.put(1, nodeId);
checkCacheState(node, cache);
return true;
}
});
代码示例来源:origin: apache/ignite
/**
* @param atomicityMode Atomicity mode.
* @throws Exception If failed.
*/
public void asyncOperations(CacheAtomicityMode atomicityMode) throws Exception {
try (IgniteCache<Integer, Integer> cache = ignite(1).getOrCreateCache(cacheConfiguration(atomicityMode))) {
async1(cache);
async2(cache);
}
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite.
* @param name Name.
*/
private IgniteCache<Integer, Integer> getCache(Ignite ignite, String name) {
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setName(name);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(0);
ccfg.setNearConfiguration(null);
return ignite.getOrCreateCache(ccfg);
}
代码示例来源:origin: apache/ignite
/** */
private void setUpGrids(int n, boolean indexed) throws Exception {
Ignite ign = startGridsMultiThreaded(n);
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME)
.setAtomicityMode(TRANSACTIONAL_SNAPSHOT);
if (indexed)
ccfg.setIndexedTypes(Integer.class, Integer.class);
ign.getOrCreateCache(ccfg);
G.setClientMode(true);
client = startGrid(n);
}
代码示例来源:origin: apache/ignite
/**
* @param ignite Ignite.
* @param name Cache name.
* @param expBackups Expected number of backups.
*/
private void checkGetOrCreate(Ignite ignite, String name, int expBackups) {
IgniteCache cache = ignite.getOrCreateCache(name);
assertNotNull(cache);
CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class);
assertEquals(name, cfg.getName());
assertEquals(expBackups, cfg.getBackups());
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
startGridsMultiThreaded(NODES_COUNT - 1, false);
clientMode = true;
startGrid(NODES_COUNT);
orgCache = ignite(NODES_COUNT).getOrCreateCache(new CacheConfiguration<Integer, JoinSqlTestHelper.Organization>(ORG_CACHE_NAME)
.setCacheMode(CacheMode.PARTITIONED)
.setQueryEntities(organizationQueryEntity())
);
awaitPartitionMapExchange();
populateDataIntoOrg();
}
内容来源于网络,如有侵权,请联系作者删除!