Java Code Examples for org.apache.ignite.configuration.CacheConfiguration#setDataRegionName()
The following examples show how to use
org.apache.ignite.configuration.CacheConfiguration#setDataRegionName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheDataRegionConfigurationTest.java From ignite with Apache License 2.0 | 6 votes |
/** * Verifies that {@link IgniteCheckedException} is thrown when swap and persistence are enabled at the same time * for a data region. */ @Test public void testSetPersistenceAndSwap() { DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); // Enabling the persistence. invCfg.setPersistenceEnabled(true); // Enabling the swap space. invCfg.setSwapPath("/path/to/some/directory"); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setDataRegionName("ccfg"); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); }
Example 2
Source File: IgniteLostPartitionsOnLeaveBaselineSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param name Cache name. * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration( String name, CacheMode cacheMode, CacheAtomicityMode atomicityMode, String dataRegName ) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(name); ccfg.setAtomicityMode(atomicityMode); ccfg.setBackups(0); ccfg.setCacheMode(cacheMode); ccfg.setPartitionLossPolicy(PartitionLossPolicy.READ_WRITE_SAFE); ccfg.setDataRegionName(dataRegName); return ccfg; }
Example 3
Source File: IgniteDataStorageMetricsSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @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); ccfg.setAffinity(new RendezvousAffinityFunction(false, 32)); if (NO_PERSISTENCE.equals(dataRegName)) ccfg.setDiskPageCompression(null); return ccfg; }
Example 4
Source File: CacheMetricsAddRemoveTest.java From ignite with Apache License 2.0 | 6 votes |
/** */ private void createCache(@Nullable String dataRegionName, @Nullable String cacheName) throws InterruptedException { CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); if (dataRegionName != null) ccfg.setDataRegionName(dataRegionName); if (cacheName != null) ccfg.setName(cacheName); if (nearEnabled) ccfg.setNearConfiguration(new NearCacheConfiguration()); grid("client").createCache(ccfg); awaitPartitionMapExchange(); }
Example 5
Source File: JoinPartitionPruningSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Create custom cache configuration. * * @param parts Partitions. * @param backups Backups. * @param customAffinity Custom affinity function flag. * @param nodeFilter Whether to set node filter. * @param persistent Whether to enable persistence. * @return Cache configuration. */ @SuppressWarnings("IfMayBeConditional") private static CacheConfiguration cacheConfiguration( int parts, int backups, boolean customAffinity, boolean nodeFilter, boolean persistent ) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setCacheMode(CacheMode.PARTITIONED); ccfg.setBackups(backups); RendezvousAffinityFunction affFunc; if (customAffinity) affFunc = new CustomRendezvousAffinityFunction(); else affFunc = new RendezvousAffinityFunction(); affFunc.setPartitions(parts); ccfg.setAffinity(affFunc); if (nodeFilter) ccfg.setNodeFilter(new CustomNodeFilter()); if (persistent) ccfg.setDataRegionName(REGION_DISK); return ccfg; }
Example 6
Source File: IgniteTwoRegionsRebuildIndexTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); boolean client = igniteInstanceName.startsWith("client"); DataStorageConfiguration dsCfg = new DataStorageConfiguration(); if (!client) { DataRegionConfiguration drCfg1 = new DataRegionConfiguration(); drCfg1.setMaxSize(16 * 1024 * 1024); drCfg1.setName("nopersistence"); drCfg1.setInitialSize(drCfg1.getMaxSize()); drCfg1.setPersistenceEnabled(false); DataRegionConfiguration drCfg2 = new DataRegionConfiguration(); drCfg2.setMaxSize(16 * 1024 * 1024); drCfg2.setName("persistence"); drCfg2.setInitialSize(drCfg2.getMaxSize()); drCfg2.setPersistenceEnabled(true); dsCfg.setDataRegionConfigurations(drCfg1, drCfg2); cfg.setDataStorageConfiguration(dsCfg); } else { CacheConfiguration ccfg1 = new CacheConfiguration(PERSISTED_CACHE); CacheConfiguration ccfg2 = new CacheConfiguration(INMEMORY_CACHE); ccfg1.setDataRegionName("persistence"); ccfg2.setDataRegionName("nopersistence"); cfg.setCacheConfiguration(ccfg1, ccfg2); } return cfg; }
Example 7
Source File: DemoCachesLoadService.java From ignite with Apache License 2.0 | 5 votes |
/** * 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; }
Example 8
Source File: CacheDataRegionConfigurationTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Verifies that proper exception is thrown when DataRegion is misconfigured for cache. */ @Test public void testMissingDataRegion() { ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setDataRegionName("nonExistingMemPlc"); checkStartGridException(IgniteCheckedException.class, "Requested DataRegion is not configured"); }
Example 9
Source File: IgnitePdsExchangeDuringCheckpointTest.java From ignite with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); DataStorageConfiguration memCfg = new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(800L * 1024 * 1024).setPersistenceEnabled(true)) .setWalMode(WALMode.LOG_ONLY) .setCheckpointThreads(1) .setCheckpointFrequency(1); memCfg.setDataRegionConfigurations(new DataRegionConfiguration() .setMaxSize(200L * 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); ccfgNp.setDiskPageCompression(null); ccfg.setAffinity(new RendezvousAffinityFunction(false, 4096)); cfg.setCacheConfiguration(ccfg, ccfgNp); return cfg; }
Example 10
Source File: TxPessimisticDeadlockDetectionTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @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) throws IgniteInterruptedCheckedException, InterruptedException { awaitPartitionMapExchange(); int minorTopVer = grid(0).context().discovery().topologyVersionEx().minorTopologyVersion(); 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<>()); } } waitForLateAffinityAssignment(minorTopVer); return cache; }
Example 11
Source File: GridLocalConfigManager.java From ignite with Apache License 2.0 | 4 votes |
/** * @param cfg Cache configuration. * @param sql SQL flag. * @param caches Caches map. * @param templates Templates map. * @throws IgniteCheckedException If failed. */ private void addCacheFromConfiguration( CacheConfiguration<?, ?> cfg, boolean sql, Map<String, CacheJoinNodeDiscoveryData.CacheInfo> caches, Map<String, CacheJoinNodeDiscoveryData.CacheInfo> templates ) throws IgniteCheckedException { String cacheName = cfg.getName(); CU.validateCacheName(cacheName); cacheProcessor.cloneCheckSerializable(cfg); CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg); // Initialize defaults. cacheProcessor.initialize(cfg, cacheObjCtx); StoredCacheData cacheData = new StoredCacheData(cfg); cacheData.sql(sql); T2<CacheConfiguration, CacheConfigurationEnrichment> splitCfg = cacheProcessor.splitter().split(cfg); cacheData.config(splitCfg.get1()); cacheData.cacheConfigurationEnrichment(splitCfg.get2()); cfg = splitCfg.get1(); if (GridCacheUtils.isCacheTemplateName(cacheName)) templates.put(cacheName, new CacheJoinNodeDiscoveryData.CacheInfo(cacheData, CacheType.USER, false, 0, true)); else { if (caches.containsKey(cacheName)) { throw new IgniteCheckedException("Duplicate cache name found (check configuration and " + "assign unique name to each cache): " + cacheName); } CacheType cacheType = ctx.cache().cacheType(cacheName); if (cacheType != CacheType.USER && cfg.getDataRegionName() == null) cfg.setDataRegionName(cacheProcessor.context().database().systemDateRegionName()); addStoredCache(caches, cacheData, cacheName, cacheType, false, true); } }
Example 12
Source File: DataRegionsExample.java From ignite with Apache License 2.0 | 4 votes |
/** * 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(); } }
Example 13
Source File: IgniteWalRecoveryPPCTest.java From ignite with Apache License 2.0 | 2 votes |
/** {@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(256L * 1024 * 1024); memPlcCfg.setMaxSize(256L * 1024 * 1024); memPlcCfg.setPersistenceEnabled(true); dbCfg.setDefaultDataRegionConfiguration(memPlcCfg); DataRegionConfiguration memPlcCfg2 = new DataRegionConfiguration(); memPlcCfg2.setName(MEM_PLC_NO_PDS); memPlcCfg2.setInitialSize(256L * 1024 * 1024); memPlcCfg2.setMaxSize(256L * 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; }