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


Java CacheConfiguration.setIndexedTypes方法代码示例

本文整理汇总了Java中org.apache.ignite.configuration.CacheConfiguration.setIndexedTypes方法的典型用法代码示例。如果您正苦于以下问题:Java CacheConfiguration.setIndexedTypes方法的具体用法?Java CacheConfiguration.setIndexedTypes怎么用?Java CacheConfiguration.setIndexedTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.configuration.CacheConfiguration的用法示例。


在下文中一共展示了CacheConfiguration.setIndexedTypes方法的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: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setAtomicityMode(TRANSACTIONAL);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setBackups(1);
    cacheCfg.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cacheCfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:IgniteCacheLargeResultSelfTest.java

示例3: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();

    spi.setIpFinder(IP_FINDER);

    CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg.setIndexedTypes(Integer.class, Integer.class);
    ccfg.setName(CACHE_NAME);

    CacheConfiguration<?, ?> ccfg2 = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg2.setIndexedTypes(Integer.class, ValueObj.class);
    ccfg2.setName(CACHE_NAME_2);

    cfg.setCacheConfiguration(ccfg, ccfg2);

    if ("client".equals(gridName))
        cfg.setClientMode(true);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:IgniteSqlQueryMinMaxTest.java

示例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<?,?> ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setCacheMode(PARTITIONED);
    ccfg.setNearConfiguration(null);
    ccfg.setBackups(1);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setIndexedTypes(
        Integer.class, Person.class
    );

    c.setCacheConfiguration(ccfg);

    return c;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:IgniteCacheSqlQueryMultiThreadedSelfTest.java

示例5: createCache

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:25,代码来源:GridCacheCrossCacheQuerySelfTest.java

示例6: 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();
}
 
开发者ID:Romeh,项目名称:akka-persistance-ignite,代码行数:44,代码来源:JournalCacheProvider.java

示例7: 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;

}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:17,代码来源:GeneCacheConfig.java

示例8: 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;

}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:18,代码来源:PopulationCacheConfig.java

示例9: setUp

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
@Before
public void setUp() {
  TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
  ipFinder.setAddresses(Collections.singletonList(HOST));

  TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
  discoSpi.setIpFinder(ipFinder);

  IgniteConfiguration cfg = new IgniteConfiguration();
  cfg.setDiscoverySpi(discoSpi);
  cfg.setPeerClassLoadingEnabled(true);
  cfg.setMarshaller(new OptimizedMarshaller());

  cfg.setGridName("test");

  ignite = Ignition.start(cfg);

  Properties props = new Properties();
  props.setProperty(IgniteSqlInterpreter.IGNITE_JDBC_URL, "jdbc:ignite:cfg://[email protected]");

  intp = new IgniteSqlInterpreter(props);

  CacheConfiguration<Integer, Person> cacheConf = new CacheConfiguration<>();
  cacheConf.setIndexedTypes(Integer.class, Person.class);
  cacheConf.setName("person");

  IgniteCache<Integer, Person> cache = ignite.createCache(cacheConf);
  cache.put(1, new Person("sun", 100));
  cache.put(2, new Person("moon", 50));
  assertEquals("moon", cache.get(2).getName());

  intp.open();
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:34,代码来源:IgniteSqlInterpreterTest.java

示例10: main

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * This is an entry point of TextQueryExample, the ignite configuration lies upon resources directory as
 * example-ignite.xml.
 *
 * @param args Command line arguments, none required.
 */
public static void main(String[] args) throws Exception {

    //The ignite configuration lies below resources directory as example-ignite.xml.
    try (Ignite ignite = Ignition.start("example-ignite.xml")) {

        logger.info("Text. Sql query example.");

        CacheConfiguration<Long, Company> employeeCacheCfg = new CacheConfiguration<>(COMPANY_CACHE_NAME);

        employeeCacheCfg.setCacheMode(CacheMode.PARTITIONED);
        employeeCacheCfg.setIndexedTypes(Long.class, Company.class);

        try (
                IgniteCache<Long, Company> employeeCache = ignite.createCache(employeeCacheCfg)
        ) {
            if (args.length <= 0) {
                logger.error("Usages! java -jar .\\target\\cache-store-runnable.jar scanquery|textquery");
                System.exit(0);
            }
            initialize();

            if (args[0].equalsIgnoreCase(SCAN_QUERY)) {
                scanQuery();
                log("Scan query example finished.");
            } else if (args[0].equalsIgnoreCase(TEXT_QUERY)) {
                textQuery();
                log("Text query example finished.");
            }

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

示例11: main

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception{
    System.out.println("Streamer for service health check!!");
    // Mark this cluster member as client.
    Ignition.setClientMode(true);
    try(Ignite ignite = Ignition.start("example-ignite.xml")){
        if(!ExamplesUtils.hasServerNodes(ignite))
            return;
        // healthcheck cache configuration
        CacheConfiguration<String, ServiceStatus> healthcheck_cfg = new CacheConfiguration<>("healthchecks");
        // set window to 5 second
        //  Note: data will evicts after 5 seconds
        //healthcheck_cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 15))));
        // set index
        healthcheck_cfg.setIndexedTypes(String.class, ServiceStatus.class);

        IgniteCache<String, ServiceStatus> healthCheckCache = ignite.getOrCreateCache(healthcheck_cfg);

        try(IgniteDataStreamer<String, ServiceStatus> healthCheckStreamer = ignite.dataStreamer(healthCheckCache.getName())){
            healthCheckStreamer.allowOverwrite(true);

            while(true ){
                int idx_service_name = RAND.nextInt(SERVICE_NAME.length);
                int idx_code = RAND.nextInt(STATUS_CODE.length);
                ServiceStatus serviceStatus = new ServiceStatus(SERVICE_NAME[idx_service_name], STATUS_CODE[idx_code]);

                healthCheckStreamer.addData(SERVICE_NAME[idx_service_name], serviceStatus);
            }

        }

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

示例12: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param igniteInstanceName Ignite instance name.
 * @return Cache configuration.
 * @throws Exception In case of error.
 */
@SuppressWarnings("unchecked")
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration cfg = defaultCacheConfiguration();

    if (storeStgy != null) {
        Factory<? extends CacheStore<Object, Object>> storeFactory = storeStgy.getStoreFactory();

        CacheStore<?, ?> store = storeFactory.create();

        if (store != null) {
            cfg.setCacheStoreFactory(storeFactory);
            cfg.setReadThrough(true);
            cfg.setWriteThrough(true);
            cfg.setLoadPreviousValue(true);
            storeStgy.updateCacheConfiguration(cfg);
        }
    }

    cfg.setCacheMode(cacheMode());
    cfg.setAtomicityMode(atomicityMode());
    cfg.setWriteSynchronizationMode(writeSynchronization());
    cfg.setNearConfiguration(nearConfiguration());
    cfg.setOnheapCacheEnabled(onheapCacheEnabled());

    Class<?>[] idxTypes = indexedTypes();

    if (!F.isEmpty(idxTypes))
        cfg.setIndexedTypes(idxTypes);

    if (cacheMode() == PARTITIONED)
        cfg.setBackups(1);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:40,代码来源:GridCacheAbstractSelfTest.java

示例13: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    CacheConfiguration<Integer, String> cacheCfg1 = defaultCacheConfiguration();

    cacheCfg1.setName("A");
    cacheCfg1.setCacheMode(cacheMode);
    cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg1.setIndexedTypes(Integer.class, String.class);
    cacheCfg1.setStatisticsEnabled(true);

    CacheConfiguration<Integer, String> cacheCfg2 = defaultCacheConfiguration();

    cacheCfg2.setName("B");
    cacheCfg2.setCacheMode(cacheMode);
    cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
    cacheCfg2.setIndexedTypes(Integer.class, String.class);
    cacheCfg2.setStatisticsEnabled(true);

    cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:CacheAbstractQueryMetricsSelfTest.java

示例14: getConfiguration0

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param gridName Grid name.
 * @return Grid configuration used for starting the grid.
 * @throws Exception If failed.
 */
private IgniteConfiguration getConfiguration0(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);

    CacheConfiguration<?,?> cache = defaultCacheConfiguration();

    cache.setCacheMode(PARTITIONED);
    cache.setBackups(1);
    cache.setWriteSynchronizationMode(FULL_SYNC);
    cache.setIndexedTypes(
        Integer.class, Integer.class
    );

    cfg.setCacheConfiguration(cache);
    cfg.setLocalHost("127.0.0.1");

    TcpDiscoverySpi disco = new TcpDiscoverySpi();

    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500..47501"));

    disco.setIpFinder(ipFinder);

    cfg.setDiscoverySpi(disco);

    cfg.setConnectorConfiguration(new ConnectorConfiguration());

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:34,代码来源:JdbcStreamingSelfTest.java

示例15: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);

    CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    ccfg.setIndexedTypes(Integer.class, String.class);
    ccfg.setCacheMode(LOCAL);

    cfg.setCacheConfiguration(ccfg);

    return cfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:IgniteCacheLocalQueryCancelOrTimeoutSelfTest.java


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