本文整理了Java中org.apache.ignite.Ignite.atomicReference()
方法的一些代码示例,展示了Ignite.atomicReference()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ignite.atomicReference()
方法的具体详情如下:
包路径:org.apache.ignite.Ignite
类名称:Ignite
方法名:atomicReference
[英]Will get a atomic reference from cache and create one if it has not been created yet and create flag is true. It will use configuration from IgniteConfiguration#getAtomicConfiguration().
[中]将从缓存中获取原子引用,并在尚未创建原子引用且create标志为true时创建一个原子引用。它将使用IgniteConfiguration#getAtomicConfiguration()中的配置。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public <T> IgniteAtomicReference<T> atomicReference(String name, AtomicConfiguration cfg,
@Nullable T initVal, boolean create) throws IgniteException {
checkIgnite();
return g.atomicReference(name, cfg, initVal, create);
}
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.atomicReference(name, 0, false);
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Nullable @Override public <T> IgniteAtomicReference<T> atomicReference(String name,
@Nullable T initVal,
boolean create)
{
checkIgnite();
return g.atomicReference(name, initVal, create);
}
代码示例来源:origin: apache/ignite
@Override public Void call() throws Exception {
ignite.atomicReference(name, 0, false);
return null;
}
}, IgniteException.class, null);
代码示例来源:origin: apache/ignite
@Override public Object apply(Ignite ignite) {
assert ignite.atomicReference(STRUCTURE_NAME, 1, false).get() > 0;
return null;
}
});
代码示例来源:origin: apache/ignite
@Override public void applyx(Ignite ignite) {
IgniteAtomicReference<Integer> ar = ignite.atomicReference(TEST_REF_NAME,
null, true);
for (int i = 0; i < operationsPerTx; i++) {
ar.set(RAND.nextInt(MAX_INT));
long cnt = writes.incrementAndGet();
if (cnt % WRITE_LOG_MOD == 0)
info("Performed " + cnt + " writes.");
}
}
};
代码示例来源:origin: apache/ignite
@Override public String call() {
IgniteAtomicReference<String> ref = ignite.atomicReference(refName, val, true);
assertEquals(val, ref.get());
return ref.get();
}
});
代码示例来源:origin: apache/ignite
@Override public void applyx(Ignite ignite) {
IgniteAtomicReference<Integer> ar = ignite.atomicReference(TEST_REF_NAME, null,
true);
for (int i = 0; i < operationsPerTx; i++) {
ar.get();
long cnt = reads.incrementAndGet();
if (cnt % READ_LOG_MOD == 0)
info("Performed " + cnt + " reads.");
}
}
};
代码示例来源:origin: apache/ignite
@Override public String call() {
IgniteAtomicReference<String> ref = ignite.atomicReference(refName, val, true);
assertEquals(val, ref.get());
return ref.get();
}
});
代码示例来源:origin: apache/ignite
@Override public String call() {
IgniteAtomicReference<String> ref = ignite.atomicReference(refName, val, true);
assertEquals(newVal, ref.get());
return ref.get();
}
});
代码示例来源:origin: apache/ignite
/**
* @throws Exception If failed.
*/
@Test
public void testAtomicReferenceTopologyChange() throws Exception {
try (IgniteAtomicReference atomic = grid(0).atomicReference(STRUCTURE_NAME, 10, true)) {
Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME);
assertEquals((Integer)10, g.atomicReference(STRUCTURE_NAME, 10, false).get());
g.atomicReference(STRUCTURE_NAME, 10, false).set(20);
stopGrid(NEW_IGNITE_INSTANCE_NAME);
assertEquals((Integer)20, grid(0).atomicReference(STRUCTURE_NAME, 10, true).get());
}
}
代码示例来源:origin: apache/ignite
Ignite ignite = grid(0);
IgniteAtomicReference<String> ref1 = ignite.atomicReference("ref1", "a", true);
IgniteAtomicReference<String> ref2 = ignite.atomicReference("ref2", "b", true);
IgniteAtomicReference<String> ref3 = ignite.atomicReference("ref3", "c", true);
IgniteAtomicReference<String> ref4 = ignite.atomicReference("ref4", cfg, "d", true);
IgniteAtomicReference<String> ref5 = ignite.atomicReference("ref5", cfg, "e", true);
IgniteAtomicReference<String> ref6 = ignite.atomicReference("ref6", cfg, "f", true);
assertNull(ignite.atomicReference("ref4", "a", false));
assertNull(ignite.atomicReference("ref5", "a", false));
assertNull(ignite.atomicReference("ref6", "a", false));
assertNull(ignite.atomicReference("ref1", cfg, "a", false));
assertNull(ignite.atomicReference("ref2", cfg, "a", false));
assertNull(ignite.atomicReference("ref3", cfg, "a", false));
assertTrue(ref5.removed());
assertNull(ignite.atomicReference("ref2", "b", false));
assertNull(ignite.atomicReference("ref5", cfg, "e", false));
assertNotNull(ignite.atomicReference("ref1", "a", false));
assertNotNull(ignite.atomicReference("ref3", "c", false));
assertNotNull(ignite.atomicReference("ref4", cfg, "d", false));
assertNotNull(ignite.atomicReference("ref6", cfg, "f", false));
代码示例来源:origin: apache/ignite
/**
*
*/
private void testAtomicReference() {
info("Test atomic reference");
IgniteAtomicReference<Person> ref = ignite.atomicReference("ref1", null, true);
assertNull(ref.get());
ref.set(person("p1"));
assertEquals(person("p1"), ref.get());
assertTrue(ref.compareAndSet(person("p1"), person("p2")));
assertEquals(person("p2"), ref.get());
assertFalse(ref.compareAndSet(person("p1"), person("p3")));
assertEquals(person("p2"), ref.get());
assertTrue(ref.compareAndSet(person("p2"), null));
assertNull(ref.get());
assertTrue(ref.compareAndSet(null, person("p2")));
assertEquals(person("p2"), ref.get());
ref.close();
ref = ignite.atomicReference("ref2", person("p1"), true);
assertEquals(person("p1"), ref.get());
}
代码示例来源:origin: apache/ignite
log.info("Create atomic reference, grid: " + ignite.name());
res = ignite.atomicReference(name, null, true);
代码示例来源:origin: apache/ignite
client.atomicReference("atomicRefRemoved", "1st value", true);
assertEquals("2st value", clientAtomicRef.get());
final IgniteAtomicReference<String> srvAtomicRef = srv.atomicReference("atomicRefRemoved", "1st value", false);
client.atomicReference("atomicRefRemoved", "1st value", true);
IgniteAtomicReference<String> newSrvAtomicRef = srv.atomicReference("atomicRefRemoved", "1st value", false);
代码示例来源:origin: apache/ignite
/**
* Tests atomic reference.
*
* @param topWorker Topology change worker.
* @throws Exception If failed.
*/
private void doTestAtomicReference(ConstantTopologyChangeWorker topWorker) throws Exception {
try (IgniteAtomicReference<Integer> s = grid(0).atomicReference(STRUCTURE_NAME, 1, true)) {
IgniteInternalFuture<?> fut = topWorker.startChangingTopology(new IgniteClosure<Ignite, Object>() {
@Override public Object apply(Ignite ignite) {
assert ignite.atomicReference(STRUCTURE_NAME, 1, false).get() > 0;
return null;
}
});
int val = s.get();
while (!fut.isDone()) {
assertEquals(val, (int)s.get());
s.set(++val);
}
fut.get();
for (Ignite g : G.allGrids())
assertEquals(val, (int)g.atomicReference(STRUCTURE_NAME, 1, true).get());
}
}
代码示例来源:origin: apache/ignite
final IgniteAtomicReference<Integer> atomicRef = client.atomicReference("atomicRef", 1, true);
final IgniteAtomicStamped<Integer, Integer> atomicStamped = client.atomicStamped("atomicStamped", 1, 1, true);
final IgniteCountDownLatch latch = client.countDownLatch("latch", 1, true, true);
代码示例来源:origin: apache/ignite
IgniteAtomicReference<String> atomicReference = ignite.atomicReference(atomicName, initValue, true);
代码示例来源:origin: apache/ignite
IgniteAtomicReference<String> clientAtomicRef = client.atomicReference("atomicRef", "1st value", true);
assertEquals("2st value", clientAtomicRef.get());
final IgniteAtomicReference<String> srvAtomicRef = srv.atomicReference("atomicRef", "1st value", false);
代码示例来源:origin: apache/ignite
client.atomicReference("atomicRefInProg", "1st value", true);
assertEquals("2st value", clientAtomicRef.get());
IgniteAtomicReference<String> srvAtomicRef = srv.atomicReference("atomicRefInProg", "1st value", false);
内容来源于网络,如有侵权,请联系作者删除!