Class CheckpointHistory
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory
-
public class CheckpointHistory extends Object
Checkpoint history. Holds chronological ordered map withCheckpointEntries. Data is loaded from corresponding checkpoint directory. This directory holds files for checkpoint start and end.
-
-
Field Summary
Fields Modifier and Type Field Description static intDFLT_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCheckpoint(CheckpointEntry entry, Map<Integer,CacheState> cacheStates)Adds checkpoint entry after the corresponding WAL record has been written to WAL.Collection<Long>checkpoints()Collection<Long>checkpoints(boolean descending)EarliestCheckpointMapSnapshotearliestCheckpointsMapSnapshot()Creates a snapshot ofearliestCpmap.WALPointerfirstCheckpointPointer()booleanhasSpace()voidinitialize(List<CheckpointEntry> checkpoints, EarliestCheckpointMapSnapshot snapshot)booleanisCheckpointApplicableForGroup(int grpId, CheckpointEntry cp)Checkpoint is not applicable when: 1) WAL was disabled somewhere after given checkpoint. 2) Checkpoint doesn't contain specifiedgrpId.@Nullable CheckpointEntrylastCheckpoint()List<CheckpointEntry>onCheckpointFinished(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpoint chp)Logs and clears checkpoint history after checkpoint finish.List<CheckpointEntry>onWalTruncated(WALPointer highBound)Clears checkpoint history after WAL truncation.List<CheckpointEntry>removeCheckpoints(int countToRemove)Removes checkpoints from history.CheckpointEntryremoveFromEarliestCheckpoints(Integer grpId)Removes last checkpoint in history from the earliest checkpoints map by group id and returns the latest checkpoint in the history.CheckpointHistoryResultsearchAndReserveCheckpoints(Map<Integer,Set<Integer>> groupsAndPartitions)Finds and reserves earliest valid checkpoint for each of given groups and partitions.Map<GroupPartitionId,CheckpointEntry>searchCheckpointEntry(Map<T2<Integer,Integer>,Long> searchCntrMap)Tries to search for a WAL pointer for the given partition counter start.@Nullable WALPointersearchEarliestWalPointer(int grpId, Map<Integer,Long> partsCounter, long margin)Search the earliest WAL pointer for particular group, matching by counter for partitions.
-
-
-
Method Detail
-
initialize
public void initialize(List<CheckpointEntry> checkpoints, EarliestCheckpointMapSnapshot snapshot)
- Parameters:
checkpoints- Checkpoints.snapshot- Earliest checkpoint map snapshot.
-
lastCheckpoint
@Nullable public @Nullable CheckpointEntry lastCheckpoint()
- Returns:
- Last checkpoint entry if exists.
-
firstCheckpointPointer
public WALPointer firstCheckpointPointer()
- Returns:
- First checkpoint WAL pointer if exists. Otherwise
null.
-
checkpoints
public Collection<Long> checkpoints(boolean descending)
- Returns:
- Collection of checkpoint timestamps.
-
checkpoints
public Collection<Long> checkpoints()
-
addCheckpoint
public void addCheckpoint(CheckpointEntry entry, Map<Integer,CacheState> cacheStates)
Adds checkpoint entry after the corresponding WAL record has been written to WAL. The checkpoint itself is not finished yet.- Parameters:
entry- Entry to add.cacheStates- Cache states map.
-
removeFromEarliestCheckpoints
public CheckpointEntry removeFromEarliestCheckpoints(Integer grpId)
Removes last checkpoint in history from the earliest checkpoints map by group id and returns the latest checkpoint in the history.- Parameters:
grpId- Group id.- Returns:
- Latest checkpoint in the history.
-
hasSpace
public boolean hasSpace()
- Returns:
trueif there is space for next checkpoint.
-
onWalTruncated
public List<CheckpointEntry> onWalTruncated(WALPointer highBound)
Clears checkpoint history after WAL truncation.- Parameters:
highBound- Upper bound.- Returns:
- List of checkpoint entries removed from history.
-
removeCheckpoints
public List<CheckpointEntry> removeCheckpoints(int countToRemove)
Removes checkpoints from history.- Returns:
- List of checkpoint entries removed from history.
-
onCheckpointFinished
public List<CheckpointEntry> onCheckpointFinished(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpoint chp)
Logs and clears checkpoint history after checkpoint finish.- Parameters:
chp- Finished checkpoint.- Returns:
- List of checkpoints removed from history.
-
searchEarliestWalPointer
@Nullable public @Nullable WALPointer searchEarliestWalPointer(int grpId, Map<Integer,Long> partsCounter, long margin) throws IgniteCheckedException
Search the earliest WAL pointer for particular group, matching by counter for partitions.- Parameters:
grpId- Group id.partsCounter- Partition mapped to update counter.margin- Margin pointer.- Returns:
- Earliest WAL pointer for group specified.
- Throws:
IgniteCheckedException
-
searchCheckpointEntry
public Map<GroupPartitionId,CheckpointEntry> searchCheckpointEntry(Map<T2<Integer,Integer>,Long> searchCntrMap)
Tries to search for a WAL pointer for the given partition counter start.- Parameters:
searchCntrMap- Search map contains (Group Id, partition, counter).- Returns:
- Map of group-partition on checkpoint entry or empty map if nothing found.
-
searchAndReserveCheckpoints
public CheckpointHistoryResult searchAndReserveCheckpoints(Map<Integer,Set<Integer>> groupsAndPartitions)
Finds and reserves earliest valid checkpoint for each of given groups and partitions.- Parameters:
groupsAndPartitions- Groups and partitions to find and reserve earliest valid checkpoint.- Returns:
- Checkpoint history reult: Map (groupId, Reason (the reason why reservation cannot be made deeper): Map (partitionId, earliest valid checkpoint to history search)) and reserved checkpoint.
-
isCheckpointApplicableForGroup
public boolean isCheckpointApplicableForGroup(int grpId, CheckpointEntry cp) throws IgniteCheckedExceptionCheckpoint is not applicable when: 1) WAL was disabled somewhere after given checkpoint. 2) Checkpoint doesn't contain specifiedgrpId.- Parameters:
grpId- Group ID.cp- Checkpoint.- Throws:
IgniteCheckedException
-
earliestCheckpointsMapSnapshot
public EarliestCheckpointMapSnapshot earliestCheckpointsMapSnapshot()
Creates a snapshot ofearliestCpmap. Guarded by checkpoint read lock.- Returns:
- Snapshot of a map.
-
-