Search in sources :

Example 21 with AtomicConfiguration

use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.

the class GridCacheSequenceApiSelfAbstractTest method atomicConfiguration.

/**
 * {@inheritDoc}
 */
protected AtomicConfiguration atomicConfiguration() {
    AtomicConfiguration atomicCfg = super.atomicConfiguration();
    atomicCfg.setAtomicSequenceReserveSize(BATCH_SIZE);
    return atomicCfg;
}
Also used : AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 22 with AtomicConfiguration

use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.

the class IgniteAtomicLongApiAbstractSelfTest method testMultipleStructuresInDifferentGroups.

/**
 * Tests that basic API works correctly when there are multiple structures in multiple groups.
 *
 * @throws Exception If failed.
 */
public void testMultipleStructuresInDifferentGroups() throws Exception {
    Ignite ignite = grid(0);
    AtomicConfiguration cfg = new AtomicConfiguration().setGroupName("grp1");
    IgniteAtomicLong atomic1 = ignite.atomicLong("atomic1", 1, true);
    IgniteAtomicLong atomic2 = ignite.atomicLong("atomic2", 2, true);
    IgniteAtomicLong atomic3 = ignite.atomicLong("atomic3", cfg, 3, true);
    IgniteAtomicLong atomic4 = ignite.atomicLong("atomic4", cfg, 4, true);
    assertNull(ignite.atomicLong("atomic1", cfg, 1, false));
    assertNull(ignite.atomicLong("atomic2", cfg, 2, false));
    assertNull(ignite.atomicLong("atomic3", 3, false));
    assertNull(ignite.atomicLong("atomic4", 4, false));
    assertTrue(atomic1.compareAndSet(1, 11));
    assertTrue(atomic2.compareAndSet(2, 12));
    assertTrue(atomic3.compareAndSet(3, 13));
    assertTrue(atomic4.compareAndSet(4, 14));
    assertFalse(atomic1.compareAndSet(1, 0));
    assertFalse(atomic2.compareAndSet(2, 0));
    assertFalse(atomic3.compareAndSet(3, 0));
    assertFalse(atomic4.compareAndSet(4, 0));
    atomic2.close();
    atomic4.close();
    assertTrue(atomic2.removed());
    assertTrue(atomic4.removed());
    assertNull(ignite.atomicLong("atomic2", 2, false));
    assertNull(ignite.atomicLong("atomic4", cfg, 4, false));
    assertFalse(atomic1.removed());
    assertFalse(atomic3.removed());
    assertNotNull(ignite.atomicLong("atomic1", 1, false));
    assertNotNull(ignite.atomicLong("atomic3", cfg, 3, false));
}
Also used : IgniteAtomicLong(org.apache.ignite.IgniteAtomicLong) Ignite(org.apache.ignite.Ignite) AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 23 with AtomicConfiguration

use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.

the class IgniteAtomicsAbstractTest method atomicConfiguration.

/**
 * @return Atomic configuration.
 */
protected AtomicConfiguration atomicConfiguration() {
    AtomicConfiguration atomicCfg = new AtomicConfiguration();
    atomicCfg.setCacheMode(atomicsCacheMode());
    return atomicCfg;
}
Also used : AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 24 with AtomicConfiguration

use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.

the class GridCachePartitionedAtomicSequenceMultiThreadedTest method atomicConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected AtomicConfiguration atomicConfiguration() {
    AtomicConfiguration cfg = super.atomicConfiguration();
    cfg.setBackups(1);
    cfg.setAtomicSequenceReserveSize(10);
    return cfg;
}
Also used : AtomicConfiguration(org.apache.ignite.configuration.AtomicConfiguration)

Example 25 with AtomicConfiguration

use of org.apache.ignite.configuration.AtomicConfiguration in project ignite by apache.

the class GridCachePartitionedAtomicLongLoadTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    AtomicConfiguration atomicCfg = new AtomicConfiguration();
    atomicCfg.setCacheMode(PARTITIONED);
    atomicCfg.setBackups(1);
    atomicCfg.setAtomicSequenceReserveSize(10);
    c.setAtomicConfiguration(atomicCfg);
    c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
    c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setRebalanceMode(CacheRebalanceMode.SYNC);
    cc.setWriteSynchronizationMode(FULL_SYNC);
    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(1000);
    cc.setEvictionPolicy(plc);
    cc.setOnheapCacheEnabled(true);
    cc.setBackups(1);
    cc.setAffinity(new RendezvousAffinityFunction(true));
    c.setCacheConfiguration(cc);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) 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)

Aggregations

AtomicConfiguration (org.apache.ignite.configuration.AtomicConfiguration)29 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)10 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)9 Ignite (org.apache.ignite.Ignite)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)5 TcpCommunicationSpi (org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)5 IgniteAtomicSequence (org.apache.ignite.IgniteAtomicSequence)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 IgniteAtomicLong (org.apache.ignite.IgniteAtomicLong)2 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)2 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 TransactionConfiguration (org.apache.ignite.configuration.TransactionConfiguration)2 PlatformDotNetBinaryConfiguration (org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration)2 NoopEventStorageSpi (org.apache.ignite.spi.eventstorage.NoopEventStorageSpi)2 MemoryEventStorageSpi (org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi)2 Serializable (java.io.Serializable)1 Map (java.util.Map)1 IgniteException (org.apache.ignite.IgniteException)1