public class PageMemoryImpl extends Object implements PageMemoryEx
+--------+------------------------------------------------------+ |8 bytes | PAGE_SIZE + PAGE_OVERHEAD - 8 bytes | +--------+------------------------------------------------------+ |Next ptr| Page data | +--------+------------------------------------------------------+When page is allocated and is in use:
+------------------+--------+--------+----+----+--------+--------+----------------------+ | 8 bytes |8 bytes |8 bytes |4 b |4 b |8 bytes |8 bytes | PAGE_SIZE | +------------------+--------+--------+----+----+--------+--------+----------------------+ | Marker/Timestamp |Rel ptr |Page ID |C 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.
| Modifier and Type | Field and Description |
|---|---|
static int |
PAGE_CACHE_ID_OFFSET
Page cache ID offset.
|
static int |
PAGE_ID_OFFSET
Page ID offset
|
static int |
PAGE_LOCK_OFFSET
Page lock offset.
|
static long |
PAGE_MARKER |
static int |
PAGE_OVERHEAD
8b Marker/timestamp
8b Relative pointer
8b Page ID
4b Cache ID
4b Pin count
8b Lock
8b Temporary buffer
|
static int |
PAGE_PIN_CNT_OFFSET
Page pin counter offset.
|
static int |
PAGE_TMP_BUF_OFFSET
Page lock offset.
|
static int |
RANDOM_PAGES_EVICT_NUM
Number of random pages that will be picked for eviction.
|
static int |
RELATIVE_PTR_OFFSET
Page relative pointer.
|
FLAG_DATA, FLAG_IDX, INDEX_PARTITION, MAX_PARTITION_ID| Constructor and Description |
|---|
PageMemoryImpl(DirectMemoryProvider directMemoryProvider,
long[] sizes,
GridCacheSharedContext<?,?> ctx,
int pageSize,
GridInClosure3X<FullPageId,ByteBuffer,Integer> flushDirtyPage,
GridInClosure3X<Long,FullPageId,PageMemoryEx> changeTracker,
CheckpointLockStateChecker stateChecker,
DataRegionMetricsImpl memMetrics,
boolean throttleEnabled) |
| Modifier and Type | Method and Description |
|---|---|
long |
acquiredPages() |
long |
acquirePage(int cacheId,
long pageId)
Gets the page absolute pointer associated with the given page ID.
|
long |
acquirePage(int cacheId,
long pageId,
boolean restore) |
int |
activePagesCount()
Gets the number of active pages across all segments.
|
long |
allocatePage(int cacheId,
int partId,
byte flags)
Allocates a page from the space for the given partition ID and the given flags.
|
GridMultiCollectionWrapper<FullPageId> |
beginCheckpoint()
Gets a collection of dirty page IDs since the last checkpoint.
|
int |
checkpointBufferPagesCount()
Number of pages used in checkpoint buffer.
|
int |
checkpointBufferPagesSize()
Number of used pages in checkpoint buffer.
|
IgniteInternalFuture<Void> |
clearAsync(GridPredicate3<Integer,Long,Integer> pred,
boolean cleanDirty)
Asynchronously clears pages satisfying the given predicate.
|
void |
finishCheckpoint()
Finishes checkpoint operation.
|
boolean |
freePage(int cacheId,
long pageId)
The given page is free now.
|
Integer |
getForCheckpoint(FullPageId fullId,
ByteBuffer outBuf,
CheckpointMetricsTracker tracker)
Gets page byte buffer for the checkpoint procedure.
|
boolean |
hasTempCopy(long absPtr)
Checks if a page has temp copy buffer.
|
int |
invalidate(int grpId,
int partId)
Marks partition as invalid / outdated.
|
boolean |
isDirty(int cacheId,
long pageId,
long page) |
long |
loadedPages() |
long |
metaPageId(int grpId)
Gets or allocates metadata page for specified grpId.
|
void |
onCacheGroupDestroyed(int grpId)
Clears internal metadata of destroyed cache group.
|
ByteBuffer |
pageBuffer(long pageAddr) |
int |
pageSize() |
long |
partitionMetaPageId(int grpId,
int partId)
Gets or allocates partition metadata page for specified grpId and partId.
|
long |
readLock(int cacheId,
long pageId,
long page) |
long |
readLockForce(int cacheId,
long pageId,
long page)
Obtains read lock without checking page tag.
|
void |
readUnlock(int cacheId,
long pageId,
long page)
Releases locked page.
|
void |
releasePage(int cacheId,
long pageId,
long page) |
boolean |
safeToUpdate()
Heuristic method which allows a thread to check if it safe to start memory struture modifications
in regard with checkpointing.
|
static int |
segmentIndex(int grpId,
long pageId,
int segments) |
void |
start()
Starts grid component, called on grid start.
|
void |
stop()
Stops grid component, called on grid shutdown.
|
int |
systemPageSize() |
long |
tryWriteLock(int cacheId,
long pageId,
long page) |
long |
writeLock(int cacheId,
long pageId,
long page) |
long |
writeLock(int grpId,
long pageId,
long page,
boolean restore) |
void |
writeUnlock(int cacheId,
long pageId,
long page,
Boolean walPlc,
boolean dirtyFlag)
Releases locked page.
|
void |
writeUnlock(int grpId,
long pageId,
long page,
Boolean walPlc,
boolean dirtyFlag,
boolean restore) |
public static final long PAGE_MARKER
public static final int RELATIVE_PTR_OFFSET
public static final int PAGE_ID_OFFSET
public static final int PAGE_CACHE_ID_OFFSET
public static final int PAGE_PIN_CNT_OFFSET
public static final int PAGE_LOCK_OFFSET
public static final int PAGE_TMP_BUF_OFFSET
public static final int PAGE_OVERHEAD
public static final int RANDOM_PAGES_EVICT_NUM
public PageMemoryImpl(DirectMemoryProvider directMemoryProvider, long[] sizes, GridCacheSharedContext<?,?> ctx, int pageSize, GridInClosure3X<FullPageId,ByteBuffer,Integer> flushDirtyPage, @Nullable GridInClosure3X<Long,FullPageId,PageMemoryEx> changeTracker, CheckpointLockStateChecker stateChecker, DataRegionMetricsImpl memMetrics, boolean throttleEnabled)
directMemoryProvider - Memory allocator to use.ctx - Cache shared context.pageSize - Page size.flushDirtyPage - Callback invoked when a dirty page is evicted.changeTracker - Callback invoked to track changes in pages.throttleEnabled - Write throttle enabled flag.public void start()
throws IgniteException
start in interface LifecycleAwareIgniteException - If failed.public void stop()
throws IgniteException
stop in interface LifecycleAwareIgniteException - If failed.public void releasePage(int cacheId,
long pageId,
long page)
releasePage in interface PageSupportcacheId - Cache group ID.pageId - Page ID to release.page - Page pointer.public long readLock(int cacheId,
long pageId,
long page)
readLock in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.public void readUnlock(int cacheId,
long pageId,
long page)
readUnlock in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.public long writeLock(int cacheId,
long pageId,
long page)
writeLock in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.0L if attempt to take the write lock failed.public long writeLock(int grpId,
long pageId,
long page,
boolean restore)
writeLock in interface PageMemoryExgrpId - Group ID.pageId - Page ID.page - Page pointer.restore - Determines if the page is locked for restore.public long tryWriteLock(int cacheId,
long pageId,
long page)
tryWriteLock in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.0L if attempt to take the write lock failed.public void writeUnlock(int cacheId,
long pageId,
long page,
Boolean walPlc,
boolean dirtyFlag)
writeUnlock in interface PageSupportcacheId - 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.public void writeUnlock(int grpId,
long pageId,
long page,
Boolean walPlc,
boolean dirtyFlag,
boolean restore)
writeUnlock in interface PageMemoryExgrpId - 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.restore - Determines if the page is locked for restore.public boolean isDirty(int cacheId,
long pageId,
long page)
isDirty in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.True if the page is dirty.public long allocatePage(int cacheId,
int partId,
byte flags)
throws IgniteCheckedException
allocatePage in interface PageIdAllocatorpartId - Partition ID.IgniteCheckedExceptionpublic ByteBuffer pageBuffer(long pageAddr)
pageBuffer in interface PageMemorypageAddr - Page address.public boolean freePage(int cacheId,
long pageId)
throws IgniteCheckedException
freePage in interface PageIdAllocatorcacheId - Cache ID.pageId - Page ID.IgniteCheckedExceptionpublic long metaPageId(int grpId)
throws IgniteCheckedException
metaPageId in interface PageMemoryExgrpId - Group ID.IgniteCheckedException - If failed.public long partitionMetaPageId(int grpId,
int partId)
throws IgniteCheckedException
partitionMetaPageId in interface PageMemoryExgrpId - Group ID.partId - Partition ID.IgniteCheckedException - If failed.public long acquirePage(int cacheId,
long pageId)
throws IgniteCheckedException
PageSupport.releasePage(int, long, long). This method will allocate page with given ID if it doesn't
exist.acquirePage in interface PageSupportcacheId - Cache group ID.pageId - Page ID.IgniteCheckedException - If failed.public long acquirePage(int cacheId,
long pageId,
boolean restore)
throws IgniteCheckedException
acquirePage in interface PageMemoryExcacheId - Cache group ID.pageId - Page id.restore - Get page for restoreIgniteCheckedException - If failed.Will not read page from file if it is not present in memorypublic int pageSize()
pageSize in interface PageMemorypublic int systemPageSize()
systemPageSize in interface PageMemorypublic boolean safeToUpdate()
safeToUpdate in interface PageMemoryExFalse if there are too many dirty pages and a thread should wait for a
checkpoint to begin.public GridMultiCollectionWrapper<FullPageId> beginCheckpoint() throws IgniteException
beginCheckpoint in interface PageMemoryExIgniteException - If checkpoint has been already started and was not finished.public void finishCheckpoint()
finishCheckpoint in interface PageMemoryExpublic Integer getForCheckpoint(FullPageId fullId, ByteBuffer outBuf, CheckpointMetricsTracker tracker)
getForCheckpoint in interface PageMemoryExfullId - Page ID to get byte buffer for. The page ID must be present in the collection returned by
the PageMemoryEx.beginCheckpoint() method call.outBuf - Temporary buffer to write changes into.tracker - Checkpoint metrics tracker.Partition tag if data was read, null otherwise (data already saved to storage).public int invalidate(int grpId,
int partId)
invalidate in interface PageMemoryExgrpId - Group ID.partId - Partition ID.public void onCacheGroupDestroyed(int grpId)
onCacheGroupDestroyed in interface PageMemoryExgrpId - Cache group ID.public IgniteInternalFuture<Void> clearAsync(GridPredicate3<Integer,Long,Integer> pred, boolean cleanDirty)
clearAsync in interface PageMemoryExpred - Predicate for cache group id, pageId and partition tag.cleanDirty - Flag indicating that dirty pages collection should be cleaned.public long loadedPages()
loadedPages in interface PageMemorypublic long acquiredPages()
public long readLockForce(int cacheId,
long pageId,
long page)
readLockForce in interface PageSupportcacheId - Cache group ID.pageId - Page ID.page - Page pointer.public boolean hasTempCopy(long absPtr)
absPtr - Absolute pointer.True if a page has temp buffer.public int activePagesCount()
public int checkpointBufferPagesCount()
checkpointBufferPagesCount in interface PageMemorypublic int checkpointBufferPagesSize()
public static int segmentIndex(int grpId,
long pageId,
int segments)
pageId - Page ID.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.4.0 Release Date : March 5 2018