Package 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
- defaultSharedFsCheckpointSpi
S3CheckpointSpi
JdbcCheckpointSpi
CacheCheckpointSpi
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 Description @org.jetbrains.annotations.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 givenkey
.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 @org.jetbrains.annotations.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 givenkey
is not found this method will returnnull
.
-
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. Value0
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 givenkey
.- 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 ornull
.
-
-