本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setAffinity方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setAffinity方法的具体用法?Java CacheConfiguration.setAffinity怎么用?Java CacheConfiguration.setAffinity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setAffinity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cacheConfig
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** */
@SuppressWarnings("unchecked")
private CacheConfiguration cacheConfig(String cacheName) {
CacheConfiguration ccfg = new CacheConfiguration<>(cacheName);
ccfg.setCacheMode(cacheMode);
ccfg.setBackups(backups);
ccfg.setAtomicityMode(atomicityMode());
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 1));
ccfg.setReadThrough(true);
ccfg.setReadFromBackup(true);
ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(TestStore.class));
if (near)
ccfg.setNearConfiguration(new NearCacheConfiguration());
return ccfg;
}
示例2: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration() {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setName(CACHE_NAME);
cc.setAtomicityMode(atomicityMode());
cc.setCacheMode(PARTITIONED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setNearConfiguration(null);
cc.setRebalanceMode(rebalancMode);
cc.setRebalanceBatchSize(rebalancBatchSize);
cc.setAffinity(new RendezvousAffinityFunction(false, partitions));
cc.setBackups(backups);
return cc;
}
示例3: randomCacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param rnd Random generator.
* @param name Cache name.
* @param srvs Server nodes.
* @param srvIdx Current servers index.
* @return Cache configuration.
*/
private CacheConfiguration randomCacheConfiguration(Random rnd, String name, List<String> srvs, int srvIdx) {
CacheConfiguration ccfg = cacheConfiguration();
ccfg.setAtomicityMode(rnd.nextBoolean() ? TRANSACTIONAL : ATOMIC);
ccfg.setBackups(rnd.nextInt(10));
ccfg.setRebalanceMode(rnd.nextBoolean() ? SYNC : ASYNC);
ccfg.setAffinity(affinityFunction(rnd.nextInt(2048) + 10));
if (rnd.nextBoolean()) {
Set<String> exclude = new HashSet<>();
for (int i = 0; i < 10; i++) {
if (i % 2 == 0 && srvs.size() > 0)
exclude.add(srvs.get(rnd.nextInt(srvs.size())));
else
exclude.add("server-" + (srvIdx + rnd.nextInt(10)));
}
ccfg.setNodeFilter(new TestCacheNodeExcludingFilter(exclude));
}
ccfg.setName(name);
return ccfg;
}
示例4: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
CacheConfiguration<?, ?> cc = defaultCacheConfiguration();
cc.setCacheMode(PARTITIONED);
cc.setBackups(1);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setRebalanceMode(SYNC);
cc.setAffinity(new RendezvousAffinityFunction(false, 15));
cc.setIndexedTypes(
Integer.class, Integer.class
);
c.setCacheConfiguration(cc);
return c;
}
示例5: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration() {
CacheConfiguration cc = defaultCacheConfiguration();
cc.setName(CACHE_NAME);
cc.setCacheMode(PARTITIONED);
cc.setWriteSynchronizationMode(FULL_SYNC);
cc.setRebalanceMode(rebalancMode);
cc.setRebalanceBatchSize(rebalancBatchSize);
cc.setAffinity(new RendezvousAffinityFunction(false, partitions));
cc.setBackups(backups);
cc.setNearConfiguration(nearEnabled() ? new NearCacheConfiguration() : null);
return cc;
}
示例6: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
final IgniteConfiguration cfg = super.getConfiguration(gridName);
final CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
ccfg.setIndexedTypes(Integer.class, IndexedObject.class);
cfg.setCacheConfiguration(ccfg);
cfg.setIncludeEventTypes(EventType.EVT_WAL_SEGMENT_ARCHIVED);
DataStorageConfiguration memCfg = new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(
new DataRegionConfiguration().setMaxSize(1024 * 1024 * 1024).setPersistenceEnabled(true))
.setPageSize(PAGE_SIZE)
.setWalHistorySize(1)
.setWalSegmentSize(1024 * 1024)
.setWalSegments(WAL_SEGMENTS)
.setWalMode(customWalMode != null ? customWalMode : WALMode.BACKGROUND);
if (archiveIncompleteSegmentAfterInactivityMs > 0)
memCfg.setWalAutoArchiveAfterInactivity(archiveIncompleteSegmentAfterInactivityMs);
cfg.setDataStorageConfiguration(memCfg);
return cfg;
}
示例7: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration ccfg = new CacheConfiguration(cacheName);
ccfg.setAffinity(new RendezvousAffinityFunction(true, 1));
ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
cfg.setCacheConfiguration(ccfg);
DataStorageConfiguration memCfg = new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(
new DataRegionConfiguration()
.setMaxSize(1024 * 1024 * 1024)
.setPersistenceEnabled(true)
.setName(policyName))
.setWalMode(WALMode.LOG_ONLY)
.setCheckpointFrequency(500)
.setAlwaysWriteFullPages(true);
cfg.setDataStorageConfiguration(memCfg);
cfg.setDiscoverySpi(
new TcpDiscoverySpi()
.setIpFinder(ipFinder)
);
return cfg;
}
示例8: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
CacheConfiguration cfg = super.cacheConfiguration(igniteInstanceName);
cfg.setAffinity(new RendezvousAffinityFunction());
return cfg;
}
示例9: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @return Cache configuration.
*/
protected CacheConfiguration cacheConfiguration() {
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setRebalanceMode(SYNC);
cacheCfg.setAffinity(new RendezvousAffinityFunction(false, 10));
cacheCfg.setBackups(0);
return cacheCfg;
}
示例10: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Gets cache configuration for grid with given name.
*
* @param igniteInstanceName Ignite instance name.
* @return Cache configuration.
*/
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) {
CacheConfiguration cacheCfg = defaultCacheConfiguration();
cacheCfg.setCacheMode(PARTITIONED);
cacheCfg.setRebalanceBatchSize(preloadBatchSize);
cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
cacheCfg.setRebalanceMode(preloadMode);
cacheCfg.setAffinity(new RendezvousAffinityFunction(false, partitions));
cacheCfg.setBackups(backups);
cacheCfg.setOnheapCacheEnabled(onheapCacheEnabled());
return cacheCfg;
}
示例11: cacheRandom
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Configure cacheCountry.
*/
private static <K, V> CacheConfiguration<K, V> cacheRandom() {
CacheConfiguration<K, V> ccfg = new CacheConfiguration<>(RANDOM_CACHE_NAME);
ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
ccfg.setQueryDetailMetricsSize(10);
ccfg.setStatisticsEnabled(true);
ccfg.setIndexedTypes(Integer.class, Integer.class);
return ccfg;
}
示例12: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
CacheConfiguration ccfg1 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg1.setBackups(1);
ccfg1.setName(CACHE1);
ccfg1.setAffinity(new RendezvousAffinityFunction());
ccfg1.setNodeFilter(new TestNodesFilter());
CacheConfiguration ccfg2 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg2.setBackups(1);
ccfg2.setName(CACHE2);
ccfg2.setAffinity(new RendezvousAffinityFunction());
CacheConfiguration ccfg4 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg4.setCacheMode(REPLICATED);
ccfg4.setName(CACHE4);
ccfg4.setNodeFilter(new TestNodesFilter());
CacheConfiguration ccfg5 = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg5.setBackups(1);
ccfg5.setName(CACHE5);
if (igniteInstanceName.equals(getTestIgniteInstanceName(NODE_CNT - 1))) {
cfg.setClientMode(true);
cfg.setCacheConfiguration(ccfg5);
}
else
cfg.setCacheConfiguration(ccfg1, ccfg2, ccfg4);
return cfg;
}
示例13: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(backups);
ccfg.setAffinity(new RendezvousAffinityFunction());
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例14: transactionalRegionConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param regionName Region name.
* @return Cache configuration for {@link TransactionalDataRegion}.
*/
protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
CacheConfiguration cfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setName(regionName);
cfg.setCacheMode(PARTITIONED);
cfg.setAtomicityMode(TRANSACTIONAL);
cfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setBackups(1);
cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
return cfg;
}
示例15: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
AtomicConfiguration atomicCfg = new AtomicConfiguration();
atomicCfg.setCacheMode(PARTITIONED);
atomicCfg.setBackups(1);
atomicCfg.setAtomicSequenceReserveSize(10);
c.setAtomicConfiguration(atomicCfg);
c.getTransactionConfiguration().setDefaultTxConcurrency(PESSIMISTIC);
c.getTransactionConfiguration().setDefaultTxIsolation(REPEATABLE_READ);
CacheConfiguration cc = defaultCacheConfiguration();
cc.setCacheMode(CacheMode.PARTITIONED);
cc.setRebalanceMode(CacheRebalanceMode.SYNC);
cc.setWriteSynchronizationMode(FULL_SYNC);
LruEvictionPolicy plc = new LruEvictionPolicy();
plc.setMaxSize(1000);
cc.setEvictionPolicy(plc);
cc.setOnheapCacheEnabled(true);
cc.setBackups(1);
cc.setAffinity(new RendezvousAffinityFunction(true));
c.setCacheConfiguration(cc);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
return c;
}