Class TrackingPageIO
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO
-
- org.apache.ignite.internal.processors.cache.persistence.tree.io.TrackingPageIO
-
public class TrackingPageIO extends PageIO
We use dedicated page for tracking pages updates. Also we divide such 'tracking' pages on two half, first is used for check that page was changed or not (during incremental snapshot), second - to accumulate changed for next snapshot. You cannot test change for not started snapshot! because it will cause of preparation for snapshot. Implementation. For each page there is own bit in both half. Tracking page is used for tracking N page after it. N depends on page size (how many bytes we can use for tracking). +-----------------------------------------+-----------------------------------------+ | left half | right half | +---------+-----------+----+------------------------------------+----+------------------------------------+ | HEADER | Last |size| |size| | | |SnapshotTag|2b. | tracking bits |2b. | tracking bits | +---------+--------- -+----+------------------------------------+----+------------------------------------+
-
-
Field Summary
Fields Modifier and Type Field Description static intBITMAP_OFFSETBitmap offset.static longCORRUPT_FLAG_FILTER_MASKCorrupt flag mask.static longCORRUPT_FLAG_MASKCorrupt flag mask.static intCOUNT_OF_EXTRA_PAGECount of extra page.static intLAST_SNAPSHOT_TAG_OFFSETLast snapshot offset.static intSIZE_FIELD_OFFSETSize field offset.static intSIZE_FIELD_SIZE'Size' field size.static IOVersions<TrackingPageIO>VERSIONS-
Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO
COMMON_HEADER_END, CRC_OFF, MAX_PAYLOAD_SIZE, PAGE_ID_OFF, ROTATED_ID_PART_OFF, T_BPLUS_META, T_CACHE_ID_AWARE_DATA_REF_INNER, T_CACHE_ID_AWARE_DATA_REF_LEAF, T_CACHE_ID_AWARE_PENDING_REF_INNER, T_CACHE_ID_AWARE_PENDING_REF_LEAF, T_DATA, T_DATA_METASTORAGE, T_DATA_PART, T_DATA_REF_INNER, T_DATA_REF_LEAF, T_DATA_REF_METASTORAGE_INNER, T_DATA_REF_METASTORAGE_LEAF, T_DEFRAG_LINK_MAPPING_INNER, T_DEFRAG_LINK_MAPPING_LEAF, T_H2_EX_REF_INNER_END, T_H2_EX_REF_INNER_START, T_H2_EX_REF_LEAF_END, T_H2_EX_REF_LEAF_START, T_H2_REF_INNER, T_H2_REF_LEAF, T_MARKER_PAGE, T_META, T_METASTORE_INNER, T_METASTORE_LEAF, T_PAGE_LIST_META, T_PAGE_LIST_NODE, T_PAGE_UPDATE_TRACKING, T_PART_CNTRS, T_PART_META, T_PENDING_REF_INNER, T_PENDING_REF_LEAF, TYPE_OFF, VER_OFF
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTrackingPageIO(int ver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description shortcountOfChangedPage(ByteBuffer buf, long snapshotTag, int pageSize)intcountOfPageToTrack(int pageSize)@Nullable LongfindNextChangedPage(ByteBuffer buf, long start, long curSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize)intgetFreeSpace(int pageSize, long pageAddr)Count of bytes that is currently free in this page and possibly can be used to place additional payload.booleanisCorrupted(ByteBuffer buf)longmarkChanged(ByteBuffer buf, long pageId, long nextSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize)Will mark pageId as changed for next (!)protected voidprintPage(long addr, int pageSize, GridStringBuilder sb)voidresetCorruptFlag(long addr)Reset corrupted flag to false.voidresetCorruptFlag(ByteBuffer buf)Reset corrupted flag to false.longtrackingPageFor(long pageId, int pageSize)booleanwasChanged(ByteBuffer buf, long pageId, long curSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize)-
Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO
assertPageType, assertPageType, copyPage, deriveIndexPageType, getBPlusIO, getBPlusIO, getCompactedSize, getCompactedSize, getCompressedSize, getCompressedSize, getCompressionType, getCompressionType, getCrc, getCrc, getInnerVersions, getLeafVersions, getPageId, getPageId, getPageIO, getPageIO, getPageIO, getRotatedIdPart, getType, getType, getType, getVersion, getVersion, getVersion, initNewPage, isDataPageType, isIndexPage, printPage, registerH2, registerH2ExtraInner, registerH2ExtraLeaf, registerTest, registerTest, setCompactedSize, setCompressedSize, setCompressionType, setCrc, setCrc, setPageId, setRotatedIdPart, setType, setVersion, toString
-
-
-
-
Field Detail
-
VERSIONS
public static final IOVersions<TrackingPageIO> VERSIONS
-
CORRUPT_FLAG_MASK
public static final long CORRUPT_FLAG_MASK
Corrupt flag mask.- See Also:
- Constant Field Values
-
CORRUPT_FLAG_FILTER_MASK
public static final long CORRUPT_FLAG_FILTER_MASK
Corrupt flag mask.- See Also:
- Constant Field Values
-
LAST_SNAPSHOT_TAG_OFFSET
public static final int LAST_SNAPSHOT_TAG_OFFSET
Last snapshot offset.- See Also:
- Constant Field Values
-
SIZE_FIELD_OFFSET
public static final int SIZE_FIELD_OFFSET
Size field offset.- See Also:
- Constant Field Values
-
SIZE_FIELD_SIZE
public static final int SIZE_FIELD_SIZE
'Size' field size.- See Also:
- Constant Field Values
-
BITMAP_OFFSET
public static final int BITMAP_OFFSET
Bitmap offset.- See Also:
- Constant Field Values
-
COUNT_OF_EXTRA_PAGE
public static final int COUNT_OF_EXTRA_PAGE
Count of extra page.- See Also:
- Constant Field Values
-
-
Method Detail
-
markChanged
public long markChanged(ByteBuffer buf, long pageId, long nextSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize)
Will mark pageId as changed for next (!) snapshotId- Parameters:
buf- Buffer.pageId- Page id.nextSnapshotTag- Tag of next snapshot.pageSize- Page size.- Returns:
-1if everything is ok, otherwise last saved tag.
-
isCorrupted
public boolean isCorrupted(ByteBuffer buf)
- Parameters:
buf- Buffer.- Returns:
- Was tracking page marked as corrupted or not.
-
resetCorruptFlag
public void resetCorruptFlag(ByteBuffer buf)
Reset corrupted flag to false.- Parameters:
buf- Buffer.
-
resetCorruptFlag
public void resetCorruptFlag(long addr)
Reset corrupted flag to false.- Parameters:
addr- Buffer.
-
wasChanged
public boolean wasChanged(ByteBuffer buf, long pageId, long curSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize) throws TrackingPageIsCorruptedException
- Parameters:
buf- Buffer.pageId- Page id.curSnapshotTag- Snapshot tag.lastSuccessfulSnapshotTag- Last successful snapshot id.pageSize- Page size.- Returns:
- Was that pageId marked as changed between previous snapshot finish and current snapshot start or not.
- Throws:
TrackingPageIsCorruptedException- if this tracking page was marked as corrupted.
-
countOfChangedPage
public short countOfChangedPage(ByteBuffer buf, long snapshotTag, int pageSize)
- Parameters:
buf- Buffer.snapshotTag- Snapshot tag.pageSize- Page size.- Returns:
- Count of pages which were marked as change for given snapshotTag.
-
trackingPageFor
public long trackingPageFor(long pageId, int pageSize)- Parameters:
pageId- Page id.pageSize- Page size.- Returns:
- Page id of tracking page which set pageId belongs to.
-
countOfPageToTrack
public int countOfPageToTrack(int pageSize)
- Parameters:
pageSize- Page size.- Returns:
- How many page we can track with 1 page.
-
findNextChangedPage
@Nullable public @Nullable Long findNextChangedPage(ByteBuffer buf, long start, long curSnapshotTag, long lastSuccessfulSnapshotTag, int pageSize) throws TrackingPageIsCorruptedException
- Parameters:
buf- Buffer.start- Start.curSnapshotTag- Snapshot id.lastSuccessfulSnapshotTag- Last successful snapshot id.pageSize- Page size.- Returns:
- Passed pageId if it was changed or next closest one, if there is no changed page
nullwill be returned. - Throws:
TrackingPageIsCorruptedException- if this tracking page was marked as corrupted.
-
printPage
protected void printPage(long addr, int pageSize, GridStringBuilder sb) throws IgniteCheckedException- Specified by:
printPagein classPageIO- Parameters:
addr- Address.pageSize- Page size.sb- Sb.- Throws:
IgniteCheckedException
-
getFreeSpace
public int getFreeSpace(int pageSize, long pageAddr)Count of bytes that is currently free in this page and possibly can be used to place additional payload.- Specified by:
getFreeSpacein classPageIO- Parameters:
pageSize- Page size.pageAddr- Page address.- Returns:
- Free space.
-
-