use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class GridCacheConcurrentTxMultiNodeTest 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();
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
c.setPeerClassLoadingEnabled(false);
return c;
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class SystemViewSelfTest method testAtomicSequence.
/**
*/
@Test
public void testAtomicSequence() throws Exception {
try (IgniteEx g0 = startGrid(0);
IgniteEx g1 = startGrid(1)) {
IgniteAtomicSequence s1 = g0.atomicSequence("seq-1", 42, true);
IgniteAtomicSequence s2 = g0.atomicSequence("seq-2", new AtomicConfiguration().setBackups(1).setGroupName("my-group"), 43, true);
s1.batchSize(42);
SystemView<AtomicSequenceView> seqs0 = g0.context().systemView().view(SEQUENCES_VIEW);
SystemView<AtomicSequenceView> seqs1 = g1.context().systemView().view(SEQUENCES_VIEW);
assertEquals(2, seqs0.size());
assertEquals(0, seqs1.size());
for (AtomicSequenceView s : seqs0) {
if ("seq-1".equals(s.name())) {
assertEquals(42, s.value());
assertEquals(42, s.batchSize());
assertEquals(DEFAULT_DS_GROUP_NAME, s.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), s.groupId());
long val = s1.addAndGet(42);
assertEquals(val, s.value());
assertFalse(s.removed());
} else {
assertEquals("seq-2", s.name());
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE, s.batchSize());
assertEquals(43, s.value());
assertEquals("my-group", s.groupName());
assertEquals(CU.cacheId("my-group"), s.groupId());
assertFalse(s.removed());
s2.close();
assertTrue(waitForCondition(s::removed, getTestTimeout()));
}
}
g1.atomicSequence("seq-1", 42, true);
assertEquals(1, seqs1.size());
AtomicSequenceView s = seqs1.iterator().next();
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE + 42, s.value());
assertEquals(DFLT_ATOMIC_SEQUENCE_RESERVE_SIZE, s.batchSize());
assertEquals(DEFAULT_DS_GROUP_NAME, s.groupName());
assertEquals(CU.cacheId(DEFAULT_DS_GROUP_NAME), s.groupId());
assertFalse(s.removed());
s1.close();
assertTrue(waitForCondition(s::removed, getTestTimeout()));
assertEquals(0, seqs0.size());
assertEquals(0, seqs1.size());
}
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class IgniteSequenceInternalCleanupTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setMetricsUpdateFrequency(10);
cfg.setActiveOnStart(false);
AtomicConfiguration atomicCfg = atomicConfiguration();
assertNotNull(atomicCfg);
cfg.setAtomicConfiguration(atomicCfg);
List<CacheConfiguration> cacheCfg = new ArrayList<>();
for (int i = 0; i < CACHES_CNT; i++) {
cacheCfg.add(new CacheConfiguration("test" + i).setStatisticsEnabled(true).setCacheMode(PARTITIONED).setAtomicityMode(TRANSACTIONAL).setAffinity(new RendezvousAffinityFunction(false, 16)));
}
cfg.setCacheConfiguration(cacheCfg.toArray(new CacheConfiguration[cacheCfg.size()]));
return cfg;
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class SemaphoreFailoverSafeReleasePermitsTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
AtomicConfiguration atomicCfg = atomicConfiguration();
assertNotNull(atomicCfg);
cfg.setAtomicConfiguration(atomicCfg);
return cfg;
}
use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.
the class SemaphoreFailoverSafeReleasePermitsTest method atomicConfiguration.
/**
* @return Atomic configuration.
*/
protected AtomicConfiguration atomicConfiguration() {
AtomicConfiguration atomicCfg = new AtomicConfiguration();
atomicCfg.setCacheMode(atomicsCacheMode);
if (atomicsCacheMode == PARTITIONED)
atomicCfg.setBackups(1);
return atomicCfg;
}
Aggregations