Class PageMemoryImpl
java.lang.Object
org.apache.ignite.internal.pagemem.PageMemoryImpl
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThrottling enabled and its type enum. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringCheckpoint pool overflow error message.static final booleanstatic final booleanstatic final LongDefault minimum checkpointing page buffer size (may be adjusted by Ignite).static final LongMinimum checkpointing page buffer size (may be adjusted by Ignite).static final intPage lock offset.static final int8b Marker/timestamp 8b Relative pointer 4b Page ID 4b Store ID 4b Pin count 8b Lock 8b Temporary bufferstatic final intNumber of random pages that will be picked for eviction.Fields inherited from interface org.apache.ignite.internal.pagemem.PageMemory
ANY_TAG -
Constructor Summary
ConstructorsConstructorDescriptionPageMemoryImpl(String name, long maximumSize, int pageSize, int concurrencyLevel, DirectMemoryProvider directMemoryProvider, PageStoreManager storeMgr, IgnitePredicate<Long> evictablePagePredicate, IgniteClosure<Long, Integer> tagReader, ExecutorService asyncRunner, IgniteLogger log, DataRegionMetrics memMetrics) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionlongacquirePage(int grpId, int pageId, int tag) Gets the page absolute pointer associated with the given page ID.longacquirePage(int grpId, int pageId, int tag, boolean restore) Gets the page absolute pointer associated with the given page ID.intallocatePage(int grpId, int tag) Allocates a page from the space for the given partition ID and the given flags.voidBegins a checkpoint.Gets a collection of all pages currently marked as dirty.voidFinishes a checkpoint.booleanisDirty(int grpId, int pageId, long page) intmetaPageId(int grpId) Gets or allocates metadata page for specified grpId.metrics()longreadLock(int grpId, int pageId, long absPtr, int tag, boolean touch) voidreadUnlock(int grpId, int pageId, long page) Releases locked page.voidReduces memory footprint.voidreleasePage(int grpId, int pageId, long page) voidRuns a checkpoint.booleanHeuristic method which allows a thread to check if it safe to start memory struture modifications in regard with checkpointing.voidstart()Start page memory.voidstartStore(int grpId, int metaPageTag, Path path, boolean restorationMode) Starts the store with the specified ID.voidstop()Stop page memory.voidstopStore(int grpId, boolean freePages) Stops the store with the specified ID.longTotal pages can be placed to memory.longtryWriteLock(int grpId, int pageId, long page, int tag) longwriteLock(int grpId, int pageId, long page, int tag) voidwriteUnlock(int grpId, int pageId, long page, boolean modified, int tag)
-
Field Details
-
PAGE_LOCK_OFFSET
public static final int PAGE_LOCK_OFFSETPage lock offset.- See Also:
-
PAGE_OVERHEAD
public static final int PAGE_OVERHEAD8b 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_NUMNumber 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:
-
IgniteSystemProperties#IGNITE_DELAYED_REPLACED_PAGE_WRITE- Constant Field Values
-
DFLT_LOADED_PAGES_BACKWARD_SHIFT_MAP
public static final boolean DFLT_LOADED_PAGES_BACKWARD_SHIFT_MAP- See Also:
-
IgniteSystemProperties#IGNITE_LOADED_PAGES_BACKWARD_SHIFT_MAP- Constant Field Values
-
CHECKPOINT_POOL_OVERFLOW_ERROR_MSG
Checkpoint pool overflow error message.- See Also:
-
DFLT_MIN_CHECKPOINTING_PAGE_BUFFER_SIZE
Minimum checkpointing page buffer size (may be adjusted by Ignite). -
DFLT_MAX_CHECKPOINTING_PAGE_BUFFER_SIZE
Default minimum checkpointing page buffer size (may be adjusted by Ignite).
-
-
Constructor Details
-
PageMemoryImpl
public PageMemoryImpl(String name, long maximumSize, int pageSize, int concurrencyLevel, DirectMemoryProvider directMemoryProvider, PageStoreManager storeMgr, IgnitePredicate<Long> evictablePagePredicate, IgniteClosure<Long, Integer> tagReader, ExecutorService asyncRunner, IgniteLogger log, DataRegionMetrics memMetrics) Constructs a new instance.- Parameters:
name-initialSize-maximumSize-pageSize-concurrencyLevel-tagInitValue-directMemoryProvider-storeMgr-evictablePagePredicate-tagReader-asyncRunner-log-memMetrics-
-
-
Method Details
-
start
Description copied from interface:PageMemoryStart page memory.- Specified by:
startin interfacePageMemory- Throws:
IgniteCheckedException
-
stop
Description copied from interface:PageMemoryStop page memory.- Specified by:
stopin interfacePageMemory- Throws:
IgniteCheckedException
-
startStore
public void startStore(int grpId, int metaPageTag, Path path, boolean restorationMode) throws IgniteCheckedException Description copied from interface:PageMemoryStarts the store with the specified ID.- Specified by:
startStorein interfacePageMemory- Parameters:
grpId- Group ID.metaPageTag- Meta-page tag.path- Store path.restorationMode- Flag indicating restoration mode.- Throws:
IgniteCheckedException
-
stopStore
Description copied from interface:PageMemoryStops the store with the specified ID.- Specified by:
stopStorein interfacePageMemory- Throws:
IgniteCheckedException
-
totalPages
public long totalPages()Description copied from interface:PageMemoryTotal pages can be placed to memory.- Specified by:
totalPagesin interfacePageMemory
-
allocatePage
Description copied from interface:PageMemoryAllocates a page from the space for the given partition ID and the given flags.- Specified by:
allocatePagein interfacePageMemorytag- Tag.- Returns:
- page ID within the store.
- Throws:
IgniteCheckedException- If failed.
-
metaPageId
public int metaPageId(int grpId) Description copied from interface:PageMemoryGets or allocates metadata page for specified grpId.- Specified by:
metaPageIdin interfacePageMemory- Parameters:
grpId- Group ID.- Returns:
- Meta page ID for the store.
-
acquirePage
Description copied from interface:PageMemoryGets 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:
acquirePagein interfacePageMemory- 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:PageMemoryGets 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:
acquirePagein interfacePageMemory- 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:
releasePagein interfacePageMemory- 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:
readLockin interfacePageMemorypageId- 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:PageMemoryReleases locked page.- Specified by:
readUnlockin interfacePageMemory- 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:
writeLockin interfacePageMemory- 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:
tryWriteLockin interfacePageMemory- 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:
writeUnlockin interfacePageMemory- 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:
isDirtyin interfacePageMemory- Parameters:
grpId- Cache group ID.pageId- Page ID.page- Page pointer.- Returns:
trueif the page is dirty.
-
beginCheckpoint
Description copied from interface:PageMemoryBegins a checkpoint.- Specified by:
beginCheckpointin interfacePageMemory- Throws:
IgniteException
-
finishCheckpoint
public void finishCheckpoint()Description copied from interface:PageMemoryFinishes a checkpoint.- Specified by:
finishCheckpointin interfacePageMemory
-
runCheckpoint
Description copied from interface:PageMemoryRuns a checkpoint.- Specified by:
runCheckpointin interfacePageMemory- Throws:
IgniteCheckedException
-
safeToUpdate
public boolean safeToUpdate()Description copied from interface:PageMemoryHeuristic 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:
safeToUpdatein interfacePageMemory- Returns:
Falseif there are too many dirty pages and a thread should wait for a checkpoint to begin.
-
reduceMemoryFootprint
Description copied from interface:PageMemoryReduces memory footprint.- Specified by:
reduceMemoryFootprintin interfacePageMemory- Throws:
IgniteCheckedException
-
metrics
- Returns:
- Data region metrics.
-
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.
-