Search in sources :

Example 36 with NearCacheConfiguration

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

the class CacheEntryProcessorNonSerializableTest method testPessimisticOnePhaseCommitFullSyncWithNearCache.

/**
 * @throws Exception If failed.
 */
public void testPessimisticOnePhaseCommitFullSyncWithNearCache() throws Exception {
    CacheConfiguration ccfg = cacheConfiguration(FULL_SYNC, 1).setNearConfiguration(new NearCacheConfiguration());
    doTestInvokeTest(ccfg, PESSIMISTIC, READ_COMMITTED);
    doTestInvokeTest(ccfg, PESSIMISTIC, REPEATABLE_READ);
    doTestInvokeTest(ccfg, PESSIMISTIC, SERIALIZABLE);
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 37 with NearCacheConfiguration

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

the class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setWriteBehindEnabled(true);
    cc.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQ);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setNearConfiguration(new NearCacheConfiguration());
    CacheStore store = stores[idx.getAndIncrement()] = new GridCacheTestStore();
    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);
    c.setCacheConfiguration(cc);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheStore(org.apache.ignite.cache.store.CacheStore) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Example 38 with NearCacheConfiguration

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

the class JdbcThinDynamicIndexAbstractSelfTest method cacheConfig.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
CacheConfiguration cacheConfig() {
    CacheConfiguration ccfg = super.cacheConfig();
    ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    ccfg.setCacheMode(cacheMode());
    ccfg.setAtomicityMode(atomicityMode());
    if (nearCache())
        ccfg.setNearConfiguration(new NearCacheConfiguration());
    return ccfg;
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 39 with NearCacheConfiguration

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

the class IgniteCacheClientNodeChangingTopologyTest method optimisticSerializableTx.

/**
 * @param nearCfg Near cache configuration.
 * @throws Exception If failed.
 */
private void optimisticSerializableTx(NearCacheConfiguration nearCfg) throws Exception {
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setNearConfiguration(nearCfg);
    IgniteEx ignite0 = startGrid(0);
    IgniteEx ignite1 = startGrid(1);
    awaitPartitionMapExchange();
    client = true;
    final Ignite ignite2 = startGrid(2);
    assertTrue(ignite2.configuration().isClientMode());
    final Map<Integer, Integer> map = new HashMap<>();
    for (int i = 0; i < 100; i++) map.put(i, i);
    TestCommunicationSpi spi = (TestCommunicationSpi) ignite2.configuration().getCommunicationSpi();
    spi.blockMessages(GridNearTxPrepareRequest.class, ignite0.localNode().id());
    spi.blockMessages(GridNearTxPrepareRequest.class, ignite1.localNode().id());
    spi.record(GridNearTxPrepareRequest.class);
    final IgniteCache<Integer, Integer> cache = ignite2.cache(DEFAULT_CACHE_NAME);
    IgniteInternalFuture<?> putFut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Thread.currentThread().setName("put-thread");
            try (Transaction tx = ignite2.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) {
                cache.putAll(map);
                tx.commit();
            }
            return null;
        }
    });
    assertFalse(putFut.isDone());
    client = false;
    IgniteEx ignite3 = startGrid(3);
    awaitPartitionMapExchange();
    log.info("Stop block1.");
    spi.stopBlock();
    putFut.get();
    spi.record(null);
    checkData(map, null, cache, 4);
    List<Object> msgs = spi.recordedMessages();
    for (Object msg : msgs) assertTrue(((GridNearTxPrepareRequest) msg).firstClientRequest());
    assertEquals(5, msgs.size());
    ignite3.close();
    awaitPartitionMapExchange();
    for (int i = 0; i < 100; i++) map.put(i, i + 1);
    spi.blockMessages(GridNearTxPrepareRequest.class, ignite0.localNode().id());
    spi.blockMessages(GridNearTxPrepareRequest.class, ignite1.localNode().id());
    spi.record(GridNearTxPrepareRequest.class);
    putFut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Thread.currentThread().setName("put-thread");
            try (Transaction tx = ignite2.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) {
                for (Map.Entry<Integer, Integer> e : map.entrySet()) cache.put(e.getKey(), e.getValue());
                tx.commit();
            }
            return null;
        }
    });
    startGrid(3);
    awaitPartitionMapExchange();
    log.info("Stop block2.");
    spi.stopBlock();
    putFut.get();
    spi.record(null);
    msgs = spi.recordedMessages();
    for (Object msg : msgs) assertTrue(((GridNearTxPrepareRequest) msg).firstClientRequest());
    assertEquals(5, msgs.size());
    checkData(map, null, cache, 4);
    for (int i = 0; i < 100; i++) map.put(i, i + 2);
    try (Transaction tx = ignite2.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) {
        cache.putAll(map);
        tx.commit();
    }
    checkData(map, null, cache, 4);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TimeoutException(java.util.concurrent.TimeoutException) IgniteException(org.apache.ignite.IgniteException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) CacheException(javax.cache.CacheException) Callable(java.util.concurrent.Callable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) GridNearTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 40 with NearCacheConfiguration

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

the class IgniteCacheClientNodeChangingTopologyTest method atomicPut.

/**
 * @param putAll If {@code true} executes putAll.
 * @param nearCfg Near cache configuration.
 * @throws Exception If failed.
 */
private void atomicPut(final boolean putAll, @Nullable NearCacheConfiguration nearCfg) throws Exception {
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setBackups(1);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    IgniteEx ignite0 = startGrid(0);
    IgniteEx ignite1 = startGrid(1);
    ccfg.setNearConfiguration(nearCfg);
    client = true;
    ccfg.setNearConfiguration(null);
    Ignite ignite2 = startGrid(2);
    assertTrue(ignite2.configuration().isClientMode());
    final Map<Integer, Integer> map = new HashMap<>();
    final int KEYS = putAll ? 100 : 1;
    for (int i = 0; i < KEYS; i++) map.put(i, i);
    TestCommunicationSpi spi = (TestCommunicationSpi) ignite2.configuration().getCommunicationSpi();
    // Block messages requests for both nodes.
    spi.blockMessages(GridNearAtomicFullUpdateRequest.class, ignite0.localNode().id());
    spi.blockMessages(GridNearAtomicFullUpdateRequest.class, ignite1.localNode().id());
    final IgniteCache<Integer, Integer> cache = ignite2.cache(DEFAULT_CACHE_NAME);
    IgniteInternalFuture<?> putFut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Thread.currentThread().setName("put-thread");
            if (putAll)
                cache.putAll(map);
            else
                cache.put(0, 0);
            return null;
        }
    });
    assertFalse(putFut.isDone());
    client = false;
    IgniteEx ignite3 = startGrid(3);
    log.info("Stop block1.");
    spi.stopBlock();
    putFut.get();
    checkData(map, null, cache, 4);
    ignite3.close();
    map.clear();
    for (int i = 0; i < KEYS; i++) map.put(i, i + 1);
    // Block messages requests for single node.
    spi.blockMessages(GridNearAtomicFullUpdateRequest.class, ignite0.localNode().id());
    putFut = GridTestUtils.runAsync(new Callable<Object>() {

        @Override
        public Object call() throws Exception {
            Thread.currentThread().setName("put-thread");
            if (putAll)
                cache.putAll(map);
            else
                cache.put(0, 1);
            return null;
        }
    });
    assertFalse(putFut.isDone());
    client = false;
    startGrid(3);
    log.info("Stop block2.");
    spi.stopBlock();
    putFut.get();
    checkData(map, null, cache, 4);
    for (int i = 0; i < KEYS; i++) map.put(i, i + 2);
    if (putAll)
        cache.putAll(map);
    else
        cache.put(0, 2);
    checkData(map, null, cache, 4);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TimeoutException(java.util.concurrent.TimeoutException) IgniteException(org.apache.ignite.IgniteException) IgniteSpiException(org.apache.ignite.spi.IgniteSpiException) CacheException(javax.cache.CacheException) Callable(java.util.concurrent.Callable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)158 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)121 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)50 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)41 Ignite (org.apache.ignite.Ignite)37 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 IgniteCache (org.apache.ignite.IgniteCache)12 CacheException (javax.cache.CacheException)11 IgniteEx (org.apache.ignite.internal.IgniteEx)9 Transaction (org.apache.ignite.transactions.Transaction)9 ArrayList (java.util.ArrayList)8 IgniteException (org.apache.ignite.IgniteException)8 HashMap (java.util.HashMap)7 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)7 LinkedHashMap (java.util.LinkedHashMap)6 Callable (java.util.concurrent.Callable)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)6 QuerySchema (org.apache.ignite.internal.processors.query.QuerySchema)6 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)6