use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class IgniteCacheClientQueryReplicatedNodeRestartSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
X.println("Ignite instance name: " + igniteInstanceName);
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
int i = 0;
CacheConfiguration<?, ?>[] ccs = new CacheConfiguration[4];
for (String name : F.asList("co", "pr", "pe", "pu")) {
CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
cc.setNodeFilter(DATA_NODES_FILTER);
cc.setName(name);
cc.setCacheMode(REPLICATED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setRebalanceMode(SYNC);
cc.setAffinity(new RendezvousAffinityFunction(false, 50));
switch(name) {
case "co":
cc.setIndexedTypes(Integer.class, Company.class);
break;
case "pr":
cc.setIndexedTypes(Integer.class, Product.class);
break;
case "pe":
cc.setIndexedTypes(Integer.class, Person.class);
break;
case "pu":
cc.setIndexedTypes(AffinityKey.class, Purchase.class);
break;
}
ccs[i++] = cc;
}
c.setCacheConfiguration(ccs);
return c;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class CrossCacheTxRandomOperationsTest method cacheConfiguration.
/**
* @param name Cache name.
* @param cacheMode Cache mode.
* @param writeSync Write synchronization mode.
* @param nearCache Near cache flag.
* @return Cache configuration.
*/
protected CacheConfiguration cacheConfiguration(String name, CacheMode cacheMode, CacheWriteSynchronizationMode writeSync, boolean nearCache) {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(name);
ccfg.setCacheMode(cacheMode);
ccfg.setAtomicityMode(TRANSACTIONAL);
ccfg.setWriteSynchronizationMode(writeSync);
if (cacheMode == PARTITIONED)
ccfg.setBackups(1);
ccfg.setAffinity(new RendezvousAffinityFunction());
if (nearCache)
ccfg.setNearConfiguration(new NearCacheConfiguration());
return ccfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction 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.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheColocatedDebugTest method getConfiguration.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(spi);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setNearConfiguration(null);
cacheCfg.setAffinity(new RendezvousAffinityFunction(false, 30));
cacheCfg.setBackups(1);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
if (storeEnabled) {
cacheCfg.setCacheStoreFactory(singletonFactory(new GridCacheTestStore()));
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
} else
cacheCfg.setCacheStoreFactory(null);
cfg.setCacheConfiguration(cacheCfg);
return cfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheRebalancingOrderingTest method getCacheConfiguration.
/**
* @return Cache configuration used by test.
* @see #getConfiguration().
*/
protected CacheConfiguration<IntegerKey, Integer> getCacheConfiguration() {
CacheConfiguration<IntegerKey, Integer> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cfg.setAtomicityMode(TRANSACTIONAL ? CacheAtomicityMode.TRANSACTIONAL : CacheAtomicityMode.ATOMIC);
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setName(TEST_CACHE_NAME);
cfg.setAffinity(new RendezvousAffinityFunction(true, /* machine-safe */
271));
cfg.setBackups(1);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cfg.setWriteSynchronizationMode(FULL_SYNC);
return cfg;
}
Aggregations