本文整理了Java中org.apache.ignite.Ignite.set()
方法的一些代码示例,展示了Ignite.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.set()
方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:set
[英]Will get a named set from cache and create one if it has not been created yet and cfg is not null.
[中]将从缓存中获取命名集,并在尚未创建且cfg不为null时创建一个命名集。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Nullable @Override public <T> IgniteSet<T> set(String name,
CollectionConfiguration cfg)
{
checkIgnite();
return g.set(name, cfg);
}
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.set(name, null);
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
@Override public Object call() throws Exception {
boolean failed = false;
try {
client.set("testSet", getCollectionConfiguration());
}
catch (IgniteClientDisconnectedException e) {
failed = true;
checkAndWait(e);
}
assertTrue(failed);
return client.set("testSet", getCollectionConfiguration());
}
},
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.set(name, config(false));
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
/**
* @param creator Creator node.
* @param other Other node.
* @throws Exception If failed.
*/
private void testSet(Ignite creator, Ignite other) throws Exception {
assertNull(creator.set("set1", null));
assertNull(other.set("set1", null));
CollectionConfiguration colCfg = new CollectionConfiguration();
try (IgniteSet<Integer> set = creator.set("set1", colCfg)) {
assertNotNull(set);
assertEquals(0, set.size());
assertFalse(set.contains(1));
assertTrue(set.add(1));
assertTrue(set.contains(1));
IgniteSet<Integer> set0 = other.set("set1", null);
assertTrue(set0.contains(1));
assertEquals(1, set0.size());
assertTrue(set0.remove(1));
assertFalse(set.contains(1));
}
assertNull(creator.set("set1", null));
assertNull(other.set("set1", null));
}
代码示例来源:origin: apache/ignite
@Override public void apply(Ignite ignite) {
for (int i = 0; i < 100; i++) {
CollectionConfiguration colCfg = new CollectionConfiguration();
colCfg.setCollocated(collocated);
colCfg.setBackups(1);
colCfg.setCacheMode(PARTITIONED);
colCfg.setAtomicityMode(i % 2 == 0 ? TRANSACTIONAL : ATOMIC);
IgniteSet set = ignite.set("set-" + i, colCfg);
set.close();
}
}
});
代码示例来源:origin: apache/ignite
/**
* @param colCfg Collection configuration.
* @throws Exception If failed.
*/
private void setReconnectRemove(CollectionConfiguration colCfg) throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
final Ignite srv = ignite(0);
final String setName = "set-rm-" + colCfg.getAtomicityMode();
final IgniteSet<String> clientSet = client.set(setName, colCfg);
final IgniteSet<String> srvSet = srv.set(setName, null);
assertTrue(clientSet.add("1"));
assertFalse(srvSet.add("1"));
reconnectClientNode(client, srv, new Runnable() {
@Override public void run() {
srvSet.close();
}
});
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
clientSet.add("fail");
return null;
}
}, IllegalStateException.class, null);
IgniteSet<String> newClientSet = client.set(setName, colCfg);
IgniteSet<String> newSrvSet = srv.set(setName, null);
assertTrue(newClientSet.add("1"));
assertFalse(newSrvSet.add("1"));
newSrvSet.close();
}
代码示例来源:origin: apache/ignite
/**
* @param collocated Collocation flag.
*/
private void testCacheReuse(boolean collocated) {
Ignite ignite = grid(0);
CollectionConfiguration colCfg = collectionConfiguration().setCollocated(collocated);
colCfg.setAtomicityMode(ATOMIC);
colCfg.setGroupName("grp1");
IgniteSet set1 = ignite.set("set1", colCfg);
IgniteSet set2 = ignite.set("set2", colCfg);
assertEquals(separated(set1), cctx(set1).cacheId() != cctx(set2).cacheId());
colCfg.setAtomicityMode(TRANSACTIONAL);
IgniteSet set3 = ignite.set("set3", colCfg);
IgniteSet set4 = ignite.set("set4", colCfg);
assertEquals(separated(set3), cctx(set3).cacheId() != cctx(set4).cacheId());
assertTrue(cctx(set1).cacheId() != cctx(set3).cacheId());
assertTrue(cctx(set1).groupId() == cctx(set3).groupId());
colCfg.setGroupName("gtp2");
IgniteSet set5 = ignite.set("set5", colCfg);
IgniteSet set6 = ignite.set("set6", colCfg);
assertEquals(separated(set5), cctx(set5).cacheId() != cctx(set6).cacheId());
assertTrue(cctx(set1).groupId() != cctx(set5).groupId());
Stream.of(set1, set2, set3, set4, set5, set6).forEach(IgniteSet::close);
}
代码示例来源:origin: apache/ignite
/**
* @param colCfg Collection configuration.
* @throws Exception If failed.
*/
private void serverNodeReconnect(CollectionConfiguration colCfg) throws Exception {
final Ignite client = grid(serverCount());
final Ignite srv = ignite(0);
assertNotNull(srv.queue("q", 0, colCfg));
assertNotNull(srv.set("s", colCfg));
reconnectClientNode(client, srv, null);
IgniteQueue<Object> q = client.queue("q", 0, null);
assertNotNull(q);
}
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testSet() throws Exception {
Ignite ignite = startGrids(4);
ignite.active(true);
IgniteSet<Object> set = ignite.set("testSet", new CollectionConfiguration());
for (int i = 0; i < 100; i++)
set.add(i);
assertEquals(100, set.size());
stopAllGrids();
ignite = startGrids(4);
ignite.active(true);
set = ignite.set("testSet", null);
assertFalse(set.add(99));
for (int i = 0; i < 100; i++)
assertTrue(set.contains(i));
assertEquals(100, set.size());
}
代码示例来源:origin: apache/ignite
/**
* @param colCfg Collection configuration.
* @throws Exception If failed.
*/
private void setReconnect(CollectionConfiguration colCfg) throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
Ignite srv = ignite(0);
final String setName = "set-" + colCfg.getAtomicityMode();
IgniteSet<String> clientSet = client.set(setName, colCfg);
final IgniteSet<String> srvSet = srv.set(setName, null);
assertTrue(clientSet.add("1"));
assertFalse(srvSet.add("1"));
reconnectClientNode(client, srv, new Runnable() {
@Override public void run() {
assertTrue(srvSet.add("2"));
}
});
assertFalse(clientSet.add("2"));
assertTrue(clientSet.remove("2"));
assertFalse(srvSet.contains("2"));
}
代码示例来源:origin: apache/ignite
final IgniteSet<Object> set = client.set("s", TX_CFGS);
try (IgniteSet<Object> set2 = client.set("s", TX_CFGS)) {
set2.add(1);
代码示例来源:origin: apache/ignite
log.info("Create set, grid: " + ignite.name());
res = ignite.set(name, config(false));
代码示例来源:origin: apache/ignite
IgniteSet<Integer> set0 = ignite.set(SET_NAME, colCfg);
代码示例来源:origin: apache/ignite
CollectionConfiguration cfg2 = collectionConfiguration().setGroupName("grp2");
IgniteSet<String> set1 = ignite.set("set1", cfg1);
IgniteSet<String> set2 = ignite.set("set2", cfg1);
IgniteSet<String> set3 = ignite.set("set3", cfg2);
IgniteSet<String> set4 = ignite.set("set4", cfg2);
assertFalse(set3.removed());
assertNotNull(ignite.set("set1", null));
assertNull(ignite.set("set2", null));
代码示例来源:origin: apache/ignite
final IgniteSet<String> clientSet = client.set(setName, colCfg);
final IgniteSet<String> srvSet = srv.set(setName, null);
代码示例来源:origin: apache/ignite
assertNull(ignite.set(name, null));
IgniteSet<Integer> set = ignite.set(name, config(false));
assertSame(set, ignite.set(name, config(false)));
assertSame(set, ignite.set(name, null));
代码示例来源:origin: org.apache.ignite/ignite-spring
/** {@inheritDoc} */
@Nullable @Override public <T> IgniteSet<T> set(String name,
CollectionConfiguration cfg)
{
checkIgnite();
return g.set(name, cfg);
}
代码示例来源:origin: org.apache.camel/camel-ignite
@Override
public Producer createProducer() throws Exception {
return new IgniteSetProducer(this, ignite().set(name, configuration));
}
代码示例来源:origin: Symantec/hendrix
for (String series : set) {
if (series.contains(tenantId)) {
IgniteSet<String> rules = ignite.set(series, cfg);
for (String ruleId : rules) {
IgniteQueue<Entry<Long, Number>> queue = ignite.queue(ruleId, seriesSize, colCfg);
内容来源于网络,如有侵权,请联系作者删除!