Search in sources :

Example 41 with AtomicConfiguration

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

Example 42 with AtomicConfiguration

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;
}
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)

Example 43 with AtomicConfiguration

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;
}
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