GridGain™ 2.0.3
Java API Specification

org.gridgain.grid.spi.checkpoint
Interface GridCheckpointSpi

All Superinterfaces:
GridSpi
All Known Implementing Classes:
GridCoherenceCheckpointSpi, GridGigaSpacesCheckpointSpi, GridSharedFsCheckpointSpi

@Apache20LicenseCompatible
public interface GridCheckpointSpi
extends GridSpi

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. The only requirement for job state to be a checkpoint is to implement Serializable interface.

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

GridGain provides the following GridCheckpointSpi implementations:





See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.0.3

 

Method Summary
 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.
 void saveCheckpoint(String key, byte[] state, long timeout)
          Saves checkpoint to the storage.
 
Methods inherited from interface org.gridgain.grid.spi.GridSpi
getNodeAttributes, onContextDestroyed, onContextInitialized, spiStart, spiStop
 

Method Detail

loadCheckpoint

byte[] loadCheckpoint(String key)
                      throws GridSpiException
Loads checkpoint from storage by its unique key.

Throws:
GridSpiException - 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.
Parameters:
key - Checkpoint key.
Returns:
Loaded data or null if there is no data for a given key.

saveCheckpoint

void saveCheckpoint(String key,
                    byte[] state,
                    long timeout)
                    throws GridSpiException
Saves checkpoint to the storage. If checkpoint exists it will be overwritten by new one.

Throws:
GridSpiException - Thrown in case of any error while saving checkpoint data.
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.

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.

GridGain™ 2.0.3
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.0.3.20052008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.