/** * Create metastorage data region configuration with enabled persistence by default. * * @param storageCfg Data storage configuration. * @return Data region configuration. */ private DataRegionConfiguration createMetastoreDataRegionConfig(DataStorageConfiguration storageCfg) { DataRegionConfiguration cfg = new DataRegionConfiguration(); cfg.setName(METASTORE_DATA_REGION_NAME); cfg.setInitialSize(storageCfg.getSystemRegionInitialSize()); cfg.setMaxSize(storageCfg.getSystemRegionMaxSize()); cfg.setPersistenceEnabled(true); return cfg; }
/** * Constructor. * * @param plc Data region configuration. */ public VisorDataRegionConfiguration(DataRegionConfiguration plc) { assert plc != null; name = plc.getName(); initSize = plc.getInitialSize(); maxSize = plc.getMaxSize(); swapPath = plc.getSwapPath(); pageEvictionMode = plc.getPageEvictionMode(); evictionThreshold = plc.getEvictionThreshold(); emptyPagesPoolSize = plc.getEmptyPagesPoolSize(); metricsEnabled = plc.isMetricsEnabled(); metricsSubIntervalCount = plc.getMetricsSubIntervalCount(); metricsRateTimeInterval = plc.getMetricsRateTimeInterval(); persistenceEnabled = plc.isPersistenceEnabled(); checkpointPageBufSize = plc.getCheckpointPageBufferSize(); }
/** * Reads the data region configuration. * * @param r Reader. */ private static DataRegionConfiguration readDataRegionConfiguration(BinaryRawReader r) { assert r != null; return new DataRegionConfiguration() .setName(r.readString()) .setPersistenceEnabled(r.readBoolean()) .setInitialSize(r.readLong()) .setMaxSize(r.readLong()) .setSwapPath(r.readString()) .setPageEvictionMode(DataPageEvictionMode.fromOrdinal(r.readInt())) .setEvictionThreshold(r.readDouble()) .setEmptyPagesPoolSize(r.readInt()) .setMetricsEnabled(r.readBoolean()) .setMetricsSubIntervalCount(r.readInt()) .setMetricsRateTimeInterval(r.readLong()) .setCheckpointPageBufferSize(r.readLong()); }
/** * Constructor. * * @param plc Memory policy configuration. */ public VisorMemoryPolicyConfiguration(DataRegionConfiguration plc) { assert plc != null; name = plc.getName(); maxSize = plc.getMaxSize(); initSize = plc.getInitialSize(); swapFilePath = plc.getSwapPath(); pageEvictionMode = plc.getPageEvictionMode(); evictionThreshold = plc.getEvictionThreshold(); emptyPagesPoolSize = plc.getEmptyPagesPoolSize(); }
/** * @param regCfg DataRegionConfiguration to validate. * @throws IgniteCheckedException If config is invalid. */ private void checkRegionMemoryStorageType(DataRegionConfiguration regCfg) throws IgniteCheckedException { if (regCfg.isPersistenceEnabled() && regCfg.getSwapPath() != null) throw new IgniteCheckedException("DataRegionConfiguration must not have both persistence " + "storage and swap space enabled at the same time (Use DataRegionConfiguration.setSwapPath(null) " + "to disable the swap space usage or DataRegionConfiguration.setPersistenceEnabled(false) " + "to disable the persistence) [name=" + regCfg.getName() + ", swapPath=" + regCfg.getSwapPath() + ", persistenceEnabled=" + regCfg.isPersistenceEnabled() + "]" ); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); return cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration(new DataRegionConfiguration() .setMaxSize(200 * 1024 * 1024) .setPersistenceEnabled(true))); }
/** * Verifies that {@link IgniteCheckedException} is thrown when empty pages pool size is less than 10 */ @Test public void testInvalidSmallEmptyPagesPoolSize() { final int SMALL_PAGES_POOL_SIZE = 5; DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU); // Setting the pages pool size less than 10 invCfg.setEmptyPagesPoolSize(SMALL_PAGES_POOL_SIZE); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); }
/** * Verifies that {@link IgniteCheckedException} is thrown when page eviction threshold is less than 0.5. */ @Test public void testSetSmallInvalidEviction() { final double SMALL_EVICTION_THRESHOLD = 0.1D; DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU); // Setting the page eviction threshold less than 0.5 invCfg.setEvictionThreshold(SMALL_EVICTION_THRESHOLD); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); }
/** {@inheritDoc} */ @Override protected void configure(DataStorageConfiguration mCfg) { mCfg.setConcurrencyLevel(CONCURRENCY_LEVEL); long size = (1024 * (isLargePage() ? 16 : 4) + 24) * pagesMax(); mCfg.setDefaultDataRegionConfiguration( new DataRegionConfiguration().setMaxSize(Math.max(size, MIN_PAGE_CACHE_SIZE)).setName("default")); }
/** * Verifies that {@link IgniteCheckedException} is thrown when IgniteCheckedException if validation of * memory metrics properties fails. Metrics rate time interval must not be less than 1000ms. */ @Test public void testInvalidMetricsProperties() { final long SMALL_RATE_TIME_INTERVAL_MS = 999; DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU); // Setting the metrics rate time less then 1000ms invCfg.setMetricsRateTimeInterval(SMALL_RATE_TIME_INTERVAL_MS); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); }
/** * Verifies that {@link IgniteCheckedException} is thrown when IgniteCheckedException if validation of * memory metrics properties fails. Metrics sub interval count must be positive. */ @Test public void testInvalidSubIntervalCount() { final int NEG_SUB_INTERVAL_COUNT = -1000; DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU); // Setting the metrics sub interval count as negative invCfg.setMetricsSubIntervalCount(NEG_SUB_INTERVAL_COUNT); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); DataStorageConfiguration dbCfg = new DataStorageConfiguration(); DataRegionConfiguration plc = new DataRegionConfiguration(); // This will test additional segment allocation. plc.setInitialSize(SIZE / 2); plc.setMaxSize(SIZE); plc.setEmptyPagesPoolSize(EMPTY_PAGES_POOL_SIZE); plc.setEvictionThreshold(EVICTION_THRESHOLD); plc.setName(DEFAULT_POLICY_NAME); dbCfg.setDefaultDataRegionConfiguration(plc); dbCfg.setPageSize(PAGE_SIZE); cfg.setDataStorageConfiguration(dbCfg); return cfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setDataStorageConfiguration(new DataStorageConfiguration() .setDefaultDataRegionConfiguration( new DataRegionConfiguration().setName("mem0").setPersistenceEnabled(false)) .setDataRegionConfigurations( new DataRegionConfiguration().setName("disk").setPersistenceEnabled(true), new DataRegionConfiguration().setName("mem2").setPersistenceEnabled(false))); return cfg; }
/** */ public DataStorageConfiguration getDataStorageConfiguration() { DataStorageConfiguration memCfg = new DataStorageConfiguration(); DataRegionConfiguration plc = new DataRegionConfiguration(); plc.setName("Default_Region"); plc.setPageEvictionMode(RANDOM_LRU); if (isSmallRegion) plc.setMaxSize(128L * 1024 * 1024); // 128 MB else plc.setMaxSize(1L * 1024 * 1024 * 1024); // 1GB memCfg.setDefaultDataRegionConfiguration(plc); memCfg.setWalMode(LOG_ONLY); return memCfg; }
/** * @throws Exception If failed. */ @Test public void testMvccInMemoryEvictionDisabled() throws Exception { final String memRegName = "in-memory-evictions"; // Enable in-memory eviction. DataRegionConfiguration regionCfg = new DataRegionConfiguration(); regionCfg.setPersistenceEnabled(false); regionCfg.setPageEvictionMode(RANDOM_2_LRU); regionCfg.setName(memRegName); DataStorageConfiguration storageCfg = new DataStorageConfiguration(); storageCfg.setDefaultDataRegionConfiguration(regionCfg); IgniteConfiguration cfg = getConfiguration("testGrid"); cfg.setDataStorageConfiguration(storageCfg); Ignite node = startGrid(cfg); CacheConfiguration ccfg1 = new CacheConfiguration("test1") .setAtomicityMode(TRANSACTIONAL_SNAPSHOT) .setDataRegionName(memRegName); try { node.createCache(ccfg1); fail("In memory evictions should be disabled for MVCC caches."); } catch (Exception e) { assertTrue(X.getFullStackTrace(e).contains("Data pages evictions cannot be used with TRANSACTIONAL_SNAPSHOT")); } }
/** * @param isRelativePath flag is set to {@code true} if relative path should be used for data region configuration. */ private DataStorageConfiguration createMemoryConfiguration(boolean isRelativePath) { DataStorageConfiguration memCfg = new DataStorageConfiguration(); DataRegionConfiguration memPlcCfg = new DataRegionConfiguration(); memPlcCfg.setName("default"); memPlcCfg.setMaxSize(20L * 1024 * 1024); if (isRelativePath) memPlcCfg.setSwapPath(RELATIVE_SWAP_PATH); else memPlcCfg.setSwapPath(Paths.get(getTmpDir(), ABSOLUTE_SWAP_PATH).toString()); memCfg.setDefaultDataRegionConfiguration(memPlcCfg); return memCfg; }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) .setConnectorConfiguration(new ConnectorConfiguration()) .setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration( new DataRegionConfiguration().setPersistenceEnabled(true)) ); }
/** * @param regCfg DataRegionConfiguration to validate. * @param dbCfg Memory configuration. * @throws IgniteCheckedException If config is invalid. */ protected void checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg) throws IgniteCheckedException { if (regCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED) return; if (regCfg.getEvictionThreshold() < 0.5 || regCfg.getEvictionThreshold() > 0.999) { throw new IgniteCheckedException("Page eviction threshold must be between 0.5 and 0.999: " + regCfg.getName()); } if (regCfg.getEmptyPagesPoolSize() <= 10) throw new IgniteCheckedException("Evicted pages pool size should be greater than 10: " + regCfg.getName()); long maxPoolSize = regCfg.getMaxSize() / dbCfg.getPageSize() / 10; if (regCfg.getEmptyPagesPoolSize() >= maxPoolSize) { throw new IgniteCheckedException("Evicted pages pool size should be lesser than " + maxPoolSize + ": " + regCfg.getName()); } }
DataRegionConfiguration regionCfg = new DataRegionConfiguration(); regionCfg.setPersistenceEnabled(true); regionCfg.setPageEvictionMode(RANDOM_LRU); storageCfg.setDefaultDataRegionConfiguration(regionCfg); IgniteConfiguration cfg = getConfiguration("testGrid");
/** * @param pageSize Page size. * @return Free list. * @throws Exception If failed. */ protected FreeList createFreeList(int pageSize) throws Exception { DataRegionConfiguration plcCfg = new DataRegionConfiguration() .setInitialSize(1024 * MB) .setMaxSize(1024 * MB); pageMem = createPageMemory(pageSize, plcCfg); long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA); DataRegionMetricsImpl regionMetrics = new DataRegionMetricsImpl(plcCfg); DataRegion dataRegion = new DataRegion(pageMem, plcCfg, regionMetrics, new NoOpPageEvictionTracker()); return new CacheFreeListImpl(1, "freelist", regionMetrics, dataRegion, null, null, metaPageId, true); }