Class PageMemoryNoStoreImpl

  • All Implemented Interfaces:
    PageIdAllocator, PageMemory, PageSupport

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

    When page is allocated and is in use:

     +--------+--------+--------+--------+---------------------------+
     |8 bytes |8 bytes |8 bytes |8 bytes |        PAGE_SIZE          |
     +--------+--------+--------+--------+---------------------------+
     | Marker |Page ID |Pin CNT |  Lock  |        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 Detail

      • LOCK_OFFSET

        public static final int LOCK_OFFSET
        Page pin counter offset.
        See Also:
        Constant Field Values
      • PAGE_OVERHEAD

        public static final int PAGE_OVERHEAD
        Need a 8-byte pointer for linked list, 8 bytes for internal needs (flags), 4 bytes cache ID, 8 bytes timestamp.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PageMemoryNoStoreImpl

        public PageMemoryNoStoreImpl​(GridCacheSharedContext<?,​?> sharedCtx,
                                     DirectMemoryProvider directMemoryProvider,
                                     int pageSize,
                                     DataRegionConfiguration dataRegionCfg,
                                     DataRegionMetricsImpl dataRegionMetrics)
        Parameters:
        directMemoryProvider - Memory allocator to use.
        sharedCtx - Cache shared context.
        pageSize - Page size.
        dataRegionCfg - Data region configuration.
        dataRegionMetrics - Data region metrics.
      • PageMemoryNoStoreImpl

        @TestOnly
        public PageMemoryNoStoreImpl​(IgniteLogger log,
                                     DirectMemoryProvider directMemoryProvider,
                                     GridCacheSharedContext<?,​?> sharedCtx,
                                     int pageSize,
                                     DataRegionConfiguration dataRegionCfg,
                                     DataRegionMetricsImpl dataRegionMetrics,
                                     boolean trackAcquiredPages)
        Parameters:
        log - Logger.
        directMemoryProvider - Direct memory provider.
        pageSize - Page size.
        dataRegionCfg - Data region config.
        dataRegionMetrics - Data region metrics.
        trackAcquiredPages - If true tracks number of allocated pages (for tests purpose only).
    • Method Detail

      • pageBuffer

        public ByteBuffer pageBuffer​(long pageAddr)
        Specified by:
        pageBuffer in interface PageMemory
        Parameters:
        pageAddr - Page address.
        Returns:
        Page byte buffer.
      • allocatePage

        public long allocatePage​(int grpId,
                                 int partId,
                                 byte flags)
        Allocates a page from the space for the given partition ID and the given flags.
        Specified by:
        allocatePage in interface PageIdAllocator
        Parameters:
        grpId - Cache Group ID.
        partId - Partition ID.
        Returns:
        Allocated page ID.
      • freePage

        public boolean freePage​(int grpId,
                                long pageId)
        The given page is free now.
        Specified by:
        freePage in interface PageIdAllocator
        Parameters:
        grpId - Cache Group ID.
        pageId - Page ID.
      • pageSize

        public int pageSize()
        Specified by:
        pageSize in interface PageMemory
        Returns:
        Page size in bytes.
      • systemPageSize

        public int systemPageSize()
        Specified by:
        systemPageSize in interface PageMemory
        Returns:
        Page size with system overhead, in bytes.
      • realPageSize

        public int realPageSize​(int grpId)
        Specified by:
        realPageSize in interface PageMemory
        Parameters:
        grpId - Group id.
        Returns:
        Page size without encryption overhead.
      • loadedPages

        public long loadedPages()
        Specified by:
        loadedPages in interface PageMemory
        Returns:
        Total number of loaded pages in memory.
      • totalPages

        public int totalPages()
        Returns:
        Total number of pages may be allocated for this instance.
      • acquiredPages

        public long acquiredPages()
        Returns:
        Total number of acquired pages.
      • acquirePage

        public long acquirePage​(int cacheId,
                                long pageId)
        Gets the page absolute pointer associated with the given page ID. Each page obtained with this method must be released by calling PageSupport.releasePage(int, long, long). This method will allocate page with given ID if it doesn't exist.
        Specified by:
        acquirePage in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        Returns:
        Page pointer.
      • acquirePage

        public long acquirePage​(int cacheId,
                                long pageId,
                                IoStatisticsHolder statHolder)
        Gets the page absolute pointer associated with the given page ID. Each page obtained with this method must be released by calling PageSupport.releasePage(int, long, long). This method will allocate page with given ID if it doesn't exist.
        Specified by:
        acquirePage in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        statHolder - Statistics holder to track IO operations.
        Returns:
        Page pointer.
      • releasePage

        public void releasePage​(int cacheId,
                                long pageId,
                                long page)
        Specified by:
        releasePage in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID to release.
        page - Page pointer.
      • readLock

        public long readLock​(int cacheId,
                             long pageId,
                             long page)
        Specified by:
        readLock in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        Returns:
        Pointer for reading the page.
      • readLockForce

        public long readLockForce​(int cacheId,
                                  long pageId,
                                  long page)
        Obtains read lock without checking page tag.
        Specified by:
        readLockForce in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        Returns:
        Pointer for reading the page.
      • readUnlock

        public void readUnlock​(int cacheId,
                               long pageId,
                               long page)
        Releases locked page.
        Specified by:
        readUnlock in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
      • writeLock

        public long writeLock​(int cacheId,
                              long pageId,
                              long page)
        Specified by:
        writeLock in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        Returns:
        Address of a buffer with contents of the given page or 0L if attempt to take the write lock failed.
      • tryWriteLock

        public long tryWriteLock​(int cacheId,
                                 long pageId,
                                 long page)
        Specified by:
        tryWriteLock in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        Returns:
        Address of a buffer with contents of the given page or 0L if attempt to take the write lock failed.
      • writeUnlock

        public void writeUnlock​(int cacheId,
                                long pageId,
                                long page,
                                Boolean walPlc,
                                boolean dirtyFlag)
        Releases locked page.
        Specified by:
        writeUnlock in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        walPlc - True if page should be recorded to WAL, false if the page must not be recorded and null for the default behavior.
        dirtyFlag - Determines whether the page was modified since the last checkpoint.
      • isDirty

        public boolean isDirty​(int cacheId,
                               long pageId,
                               long page)
        Specified by:
        isDirty in interface PageSupport
        Parameters:
        cacheId - Cache group ID.
        pageId - Page ID.
        page - Page pointer.
        Returns:
        True if the page is dirty.
      • pageSequenceNumber

        public int pageSequenceNumber​(int pageIdx)
        Parameters:
        pageIdx - Page index.
        Returns:
        Total page sequence number.
      • pageIndex

        public int pageIndex​(int seqNo)
        Parameters:
        seqNo - Page sequence number.
        Returns:
        Page index.
      • checkpointBufferPagesCount

        public int checkpointBufferPagesCount()
        Number of pages used in checkpoint buffer.
        Specified by:
        checkpointBufferPagesCount in interface PageMemory