@IgniteSpiMultipleInstancesSupport(value=true) @IgniteSpiConsistencyChecked(optional=false) public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements CheckpointSpi
CheckpointSpi
implementation for
checkpoint SPI. All checkpoints are stored on shared storage and available for all
nodes in the grid. Note that every node must have access to the shared directory. The
reason the directory needs to be shared
is because a job state
can be saved on one node and loaded on another (e.g. if a job gets
preempted on a different node after node failure). When started, this SPI tracks
all checkpoints saved by localhost for expiration. Note that this SPI does not
cache data stored in checkpoints - all the data is loaded from file system
on demand.
Directory paths for shared checkpoints should either be empty or contain previously stored checkpoint files.
setDirectoryPaths(Collection)
)SharedFsCheckpointSpi
can be configured as follows:
IgniteConfiguration cfg = new IgniteConfiguration(); SharedFsCheckpointSpi checkpointSpi = new SharedFsCheckpointSpi(); // List of checkpoint directories where all files are stored. CollectiondirPaths = new ArrayList (); dirPaths.add("/my/directory/path"); dirPaths.add("/other/directory/path"); // Override default directory path. checkpointSpi.setDirectoryPaths(dirPaths); // Override default checkpoint SPI. cfg.setCheckpointSpi(checkpointSpi); // Starts grid. G.start(cfg);
SharedFsCheckpointSpi
can be configured from Spring XML configuration file:
<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <property name="checkpointSpi"> <bean class="org.apache.ignite.spi.checkpoint.sharedfs.GridSharedFsCheckpointSpi"> <!-- Change to shared directory path in your environment. --> <property name="directoryPaths"> <list> <value>/my/directory/path</value> <value>/other/directory/path</value> </list> </property> </bean> </property> ... </bean>
For information about Spring framework visit www.springframework.org
CheckpointSpi
Modifier and Type | Field and Description |
---|---|
static String |
DFLT_DIR_PATH
Default checkpoint directory.
|
Constructor and Description |
---|
SharedFsCheckpointSpi()
Initializes default directory paths.
|
Modifier and Type | Method and Description |
---|---|
String |
getCurrentDirectoryPath()
Gets path to the directory where all checkpoints are saved.
|
Collection<String> |
getDirectoryPaths()
Gets collection of all configured paths where checkpoints can be saved.
|
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.
|
SharedFsCheckpointSpi |
setDirectoryPaths(Collection<String> dirPaths)
Sets path to a shared directory where checkpoints will be stored.
|
SharedFsCheckpointSpi |
setName(String name)
Sets SPI name.
|
void |
spiStart(String igniteInstanceName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
String |
toString() |
addTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextDestroyed0, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
public static final String DFLT_DIR_PATH
IGNITE_HOME/work
folder
if IGNITE_HOME
system or environment variable specified, otherwise it is relative to
work
folder under system java.io.tmpdir
folder.public SharedFsCheckpointSpi()
public Collection<String> getDirectoryPaths()
public String getCurrentDirectoryPath()
@IgniteSpiConfiguration(optional=true) public SharedFsCheckpointSpi setDirectoryPaths(Collection<String> dirPaths)
IGNITE_HOME
system
or environment variable.
If not provided, default value is DFLT_DIR_PATH
.
dirPaths
- Absolute or Ignite installation home folder relative path where checkpoints
will be stored.this
for chaining.public void spiStart(String igniteInstanceName) throws IgniteSpiException
spiStart
in interface IgniteSpi
igniteInstanceName
- Name of Ignite instance this SPI is being started for
(null
for default Ignite instance).IgniteSpiException
- Throws in case of any error during SPI start.public void spiStop() throws IgniteSpiException
Note that this method can be called at any point including during recovery of failed start. It should make no assumptions on what state SPI will be in when this method is called.
spiStop
in interface IgniteSpi
IgniteSpiException
- Thrown in case of any error during SPI stop.public byte[] loadCheckpoint(String key) throws IgniteSpiException
loadCheckpoint
in interface CheckpointSpi
key
- Checkpoint key.null
if there is no data for a given
key.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
.public boolean saveCheckpoint(String key, byte[] state, long timeout, boolean overwrite) throws IgniteSpiException
saveCheckpoint
in interface CheckpointSpi
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.true
if checkpoint has been actually saved, false
otherwise.IgniteSpiException
- Thrown in case of any error while saving
checkpoint data.public boolean removeCheckpoint(String key)
key
.removeCheckpoint
in interface CheckpointSpi
key
- Key for the checkpoint to remove.true
if data has been actually removed, false
otherwise.public void setCheckpointListener(CheckpointListener lsnr)
setCheckpointListener
in interface CheckpointSpi
lsnr
- The listener to set or null
.public SharedFsCheckpointSpi setName(String name)
setName
in class IgniteSpiAdapter
name
- SPI name.this
for chaining.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023