use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class CacheExchangeMessageDuplicatedStateTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
cfg.setClientMode(client);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
commSpi.record(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode node, Message msg) {
return (msg.getClass() == GridDhtPartitionsSingleMessage.class || msg.getClass() == GridDhtPartitionsFullMessage.class) && ((GridDhtPartitionsAbstractMessage) msg).exchangeId() != null;
}
});
cfg.setCommunicationSpi(commSpi);
List<CacheConfiguration> ccfgs = new ArrayList<>();
{
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(AFF1_CACHE1);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 512));
ccfgs.add(ccfg);
}
{
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(AFF1_CACHE2);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 512));
ccfgs.add(ccfg);
}
{
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(AFF3_CACHE1);
ccfg.setBackups(3);
RendezvousAffinityFunction aff = new RendezvousAffinityFunction(false, 64);
ccfg.setAffinity(aff);
ccfgs.add(ccfg);
}
{
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(AFF4_FILTER_CACHE1);
ccfg.setNodeFilter(new TestNodeFilter());
ccfg.setAffinity(new RendezvousAffinityFunction());
ccfgs.add(ccfg);
}
{
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(AFF4_FILTER_CACHE2);
ccfg.setNodeFilter(new TestNodeFilter());
ccfg.setAffinity(new RendezvousAffinityFunction());
ccfgs.add(ccfg);
}
cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
return cfg;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class AtomicCacheAffinityConfigurationTest method testRendezvousAffinity.
/**
* @throws Exception If failed.
*
*/
public void testRendezvousAffinity() throws Exception {
try {
affinityFunction = new RendezvousAffinityFunction(false, 10);
startGrids(3);
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);
CacheConfiguration cConf = igniteEx.context().cache().cache("ignite-atomics-sys-cache").configuration();
AffinityFunction aff = cConf.getAffinity();
assertNotNull(aff);
assertEquals(aff.partitions(), affinityFunction.partitions());
assertEquals(aff.getClass(), affinityFunction.getClass());
}
checkAtomics();
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class GridCacheDhtPreloadUnloadSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
cc.setRebalanceBatchSize(preloadBatchSize);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setRebalanceMode(preloadMode);
cc.setAffinity(new RendezvousAffinityFunction(false, partitions));
cc.setBackups(backups);
cc.setAtomicityMode(TRANSACTIONAL);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
if (lbean != null)
c.setLifecycleBeans(lbean);
c.setDiscoverySpi(disco);
c.setCacheConfiguration(cc);
c.setDeploymentMode(CONTINUOUS);
c.setNetworkTimeout(netTimeout);
return c;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class IgniteCacheAbstractQuerySelfTest method cacheConfiguration.
/**
* @return cache configuration
*/
protected CacheConfiguration cacheConfiguration() {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(cacheMode());
cc.setAtomicityMode(atomicityMode());
cc.setNearConfiguration(nearCacheConfiguration());
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setCacheStoreFactory(new StoreFactory());
cc.setReadThrough(true);
cc.setWriteThrough(true);
cc.setLoadPreviousValue(true);
cc.setRebalanceMode(SYNC);
cc.setSqlFunctionClasses(SqlFunctions.class);
List<QueryEntity> entityList = new ArrayList<>();
QueryEntity qryEntity = new QueryEntity();
qryEntity.setKeyType(Integer.class.getName());
qryEntity.setValueType(Type1.class.getName());
qryEntity.addQueryField("id", Integer.class.getName(), null);
qryEntity.addQueryField("name", String.class.getName(), null);
qryEntity.setTableName("Type2");
qryEntity.setIndexes(Arrays.asList(new QueryIndex("id")));
entityList.add(qryEntity);
qryEntity = new QueryEntity();
qryEntity.setKeyType(Integer.class.getName());
qryEntity.setValueType(Type2.class.getName());
qryEntity.addQueryField("id", Integer.class.getName(), null);
qryEntity.addQueryField("name", String.class.getName(), null);
qryEntity.setTableName("Type1");
qryEntity.setIndexes(Arrays.asList(new QueryIndex("id")));
entityList.add(qryEntity);
qryEntity = new QueryEntity();
qryEntity.setKeyType(Integer.class.getName());
qryEntity.setValueType(ObjectValue2.class.getName());
qryEntity.addQueryField("strVal", String.class.getName(), null);
// Default index type
final QueryIndex strIdx = new QueryIndex();
strIdx.setFieldNames(Collections.singletonList("strVal"), true);
qryEntity.setIndexes(Arrays.asList(strIdx));
entityList.add(qryEntity);
cc.setQueryEntities(entityList);
if (cacheMode() != CacheMode.LOCAL)
cc.setAffinity(new RendezvousAffinityFunction());
// Explicitly set number of backups equal to number of grids.
if (cacheMode() == CacheMode.PARTITIONED)
cc.setBackups(gridCount());
return cc;
}
use of org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction in project ignite by apache.
the class IgniteCacheQueryNodeRestartSelfTest2 method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
MemoryConfiguration memCfg = new MemoryConfiguration().setDefaultMemoryPolicySize(50 * 1024 * 1024);
c.setMemoryConfiguration(memCfg);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
int i = 0;
CacheConfiguration<?, ?>[] ccs = new CacheConfiguration[4];
for (String name : F.asList("pe", "pu")) {
CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
cc.setName(name);
cc.setCacheMode(PARTITIONED);
cc.setBackups(2);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setRebalanceMode(SYNC);
cc.setAffinity(new RendezvousAffinityFunction(false, 60));
if (name.equals("pe")) {
cc.setIndexedTypes(Integer.class, Person.class);
} else if (name.equals("pu")) {
cc.setIndexedTypes(AffinityKey.class, Purchase.class);
}
ccs[i++] = cc;
}
for (String name : F.asList("co", "pr")) {
CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
cc.setName(name);
cc.setCacheMode(REPLICATED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setRebalanceMode(SYNC);
cc.setAffinity(new RendezvousAffinityFunction(false, 50));
if (name.equals("co")) {
cc.setIndexedTypes(Integer.class, Company.class);
} else if (name.equals("pr")) {
cc.setIndexedTypes(Integer.class, Product.class);
}
ccs[i++] = cc;
}
c.setCacheConfiguration(ccs);
return c;
}
Aggregations