/** * @param plc data region Configuration. * @param pageMem Page memory. */ protected PageEvictionTracker createPageEvictionTracker(DataRegionConfiguration plc, PageMemory pageMem) { if (plc.getPageEvictionMode() == DataPageEvictionMode.DISABLED || plc.isPersistenceEnabled()) return new NoOpPageEvictionTracker(); assert pageMem instanceof PageMemoryNoStoreImpl : pageMem.getClass(); PageMemoryNoStoreImpl pageMem0 = (PageMemoryNoStoreImpl)pageMem; if (Boolean.getBoolean("override.fair.fifo.page.eviction.tracker")) return new FairFifoPageEvictionTracker(pageMem0, plc, cctx); switch (plc.getPageEvictionMode()) { case RANDOM_LRU: return new RandomLruPageEvictionTracker(pageMem0, plc, cctx); case RANDOM_2_LRU: return new Random2LruPageEvictionTracker(pageMem0, plc, cctx); default: return new NoOpPageEvictionTracker(); } }
/** {@inheritDoc} */ @Override protected void checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg) throws IgniteCheckedException { if (!regCfg.isPersistenceEnabled()) super.checkRegionEvictionProperties(regCfg, dbCfg); else if (regCfg.getPageEvictionMode() != DataPageEvictionMode.DISABLED) { U.warn(log, "Page eviction mode will have no effect because the oldest pages are evicted automatically " + "if Ignite persistence is enabled: " + regCfg.getName()); } }
/** * 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(); }
/** * 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(); }
/** * See {@link GridCacheMapEntry#ensureFreeSpace()} * * @param memPlc data region. */ public void ensureFreeSpace(DataRegion memPlc) throws IgniteCheckedException { if (memPlc == null) return; DataRegionConfiguration plcCfg = memPlc.config(); if (plcCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED || plcCfg.isPersistenceEnabled()) return; long memorySize = plcCfg.getMaxSize(); PageMemory pageMem = memPlc.pageMemory(); int sysPageSize = pageMem.systemPageSize(); CacheFreeListImpl freeListImpl = freeListMap.get(plcCfg.getName()); for (;;) { long allocatedPagesCnt = pageMem.loadedPages(); int emptyDataPagesCnt = freeListImpl.emptyDataPages(); boolean shouldEvict = allocatedPagesCnt > (memorySize / sysPageSize * plcCfg.getEvictionThreshold()) && emptyDataPagesCnt < plcCfg.getEmptyPagesPoolSize(); if (shouldEvict) { warnFirstEvict(plcCfg); memPlc.evictionTracker().evictDataPage(); memPlc.memoryMetrics().updateEvictionRate(); } else break; } }
/** * @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()); } }
storeCacheId = affNode && dataRegion.config().getPageEvictionMode() != DataPageEvictionMode.DISABLED;
/** * Writes the data region configuration. * * @param w Writer. */ private static void writeDataRegionConfiguration(BinaryRawWriter w, DataRegionConfiguration cfg) { assert w != null; assert cfg != null; w.writeString(cfg.getName()); w.writeBoolean(cfg.isPersistenceEnabled()); w.writeLong(cfg.getInitialSize()); w.writeLong(cfg.getMaxSize()); w.writeString(cfg.getSwapPath()); w.writeInt(cfg.getPageEvictionMode().ordinal()); w.writeDouble(cfg.getEvictionThreshold()); w.writeInt(cfg.getEmptyPagesPoolSize()); w.writeBoolean(cfg.isMetricsEnabled()); w.writeInt(cfg.getMetricsSubIntervalCount()); w.writeLong(cfg.getMetricsRateTimeInterval()); w.writeLong(cfg.getCheckpointPageBufferSize()); }
dataRegion.config().getPageEvictionMode() != DataPageEvictionMode.DISABLED) { throw new IgniteCheckedException("Data pages evictions cannot be used with TRANSACTIONAL_SNAPSHOT " + "cache atomicity mode for in-memory regions. Please, either disable evictions or enable " + "persistence for data regions with TRANSACTIONAL_SNAPSHOT caches. [cacheName=" + cc.getName() + ", dataRegionName=" + memPlcName + ", pageEvictionMode=" + dataRegion.config().getPageEvictionMode() + ']');
/** * @param plc data region Configuration. * @param pageMem Page memory. */ protected PageEvictionTracker createPageEvictionTracker(DataRegionConfiguration plc, PageMemory pageMem) { if (plc.getPageEvictionMode() == DataPageEvictionMode.DISABLED || plc.isPersistenceEnabled()) return new NoOpPageEvictionTracker(); assert pageMem instanceof PageMemoryNoStoreImpl : pageMem.getClass(); PageMemoryNoStoreImpl pageMem0 = (PageMemoryNoStoreImpl)pageMem; if (Boolean.getBoolean("override.fair.fifo.page.eviction.tracker")) return new FairFifoPageEvictionTracker(pageMem0, plc, cctx); switch (plc.getPageEvictionMode()) { case RANDOM_LRU: return new RandomLruPageEvictionTracker(pageMem0, plc, cctx); case RANDOM_2_LRU: return new Random2LruPageEvictionTracker(pageMem0, plc, cctx); default: return new NoOpPageEvictionTracker(); } }
/** {@inheritDoc} */ @Override protected void checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg) throws IgniteCheckedException { if (!regCfg.isPersistenceEnabled()) super.checkRegionEvictionProperties(regCfg, dbCfg); else if (regCfg.getPageEvictionMode() != DataPageEvictionMode.DISABLED) { U.warn(log, "Page eviction mode set for [" + regCfg.getName() + "] data will have no effect" + " because the oldest pages are evicted automatically if Ignite persistence is enabled."); } }
/** * 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(); }
/** * 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(); }
/** * See {@link GridCacheMapEntry#ensureFreeSpace()} * * @param memPlc data region. */ public void ensureFreeSpace(DataRegion memPlc) throws IgniteCheckedException { if (memPlc == null) return; DataRegionConfiguration plcCfg = memPlc.config(); if (plcCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED || plcCfg.isPersistenceEnabled()) return; long memorySize = plcCfg.getMaxSize(); PageMemory pageMem = memPlc.pageMemory(); int sysPageSize = pageMem.systemPageSize(); CacheFreeListImpl freeListImpl = freeListMap.get(plcCfg.getName()); for (;;) { long allocatedPagesCnt = pageMem.loadedPages(); int emptyDataPagesCnt = freeListImpl.emptyDataPages(); boolean shouldEvict = allocatedPagesCnt > (memorySize / sysPageSize * plcCfg.getEvictionThreshold()) && emptyDataPagesCnt < plcCfg.getEmptyPagesPoolSize(); if (shouldEvict) { warnFirstEvict(plcCfg); memPlc.evictionTracker().evictDataPage(); memPlc.memoryMetrics().updateEvictionRate(); } else break; } }
storeCacheId = affNode && dataRegion.config().getPageEvictionMode() != DataPageEvictionMode.DISABLED;
/** * @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()); } }
/** * Writes the data region configuration. * * @param w Writer. */ private static void writeDataRegionConfiguration(BinaryRawWriter w, DataRegionConfiguration cfg) { assert w != null; assert cfg != null; w.writeString(cfg.getName()); w.writeBoolean(cfg.isPersistenceEnabled()); w.writeLong(cfg.getInitialSize()); w.writeLong(cfg.getMaxSize()); w.writeString(cfg.getSwapPath()); w.writeInt(cfg.getPageEvictionMode().ordinal()); w.writeDouble(cfg.getEvictionThreshold()); w.writeInt(cfg.getEmptyPagesPoolSize()); w.writeBoolean(cfg.isMetricsEnabled()); w.writeInt(cfg.getMetricsSubIntervalCount()); w.writeLong(cfg.getMetricsRateTimeInterval()); w.writeLong(cfg.getCheckpointPageBufferSize()); }