Class PageMemoryNoStoreImpl
- java.lang.Object
-
- org.apache.ignite.internal.pagemem.impl.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 Summary
Fields Modifier and Type Field Description static intLOCK_OFFSETPage pin counter offset.static intPAGE_ID_OFFSETPage ID offset.static longPAGE_MARKERstatic intPAGE_OVERHEADNeed a 8-byte pointer for linked list, 8 bytes for internal needs (flags), 4 bytes cache ID, 8 bytes timestamp.-
Fields inherited from interface org.apache.ignite.internal.pagemem.PageIdAllocator
FLAG_AUX, FLAG_DATA, FLAG_IDX, INDEX_PARTITION, MAX_PARTITION_ID, META_PAGE_ID
-
-
Constructor Summary
Constructors Constructor Description PageMemoryNoStoreImpl(IgniteLogger log, DirectMemoryProvider directMemoryProvider, GridCacheSharedContext<?,?> sharedCtx, int pageSize, DataRegionConfiguration dataRegionCfg, DataRegionMetricsImpl dataRegionMetrics, boolean trackAcquiredPages)PageMemoryNoStoreImpl(GridCacheSharedContext<?,?> sharedCtx, DirectMemoryProvider directMemoryProvider, int pageSize, DataRegionConfiguration dataRegionCfg, DataRegionMetricsImpl dataRegionMetrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longacquiredPages()longacquirePage(int cacheId, long pageId)Gets the page absolute pointer associated with the given page ID.longacquirePage(int cacheId, long pageId, IoStatisticsHolder statHolder)Gets the page absolute pointer associated with the given page ID.longallocatePage(int grpId, int partId, byte flags)Allocates a page from the space for the given partition ID and the given flags.intcheckpointBufferPagesCount()Number of pages used in checkpoint buffer.booleanfreePage(int grpId, long pageId)The given page is free now.booleanisDirty(int cacheId, long pageId, long page)longloadedPages()DataRegionMetricsImplmetrics()Metrics of the data region this memory is associated with.ByteBufferpageBuffer(long pageAddr)intpageIndex(int seqNo)intpageSequenceNumber(int pageIdx)intpageSize()longreadLock(int cacheId, long pageId, long page)longreadLockForce(int cacheId, long pageId, long page)Obtains read lock without checking page tag.voidreadUnlock(int cacheId, long pageId, long page)Releases locked page.intrealPageSize(int grpId)voidreleasePage(int cacheId, long pageId, long page)voidstart()Start page memory.voidstop(boolean deallocate)Stop page memory.intsystemPageSize()inttotalPages()longtryWriteLock(int cacheId, long pageId, long page)longwriteLock(int cacheId, long pageId, long page)voidwriteUnlock(int cacheId, long pageId, long page, Boolean walPlc, boolean dirtyFlag)Releases locked page.
-
-
-
Field Detail
-
PAGE_MARKER
public static final long PAGE_MARKER
- See Also:
- Constant Field Values
-
PAGE_ID_OFFSET
public static final int PAGE_ID_OFFSET
Page ID offset.- See Also:
- Constant Field Values
-
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- Iftruetracks number of allocated pages (for tests purpose only).
-
-
Method Detail
-
start
public void start() throws IgniteExceptionStart page memory.- Specified by:
startin interfacePageMemory- Throws:
IgniteException
-
stop
public void stop(boolean deallocate) throws IgniteExceptionStop page memory.- Specified by:
stopin interfacePageMemory- Parameters:
deallocate-Trueto deallocate memory,falseto allow memory reuse on subsequentPageMemory.start()- Throws:
IgniteException
-
pageBuffer
public ByteBuffer pageBuffer(long pageAddr)
- Specified by:
pageBufferin interfacePageMemory- 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:
allocatePagein interfacePageIdAllocator- 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:
freePagein interfacePageIdAllocator- Parameters:
grpId- Cache Group ID.pageId- Page ID.
-
pageSize
public int pageSize()
- Specified by:
pageSizein interfacePageMemory- Returns:
- Page size in bytes.
-
systemPageSize
public int systemPageSize()
- Specified by:
systemPageSizein interfacePageMemory- Returns:
- Page size with system overhead, in bytes.
-
realPageSize
public int realPageSize(int grpId)
- Specified by:
realPageSizein interfacePageMemory- Parameters:
grpId- Group id.- Returns:
- Page size without encryption overhead.
-
loadedPages
public long loadedPages()
- Specified by:
loadedPagesin interfacePageMemory- 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 callingPageSupport.releasePage(int, long, long). This method will allocate page with given ID if it doesn't exist.- Specified by:
acquirePagein interfacePageSupport- 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 callingPageSupport.releasePage(int, long, long). This method will allocate page with given ID if it doesn't exist.- Specified by:
acquirePagein interfacePageSupport- 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:
releasePagein interfacePageSupport- 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:
readLockin interfacePageSupport- 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:
readLockForcein interfacePageSupport- 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:
readUnlockin interfacePageSupport- Parameters:
cacheId- Cache group ID.pageId- Page ID.page- Page pointer.
-
writeLock
public long writeLock(int cacheId, long pageId, long page)- Specified by:
writeLockin interfacePageSupport- Parameters:
cacheId- Cache group ID.pageId- Page ID.page- Page pointer.- Returns:
- Address of a buffer with contents of the given page or
0Lif attempt to take the write lock failed.
-
tryWriteLock
public long tryWriteLock(int cacheId, long pageId, long page)- Specified by:
tryWriteLockin interfacePageSupport- Parameters:
cacheId- Cache group ID.pageId- Page ID.page- Page pointer.- Returns:
- Address of a buffer with contents of the given page or
0Lif 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:
writeUnlockin interfacePageSupport- Parameters:
cacheId- Cache group ID.pageId- Page ID.page- Page pointer.walPlc-Trueif page should be recorded to WAL,falseif the page must not be recorded andnullfor 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:
isDirtyin interfacePageSupport- Parameters:
cacheId- Cache group ID.pageId- Page ID.page- Page pointer.- Returns:
Trueif 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:
checkpointBufferPagesCountin interfacePageMemory
-
metrics
public DataRegionMetricsImpl metrics()
Metrics of the data region this memory is associated with.- Specified by:
metricsin interfacePageMemory
-
-