Class PageMemoryImpl

java.lang.Object
org.apache.ignite.internal.pagemem.PageMemoryImpl
All Implemented Interfaces:
PageMemory

public class PageMemoryImpl extends Object implements PageMemory
Page header structure is described by the following diagram. When page is not allocated (in a free list):
 +--------+------------------------------------------------------+
 |8 bytes |         PAGE_SIZE + PAGE_OVERHEAD - 8 bytes          |
 +--------+------------------------------------------------------+
 |Next ptr|                      Page data                       |
 +--------+------------------------------------------------------+
 

When page is allocated and is in use:

 +------------------+--------+--------+---------+---------+----+--------+--------+----------------------+
 |     8 bytes      |8 bytes |4 bytes |4 bytes  |4 bytes  |4 b |8 bytes |8 bytes |       PAGE_SIZE      |
 +------------------+--------+--------+---------+---------+----+--------+--------+----------------------+
 | Marker/Timestamp |Rel ptr |Page ID | (align) |Store ID |PIN | LOCK   |TMP BUF |       Page data      |
 +------------------+--------+--------+---------+---------+----+--------+--------+----------------------+
 
Note that first 8 bytes of page header are used either for page marker or for next relative pointer depending on whether the page is in use or not.
  • Field Details

    • PAGE_LOCK_OFFSET

      public static final int PAGE_LOCK_OFFSET
      Page lock offset.
      See Also:
    • PAGE_OVERHEAD

      public static final int PAGE_OVERHEAD
      8b Marker/timestamp 8b Relative pointer 4b Page ID 4b Store ID 4b Pin count 8b Lock 8b Temporary buffer
      See Also:
    • RANDOM_PAGES_EVICT_NUM

      public static final int RANDOM_PAGES_EVICT_NUM
      Number of random pages that will be picked for eviction.
      See Also:
    • DFLT_DELAYED_REPLACED_PAGE_WRITE

      public static final boolean DFLT_DELAYED_REPLACED_PAGE_WRITE
      See Also:
    • DFLT_LOADED_PAGES_BACKWARD_SHIFT_MAP

      public static final boolean DFLT_LOADED_PAGES_BACKWARD_SHIFT_MAP
      See Also:
    • CHECKPOINT_POOL_OVERFLOW_ERROR_MSG

      public static final String CHECKPOINT_POOL_OVERFLOW_ERROR_MSG
      Checkpoint pool overflow error message.
      See Also:
    • DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE

      public static final Long DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE
      Minimum checkpointing page buffer size (may be adjusted by Ignite).
    • DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE

      public static final Long DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE
      Default minimum checkpointing page buffer size (may be adjusted by Ignite).
  • Constructor Details

  • Method Details

    • start

      public void start() throws IgniteCheckedException
      Description copied from interface: PageMemory
      Start page memory.
      Specified by:
      start in interface PageMemory
      Throws:
      IgniteCheckedException
    • stop

      public void stop() throws IgniteCheckedException
      Description copied from interface: PageMemory
      Stop page memory.
      Specified by:
      stop in interface PageMemory
      Throws:
      IgniteCheckedException
    • startStore

      public void startStore(int grpId, int metaPageTag, Path path, boolean restorationMode) throws IgniteCheckedException
      Description copied from interface: PageMemory
      Starts the store with the specified ID.
      Specified by:
      startStore in interface PageMemory
      Parameters:
      grpId - Group ID.
      metaPageTag - Meta-page tag.
      path - Store path.
      restorationMode - Flag indicating restoration mode.
      Throws:
      IgniteCheckedException
    • stopStore

      public void stopStore(int grpId, boolean freePages) throws IgniteCheckedException
      Description copied from interface: PageMemory
      Stops the store with the specified ID.
      Specified by:
      stopStore in interface PageMemory
      Throws:
      IgniteCheckedException
    • totalPages

      public long totalPages()
      Description copied from interface: PageMemory
      Total pages can be placed to memory.
      Specified by:
      totalPages in interface PageMemory
    • allocatePage

      public int allocatePage(int grpId, int tag) throws IgniteCheckedException
      Description copied from interface: PageMemory
      Allocates a page from the space for the given partition ID and the given flags.
      Specified by:
      allocatePage in interface PageMemory
      tag - Tag.
      Returns:
      page ID within the store.
      Throws:
      IgniteCheckedException - If failed.
    • metaPageId

      public int metaPageId(int grpId)
      Description copied from interface: PageMemory
      Gets or allocates metadata page for specified grpId.
      Specified by:
      metaPageId in interface PageMemory
      Parameters:
      grpId - Group ID.
      Returns:
      Meta page ID for the store.
    • acquirePage

      public long acquirePage(int grpId, int pageId, int tag) throws IgniteCheckedException
      Description copied from interface: PageMemory
      Gets the page absolute pointer associated with the given page ID. Each page obtained with this method must be released by calling #releasePage(int, long, long).

      An invocation of this method behaves exactly like the invocation acquirePage(grpId, pageId, false).

      Specified by:
      acquirePage in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID.
      tag - Tag.
      Returns:
      Page pointer.
      Throws:
      IgniteCheckedException - If failed.
    • acquirePage

      public long acquirePage(int grpId, int pageId, int tag, boolean restore) throws IgniteCheckedException
      Description copied from interface: PageMemory
      Gets the page absolute pointer associated with the given page ID. Each page obtained with this method must be released by calling #releasePage(int, long, long).
      Specified by:
      acquirePage in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID.
      tag - Tag.
      restore - Whether the page is acquired for restoration.
      Returns:
      Page pointer.
      Throws:
      IgniteCheckedException - If failed.
    • releasePage

      public void releasePage(int grpId, int pageId, long page)
      Specified by:
      releasePage in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID to release.
      page - Page pointer.
    • readLock

      public long readLock(int grpId, int pageId, long absPtr, int tag, boolean touch)
      Specified by:
      readLock in interface PageMemory
      pageId - Page ID.
      absPtr - Absolute pointer to read lock.
      tag - Tag.
      touch - Update page timestamp.
      Returns:
      Pointer to the page read buffer.
    • readUnlock

      public void readUnlock(int grpId, int pageId, long page)
      Description copied from interface: PageMemory
      Releases locked page.
      Specified by:
      readUnlock in interface PageMemory
      Parameters:
      grpId - Cache group ID.
      pageId - Page ID.
      page - Page pointer.
    • writeLock

      public long writeLock(int grpId, int pageId, long page, int tag)
      Specified by:
      writeLock in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID.
      page - Absolute pointer to read lock.
      tag - Tag.
      Returns:
      Pointer to the page read buffer.
    • tryWriteLock

      public long tryWriteLock(int grpId, int pageId, long page, int tag)
      Specified by:
      tryWriteLock in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID.
      page - Absolute pointer to read lock.
      tag - Tag.
      Returns:
      Pointer to the page read buffer.
    • writeUnlock

      public void writeUnlock(int grpId, int pageId, long page, boolean modified, int tag)
      Specified by:
      writeUnlock in interface PageMemory
      Parameters:
      grpId - Group ID.
      pageId - Page ID.
      page - Absolute pointer to read lock.
      modified - Flag indicating whether the page was modified.
      tag - Tag.
    • isDirty

      public boolean isDirty(int grpId, int pageId, long page)
      Specified by:
      isDirty in interface PageMemory
      Parameters:
      grpId - Cache group ID.
      pageId - Page ID.
      page - Page pointer.
      Returns:
      true if the page is dirty.
    • beginCheckpoint

      public void beginCheckpoint() throws IgniteException
      Description copied from interface: PageMemory
      Begins a checkpoint.
      Specified by:
      beginCheckpoint in interface PageMemory
      Throws:
      IgniteException
    • finishCheckpoint

      public void finishCheckpoint()
      Description copied from interface: PageMemory
      Finishes a checkpoint.
      Specified by:
      finishCheckpoint in interface PageMemory
    • runCheckpoint

      public void runCheckpoint() throws IgniteCheckedException
      Description copied from interface: PageMemory
      Runs a checkpoint.
      Specified by:
      runCheckpoint in interface PageMemory
      Throws:
      IgniteCheckedException
    • safeToUpdate

      public boolean safeToUpdate()
      Description copied from interface: PageMemory
      Heuristic method which allows a thread to check if it safe to start memory struture modifications in regard with checkpointing. May return false-negative result during or after partition eviction.
      Specified by:
      safeToUpdate in interface PageMemory
      Returns:
      False if there are too many dirty pages and a thread should wait for a checkpoint to begin.
    • reduceMemoryFootprint

      public void reduceMemoryFootprint() throws IgniteCheckedException
      Description copied from interface: PageMemory
      Reduces memory footprint.
      Specified by:
      reduceMemoryFootprint in interface PageMemory
      Throws:
      IgniteCheckedException
    • metrics

      public DataRegionMetrics metrics()
      Returns:
      Data region metrics.
    • dirtyPages

      public Collection<Long> dirtyPages()
      Gets a collection of all pages currently marked as dirty. Will create a collection copy.
      Returns:
      Collection of all page IDs marked as dirty.