use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheRendezvousAffinityClientSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setForceServerMode(true);
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(1);
ccfg.setAffinity(new RendezvousAffinityFunction());
if (client)
cfg.setClientMode(true);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class IgniteCacheConfigurationTemplateTest method testTemplateCleanup.
/**
* @throws Exception If failed.
*/
public void testTemplateCleanup() throws Exception {
startGridsMultiThreaded(3);
try {
CacheConfiguration ccfg = new CacheConfiguration("affTemplate-*");
ccfg.setAffinity(new RendezvousAffinityFunction());
ignite(0).addCacheConfiguration(ccfg);
ignite(0).getOrCreateCache("affTemplate-1");
IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache("affTemplate-2");
ignite(0).destroyCache("affTemplate-1");
startGrid(3);
cache.put(1, 1);
assertEquals(1, cache.get(1));
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class HibernateL2CacheSelfTest method generalRegionConfiguration.
/**
* @param regionName Region name.
* @return Cache configuration for {@link GeneralDataRegion}.
*/
private CacheConfiguration generalRegionConfiguration(String regionName) {
CacheConfiguration cfg = new CacheConfiguration();
cfg.setName(regionName);
cfg.setCacheMode(PARTITIONED);
cfg.setAtomicityMode(ATOMIC);
cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setBackups(1);
cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
return cfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheConfigurationValidationSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(spi);
// Default cache config.
CacheConfiguration dfltCacheCfg = defaultCacheConfiguration();
dfltCacheCfg.setCacheMode(PARTITIONED);
dfltCacheCfg.setRebalanceMode(ASYNC);
dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
dfltCacheCfg.setAffinity(new RendezvousAffinityFunction());
dfltCacheCfg.setIndexedTypes(Integer.class, String.class);
// Non-default cache configuration.
CacheConfiguration namedCacheCfg = defaultCacheConfiguration();
namedCacheCfg.setCacheMode(PARTITIONED);
namedCacheCfg.setRebalanceMode(ASYNC);
namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
namedCacheCfg.setAffinity(new RendezvousAffinityFunction());
// Modify cache config according to test parameters.
if (igniteInstanceName.contains(WRONG_PRELOAD_MODE_IGNITE_INSTANCE_NAME))
dfltCacheCfg.setRebalanceMode(SYNC);
else if (igniteInstanceName.contains(WRONG_CACHE_MODE_IGNITE_INSTANCE_NAME))
dfltCacheCfg.setCacheMode(REPLICATED);
else if (igniteInstanceName.contains(WRONG_AFFINITY_IGNITE_INSTANCE_NAME))
dfltCacheCfg.setAffinity(new TestRendezvousAffinityFunction());
else if (igniteInstanceName.contains(WRONG_AFFINITY_MAPPER_IGNITE_INSTANCE_NAME))
dfltCacheCfg.setAffinityMapper(new TestCacheDefaultAffinityKeyMapper());
if (igniteInstanceName.contains(DUP_CACHES_IGNITE_INSTANCE_NAME))
cfg.setCacheConfiguration(namedCacheCfg, namedCacheCfg);
else if (igniteInstanceName.contains(DUP_DFLT_CACHES_IGNITE_INSTANCE_NAME))
cfg.setCacheConfiguration(dfltCacheCfg, dfltCacheCfg);
else
// Normal configuration.
cfg.setCacheConfiguration(dfltCacheCfg, namedCacheCfg);
return cfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheConfigurationConsistencySelfTest method testAffinityForReplicatedCache.
/**
* @throws Exception If failed.
*/
public void testAffinityForReplicatedCache() throws Exception {
cacheEnabled = true;
aff = new RendezvousAffinityFunction(false, 100);
startGrid(1);
// Try to start node with different number of partitions.
aff = new RendezvousAffinityFunction(false, 200);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws Exception {
return startGrid(2);
}
}, IgniteCheckedException.class, "Affinity partitions count mismatch");
}
Aggregations