use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class IgniteCacheInvokeReadThroughAbstractTest method cacheConfiguration.
/**
* @param cacheMode Cache mode.
* @param atomicityMode Atomicity mode.
* @param backups Number of backups.
* @param nearCache Near cache flag.
* @return Cache configuration.
*/
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(CacheMode cacheMode, CacheAtomicityMode atomicityMode, int backups, boolean nearCache) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setReadThrough(true);
ccfg.setWriteThrough(true);
ccfg.setCacheStoreFactory(cacheStoreFactory());
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
if (nearCache)
ccfg.setNearConfiguration(new NearCacheConfiguration());
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
return ccfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheObjectToStringSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(cacheMode);
cacheCfg.setEvictionPolicy(evictionPlc);
cacheCfg.setOnheapCacheEnabled(true);
cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);
cacheCfg.setAtomicityMode(TRANSACTIONAL);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class GridCacheNearTxForceKeyTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setRebalanceMode(ASYNC);
ccfg.setRebalanceDelay(5000);
ccfg.setBackups(0);
ccfg.setNearConfiguration(new NearCacheConfiguration());
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class IgniteCacheConfigVariationsAbstractTest method startCachesDinamically.
/**
* Starts caches dynamically.
*
* @throws Exception If failed.
*/
private void startCachesDinamically() throws Exception {
for (int i = 0; i < gridCount(); i++) {
info("Starting cache dinamically on grid: " + i);
IgniteEx grid = grid(i);
if (i != CLIENT_NODE_IDX && i != CLIENT_NEAR_ONLY_IDX) {
CacheConfiguration cc = cacheConfiguration();
cc.setName(cacheName());
grid.getOrCreateCache(cc);
}
if (testsCfg.withClients() && i == CLIENT_NEAR_ONLY_IDX && grid(i).configuration().isClientMode())
grid(CLIENT_NEAR_ONLY_IDX).createNearCache(cacheName(), new NearCacheConfiguration());
}
awaitPartitionMapExchange();
for (int i = 0; i < gridCount(); i++) assertNotNull(jcache(i));
for (int i = 0; i < gridCount(); i++) assertEquals("Cache is not empty [idx=" + i + ", entrySet=" + jcache(i).localEntries() + ']', 0, jcache(i).localSize(CachePeekMode.ALL));
}
use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.
the class ConfigVariations method nearCacheConfigurationFactory.
/**
* @return Custom near cache config.
*/
private static Factory nearCacheConfigurationFactory() {
return new Factory() {
@Override
public Object create() {
NearCacheConfiguration cfg = new NearCacheConfiguration<>();
cfg.setNearEvictionPolicy(new FifoEvictionPolicy());
return cfg;
}
};
}
Aggregations