Class DataRegionConfiguration
- java.lang.Object
-
- org.apache.ignite.configuration.DataRegionConfiguration
-
- All Implemented Interfaces:
Serializable
public final class DataRegionConfiguration extends Object implements Serializable
This class allows defining custom data regions' configurations with various parameters for Apache Ignite page memory (seeDataStorageConfiguration. For each configured data region Apache Ignite instantiates respective memory regions with different parameters like maximum size, eviction policy, swapping options, persistent mode flag, etc. An Apache Ignite cache can be mapped to a particular region usingCacheConfiguration.setDataRegionName(String)method.Sample configuration below shows how to configure several data regions:
<property name="memoryConfiguration"> <bean class="org.apache.ignite.configuration.DataStorageConfiguration"> <property name="defaultRegionConfiguration"> <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> <property name="name" value="Default_Region"/> <property name="initialSize" value="#{100L * 1024 * 1024}"/> <property name="maxSize" value="#{5L * 1024 * 1024 * 1024}"/> </bean> </property> <property name="pageSize" value="4096"/> <property name="dataRegions"> <list> <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> <property name="name" value="20MB_Region_Eviction"/> <property name="initialSize" value="#{20L * 1024 * 1024}"/> <property name="pageEvictionMode" value="RANDOM_2_LRU"/> </bean> <bean class="org.apache.ignite.configuration.DataRegionConfiguration"> <property name="name" value="25MB_Region_Swapping"/> <property name="initialSize" value="#{25L * 1024 * 1024}"/> <property name="maxSize" value="#{100L * 1024 * 1024}"/> <property name="swapPath" value="db/swap"/> </bean> </list> </property>- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDFLT_METRICS_ENABLEDDefault metrics enabled flag.static PageReplacementModeDFLT_PAGE_REPLACEMENT_MODEDefault page replacement mode.static intDFLT_RATE_TIME_INTERVAL_MILLISDefault length of interval over whichDataRegionMetrics.getAllocationRate()metric is calculated.static intDFLT_SUB_INTERVALSDefault amount of sub intervals to calculateDataRegionMetrics.getAllocationRate()metric.
-
Constructor Summary
Constructors Constructor Description DataRegionConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description longgetCheckpointPageBufferSize()Gets amount of memory allocated for a checkpoint temporary buffer.intgetEmptyPagesPoolSize()Specifies the minimal number of empty pages to be present in reuse lists for this data region.doublegetEvictionThreshold()Gets a threshold for memory pages eviction initiation.longgetInitialSize()Gets initial memory region size defined by this data region.longgetMaxSize()Maximum memory region size defined by this data region.@Nullable MemoryAllocatorgetMemoryAllocator()longgetMetricsRateTimeInterval()Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.intgetMetricsSubIntervalCount()Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.StringgetName()Gets data region name.DataPageEvictionModegetPageEvictionMode()Gets memory pages eviction mode.PageReplacementModegetPageReplacementMode()Gets memory pages replacement mode.StringgetSwapPath()A path to the memory-mapped files the memory region defined by this data region will be mapped to.@Nullable WarmUpConfigurationgetWarmUpConfiguration()Gets warm-up configuration.booleanisCdcEnabled()Gets flag indicating whether CDC is enabled.booleanisLazyMemoryAllocation()booleanisMetricsEnabled()Gets whether memory metrics are enabled by default on node startup.booleanisPersistenceEnabled()Gets whether persistence is enabled for this data region.DataRegionConfigurationsetCdcEnabled(boolean cdcEnabled)Sets flag indicating whether CDC enabled.DataRegionConfigurationsetCheckpointPageBufferSize(long checkpointPageBufSize)Sets amount of memory allocated for the checkpoint temporary buffer.DataRegionConfigurationsetEmptyPagesPoolSize(int emptyPagesPoolSize)Specifies the minimal number of empty pages to be present in reuse lists for this data region.DataRegionConfigurationsetEvictionThreshold(double evictionThreshold)Sets memory pages eviction threshold.DataRegionConfigurationsetInitialSize(long initSize)Sets initial memory region size defined by this data region.DataRegionConfigurationsetLazyMemoryAllocation(boolean lazyMemoryAllocation)SetslazyMemoryAllocationflag value.DataRegionConfigurationsetMaxSize(long maxSize)Sets maximum memory region size defined by this data region.DataRegionConfigurationsetMemoryAllocator(MemoryAllocator allocator)Sets memory allocator.DataRegionConfigurationsetMetricsEnabled(boolean metricsEnabled)Sets memory metrics enabled flag.DataRegionConfigurationsetMetricsRateTimeInterval(long metricsRateTimeInterval)Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.DataRegionConfigurationsetMetricsSubIntervalCount(int metricsSubIntervalCnt)Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.DataRegionConfigurationsetName(String name)Sets data region name.DataRegionConfigurationsetPageEvictionMode(DataPageEvictionMode evictionMode)Sets memory pages eviction mode.DataRegionConfigurationsetPageReplacementMode(PageReplacementMode replacementMode)Sets memory pages replacement mode.DataRegionConfigurationsetPersistenceEnabled(boolean persistenceEnabled)Sets persistence enabled flag.DataRegionConfigurationsetSwapPath(String swapPath)Sets a path to the memory-mapped files.DataRegionConfigurationsetWarmUpConfiguration(@Nullable WarmUpConfiguration warmUpCfg)Sets warm-up configuration.StringtoString()
-
-
-
Field Detail
-
DFLT_METRICS_ENABLED
public static final boolean DFLT_METRICS_ENABLED
Default metrics enabled flag.- See Also:
- Constant Field Values
-
DFLT_SUB_INTERVALS
public static final int DFLT_SUB_INTERVALS
Default amount of sub intervals to calculateDataRegionMetrics.getAllocationRate()metric.- See Also:
- Constant Field Values
-
DFLT_RATE_TIME_INTERVAL_MILLIS
public static final int DFLT_RATE_TIME_INTERVAL_MILLIS
Default length of interval over whichDataRegionMetrics.getAllocationRate()metric is calculated.- See Also:
- Constant Field Values
-
DFLT_PAGE_REPLACEMENT_MODE
public static final PageReplacementMode DFLT_PAGE_REPLACEMENT_MODE
Default page replacement mode.
-
-
Method Detail
-
getName
public String getName()
Gets data region name.- Returns:
- Data region name.
-
setName
public DataRegionConfiguration setName(String name)
Sets data region name. The name must be non empty and must not be equal to the reserved 'sysMemPlc' one. If not specified,DataStorageConfiguration.DFLT_DATA_REG_DEFAULT_NAMEvalue is used.- Parameters:
name- Data region name.- Returns:
thisfor chaining.
-
getMaxSize
public long getMaxSize()
Maximum memory region size defined by this data region. If the whole data can not fit into the memory region an out of memory exception will be thrown.- Returns:
- Size in bytes.
-
setMaxSize
public DataRegionConfiguration setMaxSize(long maxSize)
Sets maximum memory region size defined by this data region. The total size should not be less than 10 MB due to the internal data structures overhead.- Parameters:
maxSize- Maximum data region size in bytes.- Returns:
thisfor chaining.
-
getInitialSize
public long getInitialSize()
Gets initial memory region size defined by this data region. When the used memory size exceeds this value, new chunks of memory will be allocated.- Returns:
- Data region start size.
-
setInitialSize
public DataRegionConfiguration setInitialSize(long initSize)
Sets initial memory region size defined by this data region. When the used memory size exceeds this value, new chunks of memory will be allocated.- Parameters:
initSize- Data region initial size.- Returns:
thisfor chaining.
-
getSwapPath
public String getSwapPath()
A path to the memory-mapped files the memory region defined by this data region will be mapped to. Having the path set, allows relying on swapping capabilities of an underlying operating system for the memory region.- Returns:
- A path to the memory-mapped files or
nullif this feature is not used for the memory region defined by this data region.
-
setSwapPath
public DataRegionConfiguration setSwapPath(String swapPath)
Sets a path to the memory-mapped files.- Parameters:
swapPath- A Path to the memory mapped file.- Returns:
thisfor chaining.
-
getMemoryAllocator
@Nullable public @Nullable MemoryAllocator getMemoryAllocator()
- Returns:
- Memory allocator instance.
-
setMemoryAllocator
public DataRegionConfiguration setMemoryAllocator(MemoryAllocator allocator)
Sets memory allocator. If not specified, default, based onUnsafeallocator will be used.- Parameters:
allocator- Memory allocator instance.- Returns:
thisfor chaining.
-
getPageEvictionMode
public DataPageEvictionMode getPageEvictionMode()
Gets memory pages eviction mode. IfDataPageEvictionMode.DISABLEDis used (default) then an out of memory exception will be thrown if the memory region usage, defined by this data region, goes beyond its capacity which isgetMaxSize(). Note: Page eviction is used only when persistence is disabled for data region. For persistent data regions see page replacement mode (getPageReplacementMode()).- Returns:
- Memory pages eviction algorithm.
DataPageEvictionMode.DISABLEDused by default.
-
setPageEvictionMode
public DataRegionConfiguration setPageEvictionMode(DataPageEvictionMode evictionMode)
Sets memory pages eviction mode.- Parameters:
evictionMode- Eviction mode.- Returns:
thisfor chaining.
-
getPageReplacementMode
public PageReplacementMode getPageReplacementMode()
Gets memory pages replacement mode. If persistence is enabled and Ignite store on disk more data then available data region memory (getMaxSize()) page replacement can be started to rotate memory pages with the disk. This parameter defines the algorithm to find pages to replace. Note: For not persistent data regions see page eviction mode (getPageEvictionMode()).- Returns:
- Memory pages replacement algorithm.
PageReplacementMode.CLOCKused by default.
-
setPageReplacementMode
public DataRegionConfiguration setPageReplacementMode(PageReplacementMode replacementMode)
Sets memory pages replacement mode.- Parameters:
replacementMode- Page replacement mode.- Returns:
thisfor chaining.
-
getEvictionThreshold
public double getEvictionThreshold()
Gets a threshold for memory pages eviction initiation. For instance, if the threshold is 0.9 it means that the page memory will start the eviction only after 90% of the data region is occupied.- Returns:
- Memory pages eviction threshold.
-
setEvictionThreshold
public DataRegionConfiguration setEvictionThreshold(double evictionThreshold)
Sets memory pages eviction threshold.- Parameters:
evictionThreshold- Eviction threshold.- Returns:
thisfor chaining.
-
getEmptyPagesPoolSize
public int getEmptyPagesPoolSize()
Specifies the minimal number of empty pages to be present in reuse lists for this data region. This parameter ensures that Ignite will be able to successfully evict old data entries when the size of (key, value) pair is slightly larger than page size / 2. Increase this parameter if cache can contain very big entries (total size of pages in this pool should be enough to contain largest cache entry). Increase this parameter ifIgniteOutOfMemoryExceptionoccurred with enabled page eviction.- Returns:
- Minimum number of empty pages in reuse list.
-
setEmptyPagesPoolSize
public DataRegionConfiguration setEmptyPagesPoolSize(int emptyPagesPoolSize)
Specifies the minimal number of empty pages to be present in reuse lists for this data region. This parameter ensures that Ignite will be able to successfully evict old data entries when the size of (key, value) pair is slightly larger than page size / 2. Increase this parameter if cache can contain very big entries (total size of pages in this pool should be enough to contain largest cache entry). Increase this parameter ifIgniteOutOfMemoryExceptionoccurred with enabled page eviction.- Parameters:
emptyPagesPoolSize- Empty pages pool size.- Returns:
thisfor chaining.
-
isMetricsEnabled
public boolean isMetricsEnabled()
Gets whether memory metrics are enabled by default on node startup. Memory metrics can be enabled and disabled at runtime via memory metrics "name=io.dataregion.{data_region_name}" mx bean.- Returns:
- Metrics enabled flag.
-
setMetricsEnabled
public DataRegionConfiguration setMetricsEnabled(boolean metricsEnabled)
Sets memory metrics enabled flag. If this flag istrue, metrics will be enabled on node startup. Memory metrics can be enabled and disabled at runtime via memory metrics "name=io.dataregion.{data_region_name}" mx bean.- Parameters:
metricsEnabled- Metrics enabled flag.- Returns:
thisfor chaining.
-
isPersistenceEnabled
public boolean isPersistenceEnabled()
Gets whether persistence is enabled for this data region. All caches residing in this region will be persistent.- Returns:
- Persistence enabled flag.
-
setPersistenceEnabled
public DataRegionConfiguration setPersistenceEnabled(boolean persistenceEnabled)
Sets persistence enabled flag.- Parameters:
persistenceEnabled- Persistence enabled flag.- Returns:
thisfor chaining.
-
getMetricsRateTimeInterval
@Deprecated public long getMetricsRateTimeInterval()
Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.Gets time interval forDataRegionMetrics.getAllocationRate()andDataRegionMetrics.getEvictionRate()monitoring purposes.For instance, after setting the interval to 60_000 milliseconds, subsequent calls to
DataRegionMetrics.getAllocationRate()will return average allocation rate (pages per second) for the last minute.- Returns:
- Time interval over which allocation rate is calculated.
-
setMetricsRateTimeInterval
@Deprecated public DataRegionConfiguration setMetricsRateTimeInterval(long metricsRateTimeInterval)
Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.Sets time interval forDataRegionMetrics.getAllocationRate()andDataRegionMetrics.getEvictionRate()monitoring purposes.For instance, after setting the interval to 60 seconds, subsequent calls to
DataRegionMetrics.getAllocationRate()will return average allocation rate (pages per second) for the last minute.- Parameters:
metricsRateTimeInterval- Time interval used for allocation and eviction rates calculations.- Returns:
thisfor chaining.
-
getMetricsSubIntervalCount
@Deprecated public int getMetricsSubIntervalCount()
Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.Gets a number of sub-intervals the wholesetMetricsRateTimeInterval(long)will be split into to calculateDataRegionMetrics.getAllocationRate()andDataRegionMetrics.getEvictionRate()rates (5 by default).Setting it to a bigger value will result in more precise calculation and smaller drops of
DataRegionMetrics.getAllocationRate()metric when next sub-interval has to be recycled but introduces bigger calculation overhead.- Returns:
- number of sub intervals.
-
setMetricsSubIntervalCount
@Deprecated public DataRegionConfiguration setMetricsSubIntervalCount(int metricsSubIntervalCnt)
Deprecated.UseMetricsMxBean.configureHitRateMetric(String, long)instead.Sets a number of sub-intervals the wholesetMetricsRateTimeInterval(long)will be split into to calculateDataRegionMetrics.getAllocationRate()andDataRegionMetrics.getEvictionRate()rates (5 by default).Setting it to a bigger value will result in more precise calculation and smaller drops of
DataRegionMetrics.getAllocationRate()metric when next sub-interval has to be recycled but introduces bigger calculation overhead.- Parameters:
metricsSubIntervalCnt- A number of sub-intervals.- Returns:
thisfor chaining.
-
getCheckpointPageBufferSize
public long getCheckpointPageBufferSize()
Gets amount of memory allocated for a checkpoint temporary buffer.- Returns:
- Checkpoint page buffer size in bytes or
0for Ignite to choose the buffer size automatically.
-
setCheckpointPageBufferSize
public DataRegionConfiguration setCheckpointPageBufferSize(long checkpointPageBufSize)
Sets amount of memory allocated for the checkpoint temporary buffer. The buffer is used to create temporary copies of pages that are being written to disk and being update in parallel while the checkpoint is in progress.- Parameters:
checkpointPageBufSize- Checkpoint page buffer size in bytes or0for Ignite to choose the buffer size automatically.- Returns:
thisfor chaining.
-
isLazyMemoryAllocation
public boolean isLazyMemoryAllocation()
- Returns:
Trueif memory forDataRegionwill be allocated only on the creation of the first cache belonged to thisDataRegion.
-
setLazyMemoryAllocation
public DataRegionConfiguration setLazyMemoryAllocation(boolean lazyMemoryAllocation)
SetslazyMemoryAllocationflag value. Iftrue, memory forDataRegionwill be allocated only on the creation of the first cache belonged to thisDataRegion.- Parameters:
lazyMemoryAllocation- Flag value.- Returns:
thisfor chaining.
-
setWarmUpConfiguration
public DataRegionConfiguration setWarmUpConfiguration(@Nullable @Nullable WarmUpConfiguration warmUpCfg)
Sets warm-up configuration.- Parameters:
warmUpCfg- Warm-up configuration. Can benull(defaultDataStorageConfiguration.getDefaultWarmUpConfiguration()will be used).- Returns:
thisfor chaining.
-
getWarmUpConfiguration
@Nullable public @Nullable WarmUpConfiguration getWarmUpConfiguration()
Gets warm-up configuration.- Returns:
- Warm-up configuration.
-
setCdcEnabled
public DataRegionConfiguration setCdcEnabled(boolean cdcEnabled)
Sets flag indicating whether CDC enabled.- Parameters:
cdcEnabled- CDC enabled flag.- Returns:
thisfor chaining.
-
isCdcEnabled
public boolean isCdcEnabled()
Gets flag indicating whether CDC is enabled. Default value isfalse.- Returns:
- CDC enabled flag.
-
-