Search in sources :

Example 1 with AtomicConfiguration

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 2 with AtomicConfiguration

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());
    }
}
Also used : AtomicSequenceView(org.apache.ignite.spi.systemview.view.datastructures.AtomicSequenceView) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteAtomicSequence(org.apache.ignite.IgniteAtomicSequence) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Example 3 with AtomicConfiguration

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ArrayList(java.util.ArrayList) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with AtomicConfiguration

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 5 with AtomicConfiguration

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;
}
Also used : AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Aggregations

AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)43 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)14 Test (org.junit.Test)11 Ignite (org.apache.ignite.Ignite)7 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)7 IgniteAtomicSequence (org.apache.ignite.IgniteAtomicSequence)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)5 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)4 HashMap (java.util.HashMap)3 IgniteAtomicLong (org.apache.ignite.IgniteAtomicLong)3 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)3 LinkedHashMap (java.util.LinkedHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 ExecutorConfiguration (org.apache.ignite.configuration.ExecutorConfiguration)2 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)2 NoOpFailureHandler (org.apache.ignite.failure.NoOpFailureHandler)2