use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheNearTxMultiNodeSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
// Default cache configuration.
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
cacheCfg.setNearConfiguration(new NearCacheConfiguration());
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
cacheCfg.setBackups(backups);
cacheCfg.setRebalanceMode(SYNC);
cfg.setCacheConfiguration(cacheCfg);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(spi);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheNearTxPreloadSelfTest method cacheConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);
cfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setBackups(4);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCachePartitionedBasicApiTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setBackups(1);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
cacheCfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCachePartitionedEventSelfTest method cacheConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cfg = defaultCacheConfiguration();
cfg.setCacheMode(PARTITIONED);
cfg.setBackups(gridCount() - 1);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cfg.setAtomicityMode(TRANSACTIONAL);
cfg.setNearConfiguration(new NearCacheConfiguration());
// Setting preload mode to SYNC is necessary due to race condition with test scenario in ASYNC mode.
// In ASYNC mode preloader can fetch value from previous test and update it before next test run.
// As a result test will see previous value while it expects null
cfg.setRebalanceMode(SYNC);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class IgniteCacheNearLockValueSelfTest method testDhtVersion.
/**
* @throws Exception If failed.
*/
public void testDhtVersion() throws Exception {
CacheConfiguration<Object, Object> pCfg = new CacheConfiguration<>("partitioned");
pCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
try (IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache(pCfg, new NearCacheConfiguration<>())) {
cache.put("key1", "val1");
for (int i = 0; i < 3; i++) {
try (Transaction tx = ignite(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
cache.get("key1");
tx.commit();
}
TestRecordingCommunicationSpi comm = (TestRecordingCommunicationSpi) ignite(0).configuration().getCommunicationSpi();
Collection<GridNearLockRequest> reqs = (Collection) comm.recordedMessages(false);
assertEquals(1, reqs.size());
GridCacheAdapter<Object, Object> primary = ((IgniteKernal) grid(1)).internalCache("partitioned");
GridCacheEntryEx dhtEntry = primary.peekEx(primary.context().toCacheKeyObject("key1"));
assertNotNull(dhtEntry);
GridNearLockRequest req = reqs.iterator().next();
assertEquals(dhtEntry.version(), req.dhtVersion(0));
// Check entry version in near cache after commit.
GridCacheAdapter<Object, Object> near = ((IgniteKernal) grid(0)).internalCache("partitioned");
GridNearCacheEntry nearEntry = (GridNearCacheEntry) near.peekEx(near.context().toCacheKeyObject("key1"));
assertNotNull(nearEntry);
assertEquals(dhtEntry.version(), nearEntry.dhtVersion());
}
}
}
Aggregations