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


Java CacheConfiguration.setDataRegionName方法代码示例

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


在下文中一共展示了CacheConfiguration.setDataRegionName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMissingDataRegion

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Verifies that proper exception is thrown when DataRegion is misconfigured for cache.
 */
public void testMissingDataRegion() throws Exception {
    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    ccfg.setDataRegionName("nonExistingMemPlc");

    try {
        startGrid(0);
    }
    catch (IgniteCheckedException e) {
        String msg = e.getMessage();

        assertTrue("Not expected exception was thrown: " + e, msg.contains("Requested DataRegion is not configured"));

        return;
    }

    fail("Expected exception was not thrown: missing DataRegion");
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:CacheDataRegionConfigurationTest.java

示例2: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param grpName Cache group name.
 * @param name Cache name.
 * @param cacheMode Cache mode.
 * @param atomicityMode Atomicity mode.
 * @param backups Backups number.
 * @return Cache configuration.
 */
private CacheConfiguration cacheConfiguration(
    String grpName,
    String name,
    CacheMode cacheMode,
    CacheAtomicityMode atomicityMode,
    int backups,
    String dataRegName
) {
    CacheConfiguration ccfg = new CacheConfiguration();

    ccfg.setName(name);
    ccfg.setGroupName(grpName);
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setBackups(backups);
    ccfg.setCacheMode(cacheMode);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setDataRegionName(dataRegName);

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:29,代码来源:IgniteDataStorageMetricsSelfTest.java

示例3: cacheConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Create base cache configuration.
 *
 * @param name cache name.
 * @return Cache configuration with basic properties set.
 */
private static CacheConfiguration cacheConfiguration(String name) {
    CacheConfiguration ccfg = new CacheConfiguration<>(name);

    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg.setQueryDetailMetricsSize(10);
    ccfg.setStatisticsEnabled(true);
    ccfg.setSqlFunctionClasses(SQLFunctions.class);
    ccfg.setDataRegionName("demo");

    return ccfg;
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:DemoCachesLoadService.java

示例4: createCache

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cacheMode Cache mode.
 * @param syncMode Write sync mode.
 * @param near Near.
 * @return Created cache.
 */
@SuppressWarnings("unchecked")
private IgniteCache createCache(CacheMode cacheMode, CacheWriteSynchronizationMode syncMode, boolean near) {
    CacheConfiguration ccfg = defaultCacheConfiguration();

    ccfg.setName(CACHE_NAME);
    ccfg.setCacheMode(cacheMode);
    ccfg.setBackups(1);
    ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
    ccfg.setWriteSynchronizationMode(syncMode);

    if (cacheMode == LOCAL)
        ccfg.setDataRegionName("dfltPlc");

    IgniteCache cache = ignite(0).createCache(ccfg);

    if (near) {
        for (int i = 0; i < NODES_CNT; i++) {
            Ignite client = ignite(i + NODES_CNT);

            assertTrue(client.configuration().isClientMode());

            client.createNearCache(ccfg.getName(), new NearCacheConfiguration<>());
        }
    }

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

示例5: addCacheOnJoin

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * @param cfg Cache configuration.
 * @param sql SQL flag.
 * @param caches Caches map.
 * @param templates Templates map.
 * @throws IgniteCheckedException If failed.
 */
private void addCacheOnJoin(CacheConfiguration<?, ?> cfg, boolean sql,
    Map<String, CacheInfo> caches,
    Map<String, CacheInfo> templates) throws IgniteCheckedException {
    String cacheName = cfg.getName();

    CU.validateCacheName(cacheName);

    cloneCheckSerializable(cfg);

    CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);

    // Initialize defaults.
    initialize(cfg, cacheObjCtx);

    StoredCacheData cacheData = new StoredCacheData(cfg);

    cacheData.sql(sql);

    boolean template = cacheName.endsWith("*");

    if (!template) {
        if (caches.containsKey(cacheName)) {
            throw new IgniteCheckedException("Duplicate cache name found (check configuration and " +
                "assign unique name to each cache): " + cacheName);
        }

        CacheType cacheType = cacheType(cacheName);

        if (cacheType != CacheType.USER && cfg.getDataRegionName() == null)
            cfg.setDataRegionName(sharedCtx.database().systemDateRegionName());

        if (!cacheType.userCache())
            stopSeq.addLast(cacheName);
        else
            stopSeq.addFirst(cacheName);

        caches.put(cacheName, new CacheJoinNodeDiscoveryData.CacheInfo(cacheData, cacheType, cacheData.sql(), 0));
    }
    else
        templates.put(cacheName, new CacheJoinNodeDiscoveryData.CacheInfo(cacheData, CacheType.USER, false, 0));
}
 
开发者ID:apache,项目名称:ignite,代码行数:49,代码来源:GridCacheProcessor.java

示例6: main

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**
 * Executes example.
 *
 * @param args Command line arguments, none required.
 * @throws IgniteException If example execution failed.
 */
public static void main(String[] args) throws IgniteException {
    try (Ignite ignite = Ignition.start("examples/config/example-data-regions.xml")) {
        System.out.println();
        System.out.println(">>> Data regions example started.");

        /*
         * Preparing configurations for 2 caches that will be bound to the memory region defined by
         * '10MB_Region_Eviction' data region from 'example-data-regions.xml' configuration.
         */
        CacheConfiguration<Integer, Integer> firstCacheCfg = new CacheConfiguration<>("firstCache");

        firstCacheCfg.setDataRegionName(REGION_40MB_EVICTION);
        firstCacheCfg.setCacheMode(CacheMode.PARTITIONED);
        firstCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);

        CacheConfiguration<Integer, Integer> secondCacheCfg = new CacheConfiguration<>("secondCache");
        secondCacheCfg.setDataRegionName(REGION_40MB_EVICTION);
        secondCacheCfg.setCacheMode(CacheMode.REPLICATED);
        secondCacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);

        IgniteCache<Integer, Integer> firstCache = ignite.createCache(firstCacheCfg);
        IgniteCache<Integer, Integer> secondCache = ignite.createCache(secondCacheCfg);

        System.out.println(">>> Started two caches bound to '" + REGION_40MB_EVICTION + "' memory region.");

        /*
         * Preparing a configuration for a cache that will be bound to the memory region defined by
         * '5MB_Region_Swapping' data region from 'example-data-regions.xml' configuration.
         */
        CacheConfiguration<Integer, Integer> thirdCacheCfg = new CacheConfiguration<>("thirdCache");

        thirdCacheCfg.setDataRegionName(REGION_30MB_MEMORY_MAPPED_FILE);

        IgniteCache<Integer, Integer> thirdCache = ignite.createCache(thirdCacheCfg);

        System.out.println(">>> Started a cache bound to '" + REGION_30MB_MEMORY_MAPPED_FILE + "' memory region.");

        /*
         * Preparing a configuration for a cache that will be bound to the default memory region defined by
         * default 'Default_Region' data region from 'example-data-regions.xml' configuration.
         */
        CacheConfiguration<Integer, Integer> fourthCacheCfg = new CacheConfiguration<>("fourthCache");

        IgniteCache<Integer, Integer> fourthCache = ignite.createCache(fourthCacheCfg);

        System.out.println(">>> Started a cache bound to '" + REGION_DEFAULT + "' memory region.");

        System.out.println(">>> Destroying caches...");

        firstCache.destroy();
        secondCache.destroy();
        thirdCache.destroy();
        fourthCache.destroy();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:62,代码来源:DataRegionsExample.java

示例7: getConfiguration

import org.apache.ignite.configuration.CacheConfiguration; //导入方法依赖的package包/类
/**

    /** {@inheritDoc} */
    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(gridName);

        DataStorageConfiguration memCfg = new DataStorageConfiguration()
            .setDefaultDataRegionConfiguration(
                new DataRegionConfiguration().setMaxSize(800 * 1024 * 1024).setPersistenceEnabled(true))
            .setWalMode(WALMode.LOG_ONLY)
            .setCheckpointThreads(1)
            .setCheckpointFrequency(1);

        memCfg.setDataRegionConfigurations(new DataRegionConfiguration()
            .setMaxSize(200 * 1024 * 1024)
            .setName(NO_PERSISTENCE_REGION)
            .setPersistenceEnabled(false));

        cfg.setDataStorageConfiguration(memCfg);

        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

        CacheConfiguration ccfgNp = new CacheConfiguration("nonPersistentCache");
        ccfgNp.setDataRegionName(NO_PERSISTENCE_REGION);

        ccfg.setAffinity(new RendezvousAffinityFunction(false, 4096));

        cfg.setCacheConfiguration(ccfg, ccfgNp);

        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();

        discoSpi.setIpFinder(IP_FINDER);

        cfg.setDiscoverySpi(discoSpi);

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

示例8: getConfiguration

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

    CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME_1);

    ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));

    cfg.setCacheConfiguration(ccfg);

    CacheConfiguration<Integer, IndexedObject> ccfg2 = new CacheConfiguration<>(CACHE_NAME_2);

    ccfg2.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    ccfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
    ccfg2.setAffinity(new RendezvousAffinityFunction(false, 32));
    ccfg2.setDataRegionName(MEM_PLC_NO_PDS);

    cfg.setCacheConfiguration(ccfg, ccfg2);

    DataStorageConfiguration dbCfg = new DataStorageConfiguration();
    dbCfg.setPageSize(4 * 1024);

    DataRegionConfiguration memPlcCfg = new DataRegionConfiguration();
    memPlcCfg.setInitialSize(1024 * 1024 * 1024);
    memPlcCfg.setMaxSize(1024 * 1024 * 1024);
    memPlcCfg.setPersistenceEnabled(true);

    dbCfg.setDefaultDataRegionConfiguration(memPlcCfg);

    DataRegionConfiguration memPlcCfg2 = new DataRegionConfiguration();
    memPlcCfg2.setName(MEM_PLC_NO_PDS);
    memPlcCfg2.setInitialSize(1024 * 1024 * 1024);
    memPlcCfg2.setMaxSize(1024 * 1024 * 1024);
    memPlcCfg2.setPersistenceEnabled(false);

    dbCfg.setDataRegionConfigurations(memPlcCfg2);

    dbCfg.setWalRecordIteratorBufferSize(1024 * 1024);

    dbCfg.setWalHistorySize(2);

    dbCfg.setWalMode(WALMode.LOG_ONLY);

    if (walSegmentSize != 0)
        dbCfg.setWalSegmentSize(walSegmentSize);

    cfg.setDataStorageConfiguration(dbCfg);

    cfg.setMarshaller(null);

    BinaryConfiguration binCfg = new BinaryConfiguration();

    binCfg.setCompactFooter(false);

    cfg.setBinaryConfiguration(binCfg);

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


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