/** * @return Durable memory page size in bytes. */ public int pageSize() { return dsCfg.getPageSize(); }
/** * @param type Type. * @param file File. * @param factory Factory. * @param cfg Config. * @param allocatedTracker Metrics updater */ public FilePageStoreV2( byte type, File file, FileIOFactory factory, DataStorageConfiguration cfg, AllocatedPageTracker allocatedTracker) { super(type, file, factory, cfg, allocatedTracker); hdrSize = cfg.getPageSize(); }
/** * @param ver Version. * @return Header size. */ public int headerSize(int ver) { switch (ver) { case FilePageStore.VERSION: return FilePageStore.HEADER_SIZE; case FilePageStoreV2.VERSION: return memCfg.getPageSize(); default: throw new IllegalArgumentException("Unknown version of file page store."); } } }
/** * @param file File. */ public FilePageStore( byte type, File file, FileIOFactory factory, DataStorageConfiguration cfg, AllocatedPageTracker allocatedTracker ) { this.type = type; this.cfgFile = file; this.dbCfg = cfg; this.ioFactory = factory; this.allocated = new AtomicLong(); this.pageSize = dbCfg.getPageSize(); this.allocatedTracker = allocatedTracker; }
/** * @param memCfg Memory config. */ protected void checkPageSize(DataStorageConfiguration memCfg) { if (memCfg.getPageSize() == 0) memCfg.setPageSize(DFLT_PAGE_SIZE); }
/** * Initializes header and writes it into the file store. * * @return Next available position in the file to store a data. * @throws IOException If initialization is failed. */ private long initFile(FileIO fileIO) throws IOException { try { ByteBuffer hdr = header(type, dbCfg.getPageSize()); fileIO.writeFully(hdr); //there is 'super' page in every file return headerSize() + dbCfg.getPageSize(); } catch (ClosedByInterruptException e) { // If thread was interrupted written header can be inconsistent. Files.delete(cfgFile.toPath()); throw e; } }
if (dbCfg.getPageSize() != pageSize) throw new IOException(prefix + "(invalid page size)" + " [expectedPageSize=" + dbCfg.getPageSize() + ", filePageSize=" + pageSize + "]");
/** * @param pageMem Page memory. * @param plcCfg Policy config. * @param sharedCtx Shared context. */ public RandomLruPageEvictionTracker( PageMemory pageMem, DataRegionConfiguration plcCfg, GridCacheSharedContext<?, ?> sharedCtx ) { super((PageMemoryNoStoreImpl)pageMem, plcCfg, sharedCtx); DataStorageConfiguration memCfg = sharedCtx.kernalContext().config().getDataStorageConfiguration(); assert plcCfg.getMaxSize() / memCfg.getPageSize() < Integer.MAX_VALUE; log = sharedCtx.logger(getClass()); }
/** * @param pageMem Page memory. * @param plcCfg Policy config. * @param sharedCtx Shared context. */ public Random2LruPageEvictionTracker( PageMemoryNoStoreImpl pageMem, DataRegionConfiguration plcCfg, GridCacheSharedContext<?, ?> sharedCtx ) { super(pageMem, plcCfg, sharedCtx); DataStorageConfiguration memCfg = sharedCtx.kernalContext().config().getDataStorageConfiguration(); assert plcCfg.getMaxSize() / memCfg.getPageSize() < Integer.MAX_VALUE; log = sharedCtx.logger(getClass()); }
/** * Create data transfer object. * * @param memCfg Memory configuration. */ public VisorMemoryConfiguration(DataStorageConfiguration memCfg) { assert memCfg != null; sysCacheInitSize = memCfg.getSystemRegionInitialSize(); sysCacheMaxSize = memCfg.getSystemRegionMaxSize(); pageSize = memCfg.getPageSize(); concLvl = memCfg.getConcurrencyLevel(); // dfltMemPlcName = memCfg.getDefaultDataRegionName(); //dfltMemPlcSize = memCfg.getDefaultDataRegionSize(); DataRegionConfiguration[] plcs = memCfg.getDataRegionConfigurations(); if (!F.isEmpty(plcs)) { memPlcs = new ArrayList<>(plcs.length); for (DataRegionConfiguration plc : plcs) memPlcs.add(new VisorMemoryPolicyConfiguration(plc)); } }
/** */ private byte[] bigArray(IgniteEx grid) { int arrSz = grid.configuration().getDataStorageConfiguration().getPageSize() * 3; byte[] bigArr = new byte[arrSz]; for (int i=0; i<bigArr.length; i++) bigArr[i] = (byte)i; return bigArr; } }
/** * Creates PageMemory with given size and memory provider. * * @param memProvider Memory provider. * @param memCfg Memory configuartion. * @param memPlcCfg data region configuration. * @param memMetrics DataRegionMetrics to collect memory usage metrics. * @return PageMemory instance. */ protected PageMemory createPageMemory( DirectMemoryProvider memProvider, DataStorageConfiguration memCfg, DataRegionConfiguration memPlcCfg, DataRegionMetricsImpl memMetrics, boolean trackable ) { memMetrics.persistenceEnabled(false); PageMemory pageMem = new PageMemoryNoStoreImpl( log, wrapMetricsMemoryProvider(memProvider, memMetrics), cctx, memCfg.getPageSize(), memPlcCfg, memMetrics, false ); memMetrics.pageMemory(pageMem); return pageMem; }
/** {@inheritDoc} */ @Override protected void checkPageSize(DataStorageConfiguration memCfg) { if (memCfg.getPageSize() == 0) { try { assert cctx.pageStore() instanceof FilePageStoreManager : "Invalid page store manager was created: " + cctx.pageStore(); Path anyIdxPartFile = IgniteUtils.searchFileRecursively( ((FilePageStoreManager)cctx.pageStore()).workDir().toPath(), FilePageStoreManager.INDEX_FILE_NAME); if (anyIdxPartFile != null) { memCfg.setPageSize(resolvePageSizeFromPartitionFile(anyIdxPartFile)); return; } } catch (IgniteCheckedException | IOException | IllegalArgumentException e) { U.quietAndWarn(log, "Attempt to resolve pageSize from store files failed: " + e.getMessage()); U.quietAndWarn(log, "Default page size will be used: " + DataStorageConfiguration.DFLT_PAGE_SIZE + " bytes"); } memCfg.setPageSize(DataStorageConfiguration.DFLT_PAGE_SIZE); } }
/** * @param rmt Remote node to check. * @throws IgniteCheckedException If check failed. */ private void checkMemoryConfiguration(ClusterNode rmt) throws IgniteCheckedException { ClusterNode locNode = ctx.discovery().localNode(); if (ctx.config().isClientMode() || locNode.isDaemon() || rmt.isClient() || rmt.isDaemon()) return; DataStorageConfiguration dsCfg = null; Object dsCfgBytes = rmt.attribute(IgniteNodeAttributes.ATTR_DATA_STORAGE_CONFIG); if (dsCfgBytes instanceof byte[]) dsCfg = new JdkMarshaller().unmarshal((byte[])dsCfgBytes, U.resolveClassLoader(ctx.config())); if (dsCfg == null) { // Try to use legacy memory configuration. MemoryConfiguration memCfg = rmt.attribute(IgniteNodeAttributes.ATTR_MEMORY_CONFIG); if (memCfg != null) { dsCfg = new DataStorageConfiguration(); // All properties that are used in validation should be converted here. dsCfg.setPageSize(memCfg.getPageSize()); } } if (dsCfg != null) { DataStorageConfiguration locDsCfg = ctx.config().getDataStorageConfiguration(); if (dsCfg.getPageSize() != locDsCfg.getPageSize()) { throw new IgniteCheckedException("Memory configuration mismatch (fix configuration or set -D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property) [rmtNodeId=" + rmt.id() + ", locPageSize = " + locDsCfg.getPageSize() + ", rmtPageSize = " + dsCfg.getPageSize() + "]"); } } }
/** * */ private void addDataStorageConfigurationAttributes() throws IgniteCheckedException { MemoryConfiguration memCfg = cfg.getMemoryConfiguration(); // Save legacy memory configuration if it's present. if (memCfg != null) { // Page size initialization is suspended, see IgniteCacheDatabaseSharedManager#checkPageSize. // We should copy initialized value from new configuration. memCfg.setPageSize(cfg.getDataStorageConfiguration().getPageSize()); add(ATTR_MEMORY_CONFIG, memCfg); } // Save data storage configuration. add(ATTR_DATA_STORAGE_CONFIG, new JdkMarshaller().marshal(cfg.getDataStorageConfiguration())); }
/** {@inheritDoc} */ @Override protected void start0() throws IgniteCheckedException { if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getDataStorageConfiguration() == null) return; DataStorageConfiguration memCfg = cctx.kernalContext().config().getDataStorageConfiguration(); assert memCfg != null; validateConfiguration(memCfg); pageSize = memCfg.getPageSize(); initDataRegions(memCfg); }
/** * @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()); } }
/** {@inheritDoc} */ @Override protected void start0() throws IgniteCheckedException { compressProc = cctx.kernalContext().compress(); CacheConfiguration cfg = cctx.config(); diskPageCompression = cfg.getDiskPageCompression(); if (diskPageCompression != null) { if (!cctx.dataRegion().config().isPersistenceEnabled()) throw new IgniteCheckedException("Disk page compression makes sense only with enabled persistence."); Integer lvl = cfg.getDiskPageCompressionLevel(); diskPageCompressLevel = lvl != null ? checkCompressionLevelBounds(lvl, diskPageCompression) : getDefaultCompressionLevel(diskPageCompression); DataStorageConfiguration dsCfg = cctx.kernalContext().config().getDataStorageConfiguration(); File dbPath = cctx.kernalContext().pdsFolderResolver().resolveFolders().persistentStoreRootPath(); assert dbPath != null; compressProc.checkPageCompressionSupported(dbPath.toPath(), dsCfg.getPageSize()); if (log.isInfoEnabled()) { log.info("Disk page compression is enabled [cache=" + cctx.name() + ", compression=" + diskPageCompression + ", level=" + diskPageCompressLevel + "]"); } } }
/** * Verifies that {@link IgniteCheckedException} is thrown when empty pages pool size is greater than * DataRegionConfiguration.getMaxSize() / DataStorageConfiguration.getPageSize() / 10. */ @Test public void testInvalidBigEmptyPagesPoolSize() { final int DFLT_PAGE_SIZE = 1024; long expectedMaxPoolSize; DataRegionConfiguration invCfg = new DataRegionConfiguration(); invCfg.setName("invCfg"); invCfg.setInitialSize(DFLT_MEM_PLC_SIZE); invCfg.setMaxSize(DFLT_MEM_PLC_SIZE); invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU); memCfg = new DataStorageConfiguration(); memCfg.setDataRegionConfigurations(invCfg); memCfg.setPageSize(DFLT_PAGE_SIZE); ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); expectedMaxPoolSize = invCfg.getMaxSize() / memCfg.getPageSize() / 10; if (expectedMaxPoolSize < Integer.MAX_VALUE) { // Setting the empty pages pool size greater than // DataRegionConfiguration.getMaxSize() / DataStorageConfiguration.getPageSize() / 10 invCfg.setEmptyPagesPoolSize((int)expectedMaxPoolSize + 1); memCfg.setDataRegionConfigurations(invCfg); checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []"); } }
pageSize = cfg.getPageSize(); concLvl = cfg.getConcurrencyLevel();