GridGain™ 2.1.0
Java API Specification

org.gridgain.grid.spi.checkpoint.coherence
Class GridCoherenceCheckpointSpi

java.lang.Object
  extended by org.gridgain.grid.spi.GridSpiAdapter
      extended by org.gridgain.grid.spi.checkpoint.coherence.GridCoherenceCheckpointSpi
All Implemented Interfaces:
GridCoherenceCheckpointSpiMBean, GridCheckpointSpi, GridSpi, GridSpiManagementMBean

@GridSpiInfo(author="GridGain Systems",
             url="www.gridgain.org",
             email="support@gridgain.com",
             version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridCoherenceCheckpointSpi
extends GridSpiAdapter
implements GridCheckpointSpi, GridCoherenceCheckpointSpiMBean

This class defines Coherence-based checkpoint SPI implementation. All checkpoints are stored in distributed cache and available from all nodes in the grid. Note that every node must have access to the cache. The reason of having it 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).

Configuration

Mandatory

This SPI has no mandatory configuration parameters.

Optional

This SPI has following optional configuration parameters:

Java Example

GridCoherenceCheckpointSpi can be configured as follows:
 GridCoherenceCheckpointSpi checkpointSpi = new GridCoherenceCheckpointSpi();

 // Override default cache name.
 checkpointSpi.setCacheName("myCacheName");

 GridConfigurationAdapter cfg = new GridConfigurationAdapter();

 // Override default checkpoint SPI.
 cfg.setCheckpointSpi(checkpointSpi);

 // Start grid.
 GridFactory.start(cfg);
 

Spring Example

GridCoherenceCheckpointSpi can be configured from Spring XML configuration file:
 <bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
     ...
     <property name="checkpointSpi">
         <bean class="org.gridgain.grid.spi.checkpoint.coherence.GridCoherenceCheckpointSpi">
             <!-- Change to own cache name in your environment. -->
             <property name="cacheName" value="myCacheName"/>
         </bean>
     </property>
     ...
 </bean>
 

Availability

Note: Coherence is not shipped with GridGain. If you don't have Coherence, you need to download it separately. See http://www.tangosol.com for more information. Once installed, Coherence should be available on the classpath for GridGain. If you use [GRIDGAIN_HOME]/bin/gridgain.{sh|bat} script to start a grid node you can simply add Coherence JARs to [GRIDGAIN_HOME]/bin/setenv.{sh|bat} scripts that's used to set up class path for the main scripts.


For information about Spring framework visit www.springframework.org



See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

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

 

Field Summary
static String DFLT_CACHE_NAME
          Default Coherence cache name (value is gridgain.checkpoint.cache).
 
Constructor Summary
GridCoherenceCheckpointSpi()
           
 
Method Summary
 String getCacheName()
          Gets name for Coherence cache where all checkpoints are saved.
protected  List<String> getConsistentAttributeNames()
          Returns back list of attributes that should be consistent for this SPI.
 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.
 void setCacheName(String cacheName)
          Sets name for Coherence cache used in grid.
 void spiStart(String gridName)
          This method is called to start SPI.
 void spiStop()
          This method is called to stop SPI.
 String toString()
          
 
Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter
assertParameter, configInfo, createSpiAttributeName, getAuthor, getGridGainHome, getLocalNodeId, getName, getNodeAttributes, getSpiContext, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion, onContextDestroyed, onContextInitialized, registerMBean, setName, setSpiContext, startInfo, startStopwatch, stopInfo, unregisterMBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gridgain.grid.spi.GridSpi
getName, getNodeAttributes, onContextDestroyed, onContextInitialized
 
Methods inherited from interface org.gridgain.grid.spi.GridSpiManagementMBean
getAuthor, getGridGainHome, getLocalNodeId, getName, getStartTimestamp, getStartTimestampFormatted, getUpTime, getUpTimeFormatted, getVendorEmail, getVendorUrl, getVersion
 

Field Detail

DFLT_CACHE_NAME

public static final String DFLT_CACHE_NAME
Default Coherence cache name (value is gridgain.checkpoint.cache).

See Also:
Constant Field Values
Constructor Detail

GridCoherenceCheckpointSpi

public GridCoherenceCheckpointSpi()
Method Detail

setCacheName

@GridSpiConfiguration(optional=true)
public void setCacheName(String cacheName)
Sets name for Coherence cache used in grid.

If not provided, default value is GridCoherenceCheckpointSpi.DFLT_CACHE_NAME.

Parameters:
cacheName - Coherence cache name used in grid.

getCacheName

public String getCacheName()
Gets name for Coherence cache where all checkpoints are saved.

Specified by:
getCacheName in interface GridCoherenceCheckpointSpiMBean
Returns:
Name for Coherence cache.

spiStart

public void spiStart(String gridName)
              throws GridSpiException
This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.

Specified by:
spiStart in interface GridSpi
Throws:
GridSpiException - Throws in case of any error during SPI start.
Parameters:
gridName - Name of grid instance this SPI is being started for (null for default grid).

spiStop

public void spiStop()
             throws GridSpiException
This method is called to stop SPI. After this method returns kernel assumes that this SPI is finished and all resources acquired by it are released. 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.

Specified by:
spiStop in interface GridSpi
Throws:
GridSpiException - Thrown in case of any error during SPI stop.

loadCheckpoint

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

Specified by:
loadCheckpoint in interface GridCheckpointSpi
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

public 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.

Specified by:
saveCheckpoint in interface GridCheckpointSpi
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

public boolean removeCheckpoint(String key)
This method instructs the checkpoint provider to clean saved data for a given key.

Specified by:
removeCheckpoint in interface GridCheckpointSpi
Parameters:
key - Key for the checkpoint to remove.
Returns:
true if data has been actually removed, false otherwise.

getConsistentAttributeNames

protected List<String> getConsistentAttributeNames()
Returns back list of attributes that should be consistent for this SPI. Consistency means that remote node has to have the same attribute with the same value.

Overrides:
getConsistentAttributeNames in class GridSpiAdapter
Returns:
List or attribute names.

toString

public String toString()

Overrides:
toString in class Object

GridGain™ 2.1.0
Java API Specification

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