use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class SystemViewSelfTest method testAtomicReference.
/**
*/
@Test
public void testAtomicReference() throws Exception {
try (IgniteEx g0 = startGrid(0);
IgniteEx g1 = startGrid(1)) {
IgniteAtomicReference<String> l1 = g0.atomicReference("ref-1", "str1", true);
IgniteAtomicReference<Integer> l2 = g0.atomicReference("ref-2", new AtomicConfiguration().setBackups(1).setGroupName("my-group"), 43, true);
SystemView<AtomicReferenceView> refs0 = g0.context().systemView().view(REFERENCES_VIEW);
SystemView<AtomicReferenceView> refs1 = g1.context().systemView().view(REFERENCES_VIEW);
assertEquals(2, refs0.size());
assertEquals(0, refs1.size());
for (AtomicReferenceView r : refs0) {
if ("ref-1".equals(r.name())) {
assertEquals("str1", r.value());
assertEquals(DEFAULT_DS_GROUP_NAME, r.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), r.groupId());
l1.set("str2");
assertEquals("str2", r.value());
assertFalse(r.removed());
} else {
assertEquals("ref-2", r.name());
assertEquals("43", r.value());
assertEquals("my-group", r.groupName());
assertEquals(CU.cacheId("my-group"), r.groupId());
assertFalse(r.removed());
l2.close();
assertTrue(waitForCondition(r::removed, getTestTimeout()));
}
}
g1.atomicReference("ref-1", "str3", true);
assertEquals(1, refs1.size());
AtomicReferenceView l = refs1.iterator().next();
assertEquals("str2", l.value());
assertEquals(DEFAULT_DS_GROUP_NAME, l.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), l.groupId());
assertFalse(l.removed());
l1.close();
assertTrue(waitForCondition(l::removed, getTestTimeout()));
assertEquals(0, refs0.size());
assertEquals(0, refs1.size());
}
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class GridCacheConcurrentTxMultiNodeLoadTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
AtomicConfiguration atomicCfg = new AtomicConfiguration();
atomicCfg.setAtomicSequenceReserveSize(100000);
atomicCfg.setCacheMode(mode);
c.setAtomicConfiguration(atomicCfg);
if (cacheOn) {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(mode);
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(1000);
cc.setEvictionPolicy(plc);
cc.setOnheapCacheEnabled(true);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setRebalanceMode(NONE);
c.setCacheConfiguration(cc);
} else
c.setCacheConfiguration();
c.setPeerClassLoadingEnabled(false);
return c;
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class IgniteAtomicSequenceAbstractBenchmark method setUp.
/**
* {@inheritDoc}
*/
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
int batchSize = args.batch();
int backups = args.backups();
AtomicConfiguration acfg = new AtomicConfiguration();
acfg.setAtomicSequenceReserveSize(batchSize);
acfg.setBackups(backups);
seq = ignite().atomicSequence("benchSequence", acfg, 0, true);
randomBound = batchSize < 10 ? 1 : batchSize / 10;
}
Aggregations