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