Class CheckpointHistory


  • public class CheckpointHistory
    extends Object
    Checkpoint history. Holds chronological ordered map with CheckpointEntries. Data is loaded from corresponding checkpoint directory. This directory holds files for checkpoint start and end.
    • Method Detail

      • 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.
      • 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:
        true if 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 IgniteCheckedException
        Checkpoint is not applicable when: 1) WAL was disabled somewhere after given checkpoint. 2) Checkpoint doesn't contain specified grpId.
        Parameters:
        grpId - Group ID.
        cp - Checkpoint.
        Throws:
        IgniteCheckedException
      • earliestCheckpointsMapSnapshot

        public EarliestCheckpointMapSnapshot earliestCheckpointsMapSnapshot()
        Creates a snapshot of earliestCp map. Guarded by checkpoint read lock.
        Returns:
        Snapshot of a map.