Package org.apache.ignite.configuration

## Enum PageReplacementMode

- java.lang.Object
- - java.lang.Enum<PageReplacementMode>
  - - org.apache.ignite.configuration.PageReplacementMode

- All Implemented Interfaces:
    `Serializable`, `Comparable<PageReplacementMode>`

      public enum PageReplacementMode
      extends Enum<PageReplacementMode>

  Defines memory page replacement algorithm. A mode is set for a specific `DataRegionConfiguration`.

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant | Description
    --- | ---
    `CLOCK` | CLOCK algorithm.
    `RANDOM_LRU` | Random-LRU algorithm.
    `SEGMENTED_LRU` | Segmented-LRU algorithm.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static @Nullable PageReplacementMode` | `fromOrdinal​(int ord)` | Efficiently gets enumerated value from its ordinal.
    `static PageReplacementMode` | `valueOf​(String name)` | Returns the enum constant of this type with the specified name.
    `static PageReplacementMode[]` | `values()` | Returns an array containing the constants of this enum type, in the order they are declared.

    - ### Methods inherited from class java.lang.Enum

      `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Enum Constant Detail

    - #### RANDOM_LRU

          public static final PageReplacementMode RANDOM_LRU

      Random-LRU algorithm. Every time page is accessed, its timestamp gets updated. When a page fault occurs and it's required to replace some pages, the algorithm randomly chooses 5 pages from the page memory and evicts a page with the latest timestamp. This algorithm has zero maintenance cost, but not very effective in terms of finding the next page to replace. Recommended to use in environments, where there are no page replacements (large enough data region to store all amount of data) or page replacements are rare (See `DataRegionMetrics.getPagesReplaceRate()` metric, which can be helpful here).

    - #### SEGMENTED_LRU

          public static final PageReplacementMode SEGMENTED_LRU

      Segmented-LRU algorithm. Segmented-LRU algorithm is a scan-resistant variation of the Least Recently Used (LRU) algorithm. Segmented-LRU pages list is divided into two segments, a probationary segment, and a protected segment. Pages in each segment are ordered from the least to the most recently accessed. New pages are added to the most recently accessed end (tail) of the probationary segment. Existing pages are removed from wherever they currently reside and added to the most recently accessed end of the protected segment. Pages in the protected segment have thus been accessed at least twice. The protected segment is finite, so migration of a page from the probationary segment to the protected segment may force the migration of the LRU page in the protected segment to the most recently used end of the probationary segment, giving this page another chance to be accessed before being replaced. Page to replace is polled from the least recently accessed end (head) of the probationary segment. This algorithm requires additional memory to store pages list and need to update this list on each page access, but have near to optimal page to replace selection policy. So, there can be a little performance drop for environments without page replacement (compared to random-LRU and CLOCK), but for environments with a high rate of page replacement and a large amount of one-time scans segmented-LRU can outperform random-LRU and CLOCK.

    - #### CLOCK

          public static final PageReplacementMode CLOCK

      CLOCK algorithm. The clock algorithm keeps a circular list of pages in memory, with the "hand" pointing to the last examined page frame in the list. When a page fault occurs and no empty frames exist, then the hit flag of the page is inspected at the hand's location. If the hit flag is 0, the new page is put in place of the page the "hand" points to, and the hand is advanced one position. Otherwise, the hit flag is cleared, then the clock hand is incremented and the process is repeated until a page is replaced. This algorithm has near to zero maintenance cost and replacement policy efficiency between random-LRU and segmented-LRU.

  - ### Method Detail

    - #### values

          public static PageReplacementMode[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (PageReplacementMode c : PageReplacementMode.values())
              System.out.println(c);

      Returns:
        an array containing the constants of this enum type, in the order they are declared

    - #### valueOf

          public static PageReplacementMode valueOf​(String name)

      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
        `name` - the name of the enum constant to be returned.
      Returns:
        the enum constant with the specified name
      Throws:
        `IllegalArgumentException` - if this enum type has no constant with the specified name
        `NullPointerException` - if the argument is null

    - #### fromOrdinal

          @Nullable
          public static @Nullable PageReplacementMode fromOrdinal​(int ord)

      Efficiently gets enumerated value from its ordinal.
      Parameters:
        `ord` - Ordinal value.
      Returns:
        Enumerated value or `null` if ordinal out of range.