本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration类的具体用法?Java CacheConfiguration怎么用?Java CacheConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CacheConfiguration类属于org.apache.ignite.configuration包,在下文中一共展示了CacheConfiguration类的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: createKeyObject
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
/**
* Converting entity key to cache key
*
* @param key entity key
* @return string key
*/
public Object createKeyObject(EntityKey key) {
Object result = null;
if ( key.getColumnValues().length == 1 ) {
IgniteCache<Object, BinaryObject> entityCache = getEntityCache( key.getMetadata() );
CacheConfiguration cacheConfig = entityCache.getConfiguration( CacheConfiguration.class );
result = toValidKeyObject( key.getColumnValues()[0], cacheConfig.getKeyType() );
}
else {
BinaryObjectBuilder builder = createBinaryObjectBuilder( findKeyType( key.getMetadata() ) );
for ( int i = 0; i < key.getColumnNames().length; i++ ) {
builder.setField( StringHelper.stringAfterPoint( key.getColumnNames()[i] ), key.getColumnValues()[i] );
}
result = builder.build();
}
return result;
}
示例4: 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;
}
示例5: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的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);
}
示例6: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的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);
}
示例7: newCache
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的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);
}
示例8: MemorySpatialIndexSegment
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的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
}
示例9: MemoryHashIndexSegment
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的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
}
示例10: build
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
@Override
public IgniteConfiguration build() {
IgniteConfiguration config = new IgniteConfiguration();
config.setPeerClassLoadingEnabled(true);
config.setClientMode(false);
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ArrayList<String> addrs = new ArrayList<>();
addrs.add("127.0.0.1:47500..47509");
ipFinder.setAddresses(addrs);
discoSpi.setIpFinder(ipFinder);
config.setDiscoverySpi(discoSpi);
CacheConfiguration accountCacheCfg = new CacheConfiguration()
.setName("BREED")
.setAtomicityMode(TRANSACTIONAL)
.setIndexedTypes(
String.class, Breed.class
);
config.setCacheConfiguration(accountCacheCfg);
return config;
}
示例11: main
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
try (Ignite ignite = Ignition.start(CLIENT_CONFIG)) {
IgniteCompute compute = ignite.compute();
CacheConfiguration cacheConfiguration = new CacheConfiguration("checkpoints");
// explicitly uses of checkpoint
CacheCheckpointSpi cacheCheckpointSpi = new CacheCheckpointSpi();
cacheCheckpointSpi.setCacheName("checkpointCache");
//cacheConfiguration.setC
ignite.configuration().setCheckpointSpi(cacheCheckpointSpi)
.setFailoverSpi(new AlwaysFailoverSpi());
// create or get cache
ignite.getOrCreateCache(cacheConfiguration);
ValidateMessage[] validateMessages = TestDataGenerator.getValidateMessages();
Boolean result = compute.execute(new ForkJoinWithCheckpointComputation(), validateMessages);
System.out.println("final result=" + result);
}
}
示例12: main
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
try (Ignite ignite = Ignition.start("example-ignite.xml")) {
if (!ExamplesUtils.hasServerNodes(ignite))
return;
CacheConfiguration<String, Alert> alert_Cfg = new CacheConfiguration<>("alerts");
IgniteCache<String, Alert> instCache = ignite.getOrCreateCache(alert_Cfg);
SqlFieldsQuery top3qry = new SqlFieldsQuery(QUERY_RED);
while(true){
// Execute queries.
List<List<?>> top3 = instCache.query(top3qry).getAll();
System.out.println("Service Health Monitoring");
ExamplesUtils.printQueryResults(top3);
Thread.sleep(1000);
}
}
}
示例13: main
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Mark this cluster member as client.
Ignition.setClientMode(true);
try (Ignite ignite = Ignition.start("example-ignite.xml")) {
if (!ExamplesUtils.hasServerNodes(ignite))
return;
// query code goes here.
CacheConfiguration<String, ServiceStatus> healthchecksCfg = new CacheConfiguration<>("healthchecks");
IgniteCache<String, ServiceStatus> instCache = ignite.getOrCreateCache(healthchecksCfg);
SqlFieldsQuery query = new SqlFieldsQuery(QUERY_404);
while(true){
// Execute queries.
List<List<?>> res = instCache.query(query).getAll();
System.out.println("Service Health check status");
ExamplesUtils.printQueryResults(res);
Thread.sleep(1000);
}
}
}
示例14: cacheConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
/**
* @param atomicityMode Atomicity mode.
* @param heapCache Heap cache flag.
* @param expiryPlc Expiry policy flag.
* @return Cache configuration.
*/
private CacheConfiguration cacheConfiguration(CacheAtomicityMode atomicityMode,
boolean heapCache,
boolean expiryPlc) {
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setAtomicityMode(atomicityMode);
ccfg.setOnheapCacheEnabled(heapCache);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setName("testCache");
if (expiryPlc)
ccfg.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(Duration.FIVE_MINUTES));
return ccfg;
}
示例15: getConfiguration
import org.apache.ignite.configuration.CacheConfiguration; //导入依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
CacheConfiguration<Integer, Integer> ccfg =
new CacheConfiguration<Integer, Integer>()
.setName("config")
.setAtomicityMode(CacheAtomicityMode.ATOMIC)
.setBackups(0) // No need for backup, just load from the store if needed
.setCacheStoreFactory(new CacheStoreFactory())
.setOnheapCacheEnabled(true)
.setEvictionPolicy(new LruEvictionPolicy(100))
.setNearConfiguration(new NearCacheConfiguration<Integer, Integer>()
.setNearEvictionPolicy(new LruEvictionPolicy<Integer, Integer>()));
ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 1)))
.setReadThrough(true)
.setWriteThrough(false);
cfg.setCacheConfiguration(ccfg);
return cfg;
}