org.apache.ignite.spi.checkpoint

## Interface CheckpointSpi

- All Superinterfaces:
    IgniteSpi
  All Known Implementing Classes:
    CacheCheckpointSpi, JdbcCheckpointSpi, NoopCheckpointSpi, SharedFsCheckpointSpi

      public interface CheckpointSpi
      extends IgniteSpi

  Checkpoint SPI provides an ability to save an intermediate job state. It can be useful when long running jobs need to store some intermediate state to protect from system or application failures. Grid job can save intermediate state in certain points of the execution (e.g., periodically) and upon start check if previously saved state exists. This allows job to restart from the last save checkpoint in case of preemption or other types of failover.

  Note, that since a job can execute on different nodes, checkpoints need to be accessible by all nodes.

  To manipulate checkpoints from grid job the following public methods are available on task session (that can be injected into grid job):

  - `ComputeTaskSession.loadCheckpoint(String)`
  - `ComputeTaskSession.removeCheckpoint(String)`
  - `ComputeTaskSession.saveCheckpoint(String, Object)`
  - `ComputeTaskSession.saveCheckpoint(String, Object, org.apache.ignite.compute.ComputeTaskSessionScope, long)`
  - `ComputeTaskSession.saveCheckpoint(String, Object, org.apache.ignite.compute.ComputeTaskSessionScope, long, boolean)`

  Ignite provides the following `GridCheckpointSpi` implementations:

  - `NoopCheckpointSpi` - default
  - `SharedFsCheckpointSpi`
  - `S3CheckpointSpi`
  - `JdbcCheckpointSpi`
  - `CacheCheckpointSpi`
  NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained via `Ignite.configuration()` method to check its configuration properties or call other non-SPI methods. Note again that calling methods from this interface on the obtained instance can lead to undefined behavior and explicitly not supported.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `@Nullable byte[]` | `loadCheckpoint(String key)` Loads checkpoint from storage by its unique key.
    `boolean` | `removeCheckpoint(String key)` This method instructs the checkpoint provider to clean saved data for a given `key`.
    `boolean` | `saveCheckpoint(String key, byte[] state, long timeout, boolean overwrite)` Saves checkpoint to the storage.
    `void` | `setCheckpointListener(CheckpointListener lsnr)` Sets the checkpoint listener.

    - ### Methods inherited from interface org.apache.ignite.spi.IgniteSpi

      `getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, spiStart, spiStop`

- - ### Method Detail

    - #### loadCheckpoint

          @Nullable
          @Nullable byte[] loadCheckpoint(String key)
                                             throws IgniteSpiException

      Loads checkpoint from storage by its unique key.
      Parameters:
        `key` - Checkpoint key.
      Returns:
        Loaded data or `null` if there is no data for a given key.
      Throws:
        `IgniteSpiException` - Thrown in case of any error while loading checkpoint data. Note that in case when given `key` is not found this method will return `null`.

    - #### saveCheckpoint

          boolean saveCheckpoint(String key,
                                 byte[] state,
                                 long timeout,
                                 boolean overwrite)
                          throws IgniteSpiException

      Saves checkpoint to the storage.
      Parameters:
        `key` - Checkpoint unique key.
        `state` - Saved data.
        `timeout` - Every intermediate data stored by checkpoint provider should have a timeout. Timeout allows for effective resource management by checkpoint provider by cleaning saved data that are not needed anymore. Generally, the user should choose the minimum possible timeout to avoid long-term resource acquisition by checkpoint provider. Value `0` means that timeout will never expire.
        `overwrite` - Whether or not overwrite checkpoint if it already exists.
      Returns:
        `true` if checkpoint has been actually saved, `false` otherwise.
      Throws:
        `IgniteSpiException` - Thrown in case of any error while saving checkpoint data.

    - #### removeCheckpoint

          boolean removeCheckpoint(String key)

      This method instructs the checkpoint provider to clean saved data for a given `key`.
      Parameters:
        `key` - Key for the checkpoint to remove.
      Returns:
        `true` if data has been actually removed, `false` otherwise.

    - #### setCheckpointListener

          void setCheckpointListener(CheckpointListener lsnr)

      Sets the checkpoint listener.
      Parameters:
        `lsnr` - The listener to set or `null`.

2022 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.12.0
Release Date | : January 10 2022