org.apache.ignite.configuration

## Class MemoryPolicyConfiguration

- java.lang.Object
- - org.apache.ignite.configuration.MemoryPolicyConfiguration

All Implemented Interfaces:
  Serializable

Deprecated.
Use `DataRegionConfiguration` instead.

    @Deprecated
    public final class MemoryPolicyConfiguration
    extends Object
    implements Serializable

This class allows defining custom memory policies' configurations with various parameters for Apache Ignite page memory (see `MemoryConfiguration`. For each configured memory policy Apache Ignite instantiates respective memory regions with different parameters like maximum size, eviction policy, swapping options, etc. An Apache Ignite cache can be mapped to a particular policy using `CacheConfiguration.setMemoryPolicyName(String)` method.

Sample configuration below shows how to configure several memory policies:

         <property name="memoryConfiguration">
             <bean class="org.apache.ignite.configuration.MemoryConfiguration">
                 <property name="defaultMemoryPolicyName" value="Default_Region"/>
                 <property name="pageSize" value="4096"/>

                 <property name="memoryPolicies">
                     <list>
                          <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
                              <property name="name" value="Default_Region"/>
                              <property name="initialSize" value="#{100L * 1024 * 1024}"/>
                          </bean>

                          <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration">
                              <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.MemoryPolicyConfiguration">
                              <property name="name" value="25MB_Region_Swapping"/>
                              <property name="initialSize" value="#{25L * 1024 * 1024}"/>
                              <property name="maxSize" value="#{100L * 1024 * 1024}"/>
                              <property name="swapFilePath" value="memoryPolicyExampleSwap"/>
                          </bean>
                      </list>
                  </property>

See Also:
  Serialized Form

### Field Summary

Fields
`static boolean` `DFLT_METRICS_ENABLED` Deprecated. Default metrics enabled flag.
`static int` `DFLT_RATE_TIME_INTERVAL_MILLIS` Deprecated. Default length of interval over which `MemoryMetrics.getAllocationRate()` metric is calculated.
`static int` `DFLT_SUB_INTERVALS` Deprecated. Default amount of sub intervals to calculate `MemoryMetrics.getAllocationRate()` metric.

### Constructor Summary

Constructors
Constructor and Description
`MemoryPolicyConfiguration()` Deprecated.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`int` `getEmptyPagesPoolSize()` Deprecated. Specifies the minimal number of empty pages to be present in reuse lists for this memory policy.
`double` `getEvictionThreshold()` Deprecated. Gets a threshold for memory pages eviction initiation.
`long` `getInitialSize()` Deprecated. Gets initial memory region size defined by this memory policy.
`long` `getMaxSize()` Deprecated. Maximum memory region size defined by this memory policy.
`String` `getName()` Deprecated. Gets memory policy name.
`DataPageEvictionMode` `getPageEvictionMode()` Deprecated. Gets memory pages eviction mode.
`long` `getRateTimeInterval()` Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
`int` `getSubIntervals()` Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
`String` `getSwapFilePath()` Deprecated. A path to the memory-mapped files the memory region defined by this memory policy will be mapped to.
`boolean` `isMetricsEnabled()` Deprecated. Gets whether memory metrics are enabled by default on node startup.
`MemoryPolicyConfiguration` `setEmptyPagesPoolSize(int emptyPagesPoolSize)` Deprecated. Specifies the minimal number of empty pages to be present in reuse lists for this memory policy.
`MemoryPolicyConfiguration` `setEvictionThreshold(double evictionThreshold)` Deprecated. Sets memory pages eviction threshold.
`MemoryPolicyConfiguration` `setInitialSize(long initialSize)` Deprecated. Sets initial memory region size defined by this memory policy.
`MemoryPolicyConfiguration` `setMaxSize(long maxSize)` Deprecated. Sets maximum memory region size defined by this memory policy.
`MemoryPolicyConfiguration` `setMetricsEnabled(boolean metricsEnabled)` Deprecated. Sets memory metrics enabled flag.
`MemoryPolicyConfiguration` `setName(String name)` Deprecated. Sets memory policy name.
`MemoryPolicyConfiguration` `setPageEvictionMode(DataPageEvictionMode evictionMode)` Deprecated. Sets memory pages eviction mode.
`MemoryPolicyConfiguration` `setRateTimeInterval(long rateTimeInterval)` Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
`MemoryPolicyConfiguration` `setSubIntervals(int subIntervals)` Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
`MemoryPolicyConfiguration` `setSwapFilePath(String swapFilePath)` Deprecated. Sets a path to the memory-mapped file.
`String` `toString()` Deprecated.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DFLT_METRICS_ENABLED

    public static final boolean DFLT_METRICS_ENABLED

Deprecated.
Default metrics enabled flag.

See Also:
  Constant Field Values

#### DFLT_SUB_INTERVALS

    public static final int DFLT_SUB_INTERVALS

Deprecated.
Default amount of sub intervals to calculate `MemoryMetrics.getAllocationRate()` metric.

See Also:
  Constant Field Values

#### DFLT_RATE_TIME_INTERVAL_MILLIS

    public static final int DFLT_RATE_TIME_INTERVAL_MILLIS

Deprecated.
Default length of interval over which `MemoryMetrics.getAllocationRate()` metric is calculated.

See Also:
  Constant Field Values

### Constructor Detail

#### MemoryPolicyConfiguration

    public MemoryPolicyConfiguration()

Deprecated.

### Method Detail

#### getName

    public String getName()

Deprecated.
Gets memory policy name.

Returns:
  Memory policy name.

#### setName

    public MemoryPolicyConfiguration setName(String name)

Deprecated.
Sets memory policy name. The name must be non empty and must not be equal to the reserved 'sysMemPlc' one. If not specified, `MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME` value is used.

Parameters:
  `name` - Memory policy name.
Returns:
  `this` for chaining.

#### getMaxSize

    public long getMaxSize()

Deprecated.
Maximum memory region size defined by this memory policy. 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 MemoryPolicyConfiguration setMaxSize(long maxSize)

Deprecated.
Sets maximum memory region size defined by this memory policy. The total size should not be less than 10 MB due to the internal data structures overhead.

Parameters:
  `maxSize` - Maximum memory policy size in bytes.
Returns:
  `this` for chaining.

#### getInitialSize

    public long getInitialSize()

Deprecated.
Gets initial memory region size defined by this memory policy. When the used memory size exceeds this value, new chunks of memory will be allocated.

Returns:
  Memory policy start size.

#### setInitialSize

    public MemoryPolicyConfiguration setInitialSize(long initialSize)

Deprecated.
Sets initial memory region size defined by this memory policy. When the used memory size exceeds this value, new chunks of memory will be allocated.

Parameters:
  `initialSize` - Memory policy initial size.
Returns:
  `this` for chaining.

#### getSwapFilePath

    public String getSwapFilePath()

Deprecated.
A path to the memory-mapped files the memory region defined by this memory policy 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 `null` if this feature is not used for the memory region defined by this memory policy.

#### setSwapFilePath

    public MemoryPolicyConfiguration setSwapFilePath(String swapFilePath)

Deprecated.
Sets a path to the memory-mapped file.

Parameters:
  `swapFilePath` - A Path to the memory mapped file.
Returns:
  `this` for chaining.

#### getPageEvictionMode

    public DataPageEvictionMode getPageEvictionMode()

Deprecated.
Gets memory pages eviction mode. If `DataPageEvictionMode.DISABLED` is used (default) then an out of memory exception will be thrown if the memory region usage, defined by this memory policy, goes beyond its capacity which is `getMaxSize()`.

Returns:
  Memory pages eviction algorithm. `DataPageEvictionMode.DISABLED` used by default.

#### setPageEvictionMode

    public MemoryPolicyConfiguration setPageEvictionMode(DataPageEvictionMode evictionMode)

Deprecated.
Sets memory pages eviction mode.

Parameters:
  `evictionMode` - Eviction mode.
Returns:
  `this` for chaining.

#### getEvictionThreshold

    public double getEvictionThreshold()

Deprecated.
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 memory region (defined by this policy) is occupied.

Returns:
  Memory pages eviction threshold.

#### setEvictionThreshold

    public MemoryPolicyConfiguration setEvictionThreshold(double evictionThreshold)

Deprecated.
Sets memory pages eviction threshold.

Parameters:
  `evictionThreshold` - Eviction threshold.
Returns:
  `this` for chaining.

#### getEmptyPagesPoolSize

    public int getEmptyPagesPoolSize()

Deprecated.
Specifies the minimal number of empty pages to be present in reuse lists for this memory policy. 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 if `IgniteOutOfMemoryException` occurred with enabled page eviction.

Returns:
  Minimum number of empty pages in reuse list.

#### setEmptyPagesPoolSize

    public MemoryPolicyConfiguration setEmptyPagesPoolSize(int emptyPagesPoolSize)

Deprecated.
Specifies the minimal number of empty pages to be present in reuse lists for this memory policy. 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 if `IgniteOutOfMemoryException` occurred with enabled page eviction.

Parameters:
  `emptyPagesPoolSize` - Empty pages pool size.
Returns:
  `this` for chaining.

#### isMetricsEnabled

    public boolean isMetricsEnabled()

Deprecated.
Gets whether memory metrics are enabled by default on node startup. Memory metrics can be enabled and disabled at runtime via memory metrics `MX bean`.

Returns:
  Metrics enabled flag.

#### setMetricsEnabled

    public MemoryPolicyConfiguration setMetricsEnabled(boolean metricsEnabled)

Deprecated.
Sets memory metrics enabled flag. If this flag is `true`, metrics will be enabled on node startup. Memory metrics can be enabled and disabled at runtime via memory metrics `MX bean`.

Parameters:
  `metricsEnabled` - Metrics enabled flag.
Returns:
  `this` for chaining.

#### getRateTimeInterval

    @Deprecated
    public long getRateTimeInterval()

Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
Gets time interval for `MemoryMetrics.getAllocationRate()` and `MemoryMetrics.getEvictionRate()` monitoring purposes.

For instance, after setting the interval to 60_000 milliseconds, subsequent calls to `MemoryMetrics.getAllocationRate()` will return average allocation rate (pages per second) for the last minute.

Returns:
  Time interval over which allocation rate is calculated.

#### setRateTimeInterval

    @Deprecated
    public MemoryPolicyConfiguration setRateTimeInterval(long rateTimeInterval)

Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
Sets time interval for `MemoryMetrics.getAllocationRate()` and `MemoryMetrics.getEvictionRate()` monitoring purposes.

For instance, after setting the interval to 60 seconds, subsequent calls to `MemoryMetrics.getAllocationRate()` will return average allocation rate (pages per second) for the last minute.

Parameters:
  `rateTimeInterval` - Time interval used for allocation and eviction rates calculations.
Returns:
  `this` for chaining.

#### getSubIntervals

    @Deprecated
    public int getSubIntervals()

Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
Gets a number of sub-intervals the whole `setRateTimeInterval(long)` will be split into to calculate `MemoryMetrics.getAllocationRate()` and `MemoryMetrics.getEvictionRate()` rates (5 by default).

Setting it to a bigger value will result in more precise calculation and smaller drops of `MemoryMetrics.getAllocationRate()` metric when next sub-interval has to be recycled but introduces bigger calculation overhead.

Returns:
  number of sub intervals.

#### setSubIntervals

    @Deprecated
    public MemoryPolicyConfiguration setSubIntervals(int subIntervals)

Deprecated. Use `MetricsMxBean.configureHitRateMetric(String, long)` instead.
Sets a number of sub-intervals the whole `setRateTimeInterval(long)` will be split into to calculate `MemoryMetrics.getAllocationRate()` and `MemoryMetrics.getEvictionRate()` rates (5 by default).

Setting it to a bigger value will result in more precise calculation and smaller drops of `MemoryMetrics.getAllocationRate()` metric when next sub-interval has to be recycled but introduces bigger calculation overhead.

Parameters:
  `subIntervals` - A number of sub-intervals.
Returns:
  `this` for chaining.

#### toString

    public String toString()

Deprecated.

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022