use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteClientAffinityAssignmentSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
if (cache) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(1);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setNearConfiguration(null);
ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
cfg.setCacheConfiguration(ccfg);
} else
cfg.setClientMode(true);
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class IgniteCacheTopologySafeGetSelfTest method cacheCfg.
/**
* @param name Cache name.
* @param cacheMode Cache mode.
* @param near Near enabled flag.
* @return Cache configuration.
*/
@SuppressWarnings("unchecked")
private CacheConfiguration cacheCfg(String name, CacheAtomicityMode cacheMode, boolean near) {
CacheConfiguration cfg = new CacheConfiguration(name);
cfg.setAtomicityMode(cacheMode);
cfg.setBackups(1);
if (near)
cfg.setNearConfiguration(new NearCacheConfiguration());
else
cfg.setNearConfiguration(null);
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheAbstractDataStructuresFailoverSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
AtomicConfiguration atomicCfg = new AtomicConfiguration();
atomicCfg.setCacheMode(collectionCacheMode());
atomicCfg.setBackups(collectionConfiguration().getBackups());
cfg.setAtomicConfiguration(atomicCfg);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(TRANSACTIONAL_CACHE_NAME);
ccfg.setAtomicityMode(TRANSACTIONAL);
cfg.setCacheConfiguration(ccfg);
if (client) {
cfg.setClientMode(client);
((TcpDiscoverySpi) (cfg.getDiscoverySpi())).setForceServerMode(true);
}
return cfg;
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheAtomicReferenceApiSelfAbstractTest method testIsolation.
/**
* Implementation of ignite data structures internally uses special system caches, need make sure
* that transaction on these system caches do not intersect with transactions started by user.
*
* @throws Exception If failed.
*/
public void testIsolation() throws Exception {
Ignite ignite = grid(0);
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setName("myCache");
cfg.setAtomicityMode(TRANSACTIONAL);
cfg.setWriteSynchronizationMode(FULL_SYNC);
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cfg);
try {
String atomicName = UUID.randomUUID().toString();
String initValue = "qazwsx";
IgniteAtomicReference<String> atomicReference = ignite.atomicReference(atomicName, initValue, true);
try (Transaction tx = ignite.transactions().txStart()) {
cache.put(1, 1);
assertEquals(initValue, atomicReference.get());
assertTrue(atomicReference.compareAndSet(initValue, "aaa"));
assertEquals("aaa", atomicReference.get());
tx.rollback();
assertEquals(0, cache.size());
}
assertTrue(atomicReference.compareAndSet("aaa", null));
assertNull(atomicReference.get());
atomicReference.close();
assertTrue(atomicReference.removed());
} finally {
ignite.destroyCache(cfg.getName());
}
}
use of org.apache.ignite.configuration.CacheConfiguration in project ignite by apache.
the class GridCacheAtomicStampedApiSelfAbstractTest method testIsolation.
/**
* @throws Exception If failed.
*/
public void testIsolation() throws Exception {
Ignite ignite = grid(0);
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setName("MyCache");
cfg.setAtomicityMode(TRANSACTIONAL);
cfg.setWriteSynchronizationMode(FULL_SYNC);
IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(cfg);
try {
String atomicName = UUID.randomUUID().toString();
String initVal = "qwerty";
String initStamp = "asdf";
IgniteAtomicStamped<String, String> atomicStamped = ignite.atomicStamped(atomicName, initVal, initStamp, true);
try (Transaction tx = ignite.transactions().txStart()) {
cache.put(1, 1);
assertEquals(initVal, atomicStamped.value());
assertEquals(initStamp, atomicStamped.stamp());
assertEquals(initVal, atomicStamped.get().get1());
assertEquals(initStamp, atomicStamped.get().get2());
assertTrue(atomicStamped.compareAndSet(initVal, "b", initStamp, "d"));
tx.rollback();
}
assertEquals(0, cache.size());
assertEquals("b", atomicStamped.value());
assertEquals("d", atomicStamped.stamp());
atomicStamped.close();
assertTrue(atomicStamped.removed());
} finally {
ignite.destroyCache(cfg.getName());
}
}
Aggregations