@IgniteSpiMultipleInstancesSupport(value=true) public class CacheCheckpointSpi extends IgniteSpiAdapter implements CheckpointSpi
setCacheName(String)
)CacheCheckpointSpi
can be configured as follows:
IgniteConfiguration cfg = new IgniteConfiguration(); String cacheName = "checkpoints"; GridCacheConfiguration cacheConfig = new GridCacheConfiguration(); cacheConfig.setName(cacheName); GridCacheCheckpointSpi spi = new GridCacheCheckpointSpi(); spi.setCacheName(cacheName); cfg.setCacheConfiguration(cacheConfig); // Override default checkpoint SPI. cfg.setCheckpointSpi(cpSpi); // Start grid. G.start(cfg);
CacheCheckpointSpi
can be configured from Spring XML configuration file:
<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <!-- Cache configuration. --> <property name="cacheConfiguration"> <list> <bean class="org.apache.ignite.cache.CacheConfiguration"> <property name="name" value="CACHE_NAME"/> </bean> </list> </property> <!-- SPI configuration. --> <property name="checkpointSpi"> <bean class="org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi"> <property name="cacheName" value="CACHE_NAME"/> </bean> </property> ... </bean>
For information about Spring framework visit www.springframework.org
CheckpointSpi
Modifier and Type | Field and Description |
---|---|
static String |
DFLT_CACHE_NAME
Default cache name (value is checkpoints).
|
ignite, igniteInstanceName
Constructor and Description |
---|
CacheCheckpointSpi() |
Modifier and Type | Method and Description |
---|---|
String |
getCacheName()
Gets cache name to be used by this SPI..
|
@Nullable byte[] |
loadCheckpoint(String key)
Loads checkpoint from storage by its unique key.
|
protected void |
onContextDestroyed0()
Method to be called in the beginning of onContextDestroyed() method.
|
protected void |
onContextInitialized0(IgniteSpiContext spiCtx)
Method to be called in the end of onContextInitialized method.
|
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.
|
CacheCheckpointSpi |
setCacheName(String cacheName)
Sets cache name to be used by this SPI.
|
void |
setCheckpointListener(CheckpointListener lsnr)
Sets the checkpoint listener.
|
CacheCheckpointSpi |
setName(String name)
Sets SPI name.
|
void |
spiStart(@Nullable 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, onContextInitialized, 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_CACHE_NAME
@IgniteSpiConfiguration(optional=true) public CacheCheckpointSpi setCacheName(String cacheName)
If cache name is not provided DFLT_CACHE_NAME
is used.
cacheName
- Cache name.this
for chaining.public String getCacheName()
public void spiStart(@Nullable @Nullable 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.protected void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException
onContextInitialized0
in class IgniteSpiAdapter
spiCtx
- SPI context.IgniteSpiException
- In case of errors.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.protected void onContextDestroyed0()
onContextDestroyed0
in class IgniteSpiAdapter
@Nullable public @Nullable 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 CacheCheckpointSpi setName(String name)
setName
in class IgniteSpiAdapter
name
- SPI name.this
for chaining.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024