当前位置: 首页>>代码示例>>Java>>正文


Java CacheConfiguration类代码示例

本文整理汇总了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);
}
 
开发者ID:Romeh,项目名称:akka-persistance-ignite,代码行数:26,代码来源:SnapshotCacheProvider.java

示例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);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:32,代码来源:TestResources.java

示例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;
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:23,代码来源:IgniteDatastoreProvider.java

示例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;
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:26,代码来源:IgniteCacheInitializer.java

示例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);
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:27,代码来源:BlockMatrixStorage.java

示例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);
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:27,代码来源:BlockVectorStorage.java

示例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);
}
 
开发者ID:Luodian,项目名称:Higher-Cloud-Computing-Project,代码行数:27,代码来源:SparseDistributedVectorStorage.java

示例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
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:23,代码来源:MemorySpatialIndexSegment.java

示例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
}
 
开发者ID:amrmagdy4,项目名称:kite,代码行数:18,代码来源:MemoryHashIndexSegment.java

示例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;
}
 
开发者ID:srecon,项目名称:ignite-jpa,代码行数:25,代码来源:ConfigurationMaker.java

示例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);
        }
    }
 
开发者ID:srecon,项目名称:ignite-book-code-samples,代码行数:21,代码来源:ForkJoinWithCheckpointComputation.java

示例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);
        }

    }
}
 
开发者ID:srecon,项目名称:ignite-book-code-samples,代码行数:26,代码来源:AlertMonitoring.java

示例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);
        }

    }
}
 
开发者ID:srecon,项目名称:ignite-book-code-samples,代码行数:26,代码来源:QueryStatus.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteCacheNoSyncForGetTest.java

示例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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:GridCachePartitionEvictionDuringReadThroughSelfTest.java


注:本文中的org.apache.ignite.configuration.CacheConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。