本文整理汇总了Java中org.apache.ignite.cache.CacheMode类的典型用法代码示例。如果您正苦于以下问题:Java CacheMode类的具体用法?Java CacheMode怎么用?Java CacheMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheMode类属于org.apache.ignite.cache包,在下文中一共展示了CacheMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import org.apache.ignite.cache.CacheMode; //导入依赖的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.cache.CacheMode; //导入依赖的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: newCache
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<MatrixBlockKey, MatrixBlockEntry> newCache() {
CacheConfiguration<MatrixBlockKey, MatrixBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例4: newCache
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<VectorBlockKey, VectorBlockEntry> newCache() {
CacheConfiguration<VectorBlockKey, VectorBlockEntry> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例5: newCache
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* Create new ML cache if needed.
*/
private IgniteCache<RowColMatrixKey, Double> newCache() {
CacheConfiguration<RowColMatrixKey, Double> cfg = new CacheConfiguration<>();
// Write to primary.
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
// Atomic transactions only.
cfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
// No eviction.
cfg.setEvictionPolicy(null);
// No copying of values.
cfg.setCopyOnRead(false);
// Cache is partitioned.
cfg.setCacheMode(CacheMode.PARTITIONED);
// Random cache name.
cfg.setName(CACHE_NAME);
return Ignition.localIgnite().getOrCreateCache(cfg);
}
示例6: MemorySpatialIndexSegment
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
public MemorySpatialIndexSegment(String uniqueName, SpatialPartitioner
partitioner, long batchUpdateTimeMilliseconds, StreamDataset
stream, Attribute indexedAttribute)
{
this.setName(uniqueName);
this.spatialPartitioner = partitioner;
this.stream = stream;
this.indexedAttribute = indexedAttribute;
//Index creation
//Setting index configuration
CacheConfiguration<Integer,SpatialPartition> cnfig = new
CacheConfiguration<> (this.getName());
cnfig.setCacheMode(CacheMode.LOCAL);
cnfig.setCacheStoreFactory(new IgniteReflectionFactory<BulkLoadSpatialCacheStore>
(BulkLoadSpatialCacheStore.class));
cnfig.setWriteThrough(true);
Ignite cluster = KiteInstance.getCluster(); //getting underlying cluster
spatialPartitionsData = cluster.getOrCreateCache(cnfig); //create
}
示例7: MemoryHashIndexSegment
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
public MemoryHashIndexSegment(String uniqueName, long
batchUpdateTimeMilliseconds) {
this.setName(uniqueName);
//Index creation
//Setting index configuration
CacheConfiguration<String,ArrayList<Long>> cnfig = new
CacheConfiguration<String,ArrayList<Long>>(this.getName());
cnfig.setCacheMode(CacheMode.LOCAL);
cnfig.setCacheStoreFactory(new IgniteReflectionFactory<BulkLoadCacheStore>
(BulkLoadCacheStore.class));
cnfig.setWriteThrough(true);
Ignite cluster = KiteInstance.getCluster(); //getting underlying cluster
hashIndex = cluster.getOrCreateCache(cnfig); //create index
}
示例8: testAdd
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
@Test
public void testAdd() throws Exception {
L2CacheConfig base = new L2CacheConfig();
base.setCacheMode(CacheMode.LOCAL);
base.setNearSize(42);
assertNull(base.getAtomicityMode());
L2CacheConfig apply = new L2CacheConfig();
apply.setNearSize(56);
apply.setAtomicityMode(CacheAtomicityMode.ATOMIC);
L2CacheConfig add = AddL2CacheConfig.add(base, apply);
assertEquals(add.getNearSize(), Integer.valueOf(56));
assertEquals(add.getAtomicityMode(), CacheAtomicityMode.ATOMIC);
assertEquals(add.getCacheMode(), CacheMode.LOCAL);
assertNull(add.getBackups());
}
示例9: testBackupConsistencyPartitionedFullSync
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testBackupConsistencyPartitionedFullSync() throws Exception {
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setBackups(NODES - 1);
cfg.setReadFromBackup(false);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}
示例10: assignPartitionsStates
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
*
*/
private void assignPartitionsStates() {
for (Map.Entry<Integer, CacheGroupDescriptor> e : cctx.affinity().cacheGroups().entrySet()) {
CacheGroupDescriptor grpDesc = e.getValue();
if (grpDesc.config().getCacheMode() == CacheMode.LOCAL)
continue;
if (!CU.isPersistentCache(grpDesc.config(), cctx.gridConfig().getDataStorageConfiguration()))
continue;
CacheGroupContext grpCtx = cctx.cache().cacheGroup(e.getKey());
GridDhtPartitionTopology top = grpCtx != null ?
grpCtx.topology() :
cctx.exchange().clientTopology(e.getKey(), events().discoveryCache());
assignPartitionStates(top);
}
}
示例11: cacheConfiguration
import org.apache.ignite.cache.CacheMode; //导入依赖的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;
}
示例12: getConfiguration
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setName(CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
ccfg.setCacheMode(CacheMode.PARTITIONED);
ccfg.setBackups(1);
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 10)));
cfg.setCacheConfiguration(ccfg);
return cfg;
}
示例13: createCache
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* Creates new cache configuration.
*
* @param name Cache name.
* @param mode Cache mode.
* @param clsK Key class.
* @param clsV Value class.
* @return Cache configuration.
*/
private static CacheConfiguration createCache(String name, CacheMode mode, Class<?> clsK, Class<?> clsV) {
CacheConfiguration<?,?> cc = defaultCacheConfiguration();
cc.setName(name);
cc.setCacheMode(mode);
cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
cc.setRebalanceMode(SYNC);
cc.setAtomicityMode(TRANSACTIONAL);
cc.setIndexedTypes(clsK, clsV);
if ((mode != CacheMode.PARTITIONED) && (mode != CacheMode.REPLICATED))
throw new IllegalStateException("mode: " + mode);
return cc;
}
示例14: cacheConfiguration
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
*
* @param cacheMode Cache mode.
* @param backups Number of backups.
* @param atomicityMode Cache atomicity mode.
* @param filter Filter enabled.
* @return Cache configuration.
*/
private CacheConfiguration<Object, Object> cacheConfiguration(
CacheMode cacheMode,
int backups,
CacheAtomicityMode atomicityMode,
boolean filter) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
ccfg.setAtomicityMode(atomicityMode);
ccfg.setCacheMode(cacheMode);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
if (cacheMode == PARTITIONED)
ccfg.setBackups(backups);
if (filter)
ccfg.setNodeFilter(new P1<ClusterNode>() {
@Override public boolean apply(ClusterNode node) {
return !node.attributes().get(ATTR_IGNITE_INSTANCE_NAME).equals(SERVER2);
}
});
return ccfg;
}
示例15: testBackupConsistencyPartitioned
import org.apache.ignite.cache.CacheMode; //导入依赖的package包/类
/**
* @throws Exception If failed.
*/
public void testBackupConsistencyPartitioned() throws Exception {
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>("test-cache");
cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC);
cfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setBackups(NODES - 1);
cfg.setReadFromBackup(false);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistency(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistency(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
checkBackupConsistencyGetAll(cfg, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
}