本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setBackups方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setBackups方法的具体用法?Java CacheConfiguration.setBackups怎么用?Java CacheConfiguration.setBackups使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.configuration.CacheConfiguration
的用法示例。
在下文中一共展示了CacheConfiguration.setBackups方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param config the akka configuration object
* @param actorSystem the akk actor system
* @return the created snapshot ignite cache
*/
@Override
public IgniteCache<Long, SnapshotItem> apply(Config config, ActorSystem actorSystem) {
final IgniteExtension extension = IgniteExtensionProvider.EXTENSION.get(actorSystem);
final String cachePrefix = config.getString(CACHE_PREFIX_PROPERTY);
final int cacheBackups = config.getInt(CACHE_BACKUPS);
final CacheConfiguration<Long, SnapshotItem> eventStore = new CacheConfiguration();
eventStore.setCopyOnRead(false);
if (cacheBackups > 0) {
eventStore.setBackups(cacheBackups);
} else {
eventStore.setBackups(1);
}
eventStore.setAtomicityMode(CacheAtomicityMode.ATOMIC);
eventStore.setName(cachePrefix + "_SNAPSHOT");
eventStore.setCacheMode(CacheMode.PARTITIONED);
eventStore.setReadFromBackup(true);
eventStore.setIndexedTypes(Long.class, SnapshotItem.class);
eventStore.setIndexedTypes(String.class, SnapshotItem.class);
return extension.getIgnite().getOrCreateCache(eventStore);
}
示例2: createCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Creates cache with full configuration. Active store is used.
*
* @param cacheName name of cache.
* @param atomicityMode atomicity.
* @param cacheMode mode.
* @param writeBehindEnabled should write behind be used for active store.
* @param flushFreq flush frequency for write behind.
* @param base configuration to copy settings from.
* @param <K> type of key.
* @param <V> type of value
* @return cache instance.
*/
@SuppressWarnings("unchecked")
public <K, V> IgniteCache<K, V> createCache(String cacheName, CacheAtomicityMode atomicityMode, CacheMode cacheMode,
boolean writeBehindEnabled, int flushFreq,
CacheConfiguration<K, V> base) {
CacheConfiguration<K, V> realConfiguration = base == null
? new CacheConfiguration<K, V>()
: new CacheConfiguration<K, V>(base);
realConfiguration.setName(cacheName);
realConfiguration.setAtomicityMode(atomicityMode);
realConfiguration.setCacheMode(cacheMode);
realConfiguration.setBackups(2);
realConfiguration.setWriteThrough(true);
realConfiguration.setReadThrough(true);
realConfiguration.setWriteBehindEnabled(writeBehindEnabled);
realConfiguration.setWriteBehindFlushFrequency(flushFreq);
realConfiguration.setCacheStoreFactory(activeStoreConfiguration.activeCacheStoreFactory());
return ignite().createCache(realConfiguration);
}
示例3: createEntityCacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
private CacheConfiguration<?,?> createEntityCacheConfiguration(EntityKeyMetadata entityKeyMetadata, SchemaDefinitionContext context) {
CacheConfiguration<?,?> cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setStoreKeepBinary( true );
cacheConfiguration.setSqlSchema( QueryUtils.DFLT_SCHEMA );
cacheConfiguration.setBackups( 1 );
cacheConfiguration.setName( StringHelper.stringBeforePoint( entityKeyMetadata.getTable() ) );
cacheConfiguration.setAtomicityMode( CacheAtomicityMode.TRANSACTIONAL );
QueryEntity queryEntity = new QueryEntity();
queryEntity.setTableName( entityKeyMetadata.getTable() );
queryEntity.setKeyType( getEntityIdClassName( entityKeyMetadata.getTable(), context ).getSimpleName() );
queryEntity.setValueType( StringHelper.stringAfterPoint( entityKeyMetadata.getTable() ) );
addTableInfo( queryEntity, context, entityKeyMetadata.getTable() );
for ( AssociationKeyMetadata associationKeyMetadata : context.getAllAssociationKeyMetadata() ) {
if ( associationKeyMetadata.getAssociationKind() != AssociationKind.EMBEDDED_COLLECTION
&& associationKeyMetadata.getTable().equals( entityKeyMetadata.getTable() )
&& !IgniteAssociationSnapshot.isThirdTableAssociation( associationKeyMetadata ) ) {
appendIndex( queryEntity, associationKeyMetadata, context );
}
}
log.debugf( "queryEntity: %s", queryEntity );
cacheConfiguration.setQueryEntities( Arrays.asList( queryEntity ) );
return cacheConfiguration;
}
示例4: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cacheMode Cache mode.
* @param atomicityMode Cache atomicity mode.
* @param evictionPlc Eviction policy.
* @param indexing Indexing flag.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(
CacheMode cacheMode,
CacheAtomicityMode atomicityMode,
@Nullable EvictionPolicy<Object, Object> evictionPlc,
boolean indexing) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setEvictionPolicy(evictionPlc);
ccfg.setOnheapCacheEnabled(evictionPlc != null);
if (cacheMode == PARTITIONED)
ccfg.setBackups(1);
if (indexing)
ccfg.setIndexedTypes(TestKey.class, TestData.class);
return ccfg;
}
示例5: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration<?,?> cache = defaultCacheConfiguration();
cache.setCacheMode(PARTITIONED);
cache.setBackups(1);
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setIndexedTypes(
String.class, Person.class,
Integer.class, Test.class
);
cfg.setCacheConfiguration(cache);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(disco);
return cfg;
}
示例6: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
commSpi.setSocketWriteTimeout(1000);
commSpi.setSharedMemoryPort(-1);
commSpi.setConnectionsPerNode(connectionsPerNode());
cfg.setCommunicationSpi(commSpi);
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setCacheMode(PARTITIONED);
ccfg.setAtomicityMode(atomicityMode());
ccfg.setBackups(1);
ccfg.setNearConfiguration(null);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例7: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param cacheMode Cache mode.
* @param backups Number of backups.
* @param atomicityMode Cache atomicity mode.
* @param writeMode Write sync mode.
* @return Cache configuration.
*/
protected CacheConfiguration<Object, Object> cacheConfiguration(
CacheMode cacheMode,
int backups,
CacheAtomicityMode atomicityMode,
CacheWriteSynchronizationMode writeMode) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setName("test-cache-" + atomicityMode + "-" + cacheMode + "-" + writeMode + "-" + backups);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setWriteSynchronizationMode(writeMode);
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
return ccfg;
}
示例8: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setClientMode(client);
DataStorageConfiguration memCfg = new DataStorageConfiguration()
.setDefaultDataRegionConfiguration(
new DataRegionConfiguration().setMaxSize(200 * 1024 * 1024).setPersistenceEnabled(true))
.setWalMode(WALMode.LOG_ONLY);
cfg.setDataStorageConfiguration(memCfg);
CacheConfiguration ccfg1 = new CacheConfiguration();
ccfg1.setName("cache1");
ccfg1.setBackups(1);
ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg1.setAffinity(new RendezvousAffinityFunction(false, 32));
cfg.setCacheConfiguration(ccfg1);
return cfg;
}
示例9: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @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;
}
示例10: apply
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @param config the akka configuration object
* @param actorSystem the akk actor system
* @return the created journal and sequence ignite caches†
*/
@Override
public JournalCaches apply(Config config, ActorSystem actorSystem) {
final IgniteExtension extension = IgniteExtensionProvider.EXTENSION.get(actorSystem);
final String cachePrefix = config.getString(CACHE_PREFIX_PROPERTY);
final int cacheBackups = config.getInt(CACHE_BACKUPS);
// cache configuration
final CacheConfiguration<Long, JournalItem> eventStore = new CacheConfiguration();
eventStore.setCopyOnRead(false);
if (cacheBackups > 0) {
eventStore.setBackups(cacheBackups);
} else {
eventStore.setBackups(1);
}
eventStore.setAtomicityMode(CacheAtomicityMode.ATOMIC);
eventStore.setName(cachePrefix);
eventStore.setCacheMode(CacheMode.PARTITIONED);
eventStore.setReadFromBackup(true);
eventStore.setIndexedTypes(Long.class, JournalItem.class);
eventStore.setIndexedTypes(String.class, JournalItem.class);
eventStore.setInterceptor(new JournalStoreInterceptor());
//sequence Number Tracking
final CacheConfiguration<String, Long> squenceNumberTrack = new CacheConfiguration();
squenceNumberTrack.setCopyOnRead(false);
if (cacheBackups > 0) {
squenceNumberTrack.setBackups(cacheBackups);
} else {
squenceNumberTrack.setBackups(1);
}
squenceNumberTrack.setAtomicityMode(CacheAtomicityMode.ATOMIC);
squenceNumberTrack.setName("sequenceNumberTrack");
squenceNumberTrack.setCacheMode(CacheMode.PARTITIONED);
squenceNumberTrack.setReadFromBackup(true);
return JournalCaches.builder()
.journalCache(extension.getIgnite().getOrCreateCache(eventStore))
.sequenceCache(extension.getIgnite().getOrCreateCache(squenceNumberTrack))
.build();
}
示例11: geneCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
*
* @return CacheConfiguration<Long, Gene>
*/
public static CacheConfiguration<Long, Gene> geneCache() {
CacheConfiguration<Long, Gene> cfg = new CacheConfiguration<>(GAGridConstants.GENE_CACHE);
cfg.setIndexedTypes(Long.class, Gene.class);
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cfg.setStatisticsEnabled(true);
cfg.setBackups(1);
cfg.setSqlFunctionClasses(GAGridFunction.class);
return cfg;
}
示例12: populationCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
*
* @return CacheConfiguration<Long, Chromosome>
*/
public static CacheConfiguration<Long, Chromosome> populationCache() {
CacheConfiguration<Long, Chromosome> cfg = new CacheConfiguration<>(GAGridConstants.POPULATION_CACHE);
cfg.setIndexedTypes(Long.class, Chromosome.class);
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setStatisticsEnabled(true);
cfg.setBackups(1);
return cfg;
}
示例13: createSimpleCache
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Creates cache with minimal configuration. Active store is not used.
*
* @param cacheName name of cache.
* @param atomicityMode atomicity.
* @param cacheMode mode.
* @param base configuration to copy settings from.
* @param <K> type of key.
* @param <V> type of value
* @return cache instance.
*/
public <K, V> IgniteCache<K, V> createSimpleCache(String cacheName, CacheAtomicityMode atomicityMode,
CacheMode cacheMode, CacheConfiguration<K, V> base) {
CacheConfiguration<K, V> realConfiguration = base == null
? new CacheConfiguration<K, V>()
: new CacheConfiguration<K, V>(base);
realConfiguration.setName(cacheName);
realConfiguration.setAtomicityMode(atomicityMode);
realConfiguration.setCacheMode(cacheMode);
realConfiguration.setBackups(2);
return ignite().createCache(realConfiguration);
}
示例14: configuration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* Node configuration.
*
* @param idx Node index.
* @return Node configuration.
* @throws Exception If failed.
*/
private IgniteConfiguration configuration(int idx) throws Exception {
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(CACHE_NAME);
ccfg.setCacheMode(cacheMode());
ccfg.setAtomicityMode(atomicityMode());
ccfg.setRebalanceMode(SYNC);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setEvictionPolicy(null);
if (cacheMode() == PARTITIONED)
ccfg.setBackups(backups());
if (atomicityMode() != ATOMIC && cacheMode() == PARTITIONED) {
ccfg.setNearConfiguration(new NearCacheConfiguration());
}
IgniteConfiguration cfg = getConfiguration(nodeName(idx));
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoSpi);
cfg.setLocalHost("127.0.0.1");
cfg.setCacheConfiguration(ccfg);
cfg.setConnectorConfiguration(null);
return cfg;
}
示例15: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
* @return Cache configuration.
*/
protected CacheConfiguration cacheConfiguration() {
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setCacheMode(cacheMode());
ccfg.setAtomicityMode(atomicityMode());
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
if (cacheMode() == PARTITIONED)
ccfg.setBackups(1);
return ccfg;
}