org.apache.ignite.internal.processors.cache.persistence.checkpoint

## 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 with `CheckpointEntries`. Data is loaded from corresponding checkpoint directory. This directory holds files for checkpoint start and end.

### Constructor Summary

Constructors
Constructor and Description
`CheckpointHistory(GridKernalContext ctx)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addCheckpoint(CheckpointEntry entry)` Adds checkpoint entry after the corresponding WAL record has been written to WAL.
`Collection<Long>` `checkpoints()`
`Collection<Long>` `checkpoints(boolean descending)`
`CheckpointEntry` `firstCheckpoint()`
`WALPointer` `firstCheckpointPointer()`
`boolean` `hasSpace()`
`void` `initialize(List<CheckpointEntry> checkpoints)`
`CheckpointEntry` `lastCheckpoint()`
`List<CheckpointEntry>` `onCheckpointFinished(GridCacheDatabaseSharedManager.Checkpoint chp, boolean truncateWal)` Logs and clears checkpoint history after checkpoint finish.
`List<CheckpointEntry>` `onWalTruncated(WALPointer ptr)` Clears checkpoint history after WAL truncation.
`Map<Integer,Map<Integer,CheckpointEntry>>` `searchAndReserveCheckpoints(Map<Integer,Set<Integer>> groupsAndPartitions)` Finds and reserves earliest valid checkpoint for each of given groups and partitions.
`CheckpointEntry` `searchCheckpointEntry(int grpId, int part, long partCntrSince)` Tries to search for a WAL pointer for the given partition counter start.
`WALPointer` `searchPartitionCounter(int grpId, int part, long partCntrSince)` Tries to search for a WAL pointer for the given partition counter start.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### CheckpointHistory

    public CheckpointHistory(GridKernalContext ctx)

Constructor.

Parameters:
  `ctx` - Context.

### Method Detail

#### initialize

    public void initialize(List<CheckpointEntry> checkpoints)

Parameters:
  `checkpoints` - Checkpoints.

#### firstCheckpoint

    public CheckpointEntry firstCheckpoint()

Returns:
  First checkpoint entry if exists. Otherwise `null`.

#### lastCheckpoint

    public CheckpointEntry lastCheckpoint()

Returns:
  Last checkpoint entry if exists. Otherwise `null`.

#### 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)

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.

#### hasSpace

    public boolean hasSpace()

Returns:
  `true` if there is space for next checkpoint.

#### onWalTruncated

    public List<CheckpointEntry> onWalTruncated(WALPointer ptr)

Clears checkpoint history after WAL truncation.

Returns:
  List of checkpoint entries removed from history.

#### onCheckpointFinished

    public List<CheckpointEntry> onCheckpointFinished(GridCacheDatabaseSharedManager.Checkpoint chp,
                                                      boolean truncateWal)

Logs and clears checkpoint history after checkpoint finish.

Returns:
  List of checkpoints removed from history.

#### searchPartitionCounter

    @Nullable
    public WALPointer searchPartitionCounter(int grpId,
                                                       int part,
                                                       long partCntrSince)

Tries to search for a WAL pointer for the given partition counter start.

Parameters:
  `grpId` - Cache group ID.
  `part` - Partition ID.
  `partCntrSince` - Partition counter or `null` to search for minimal counter.
Returns:
  Checkpoint entry or `null` if failed to search.

#### searchCheckpointEntry

    @Nullable
    public CheckpointEntry searchCheckpointEntry(int grpId,
                                                           int part,
                                                           long partCntrSince)

Tries to search for a WAL pointer for the given partition counter start.

Parameters:
  `grpId` - Cache group ID.
  `part` - Partition ID.
  `partCntrSince` - Partition counter or `null` to search for minimal counter.
Returns:
  Checkpoint entry or `null` if failed to search.

#### searchAndReserveCheckpoints

    public Map<Integer,Map<Integer,CheckpointEntry>> 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:
  Map (groupId, Map (partitionId, earliest valid checkpoint to history search)).

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.5
Release Date | : June 4 2019