|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.gridgain.grid.spi.GridSpiAdapter
org.gridgain.grid.spi.checkpoint.database.GridDatabaseCheckpointSpi
@GridSpiInfo(author="GridGain Systems",
url="www.gridgain.org",
email="support@gridgain.com",
version="x.x")
@GridSpiMultipleInstancesSupport(value=true)
public class GridDatabaseCheckpointSpiThis class defines database checkpoint SPI implementation. All checkpoints are stored in the database table and available from all nodes in the grid. Note that every node must have access to the database. 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).
GridDatabaseCheckpointSpi.setDataSource(DataSource)).GridDatabaseCheckpointSpi.setCheckpointTableName(String)).GridDatabaseCheckpointSpi.setKeyFieldName(String)). GridDatabaseCheckpointSpi.setKeyFieldType(String)). GridDatabaseCheckpointSpi.setValueFieldName(String)).GridDatabaseCheckpointSpi.setValueFieldType(String)).GridDatabaseCheckpointSpi.setExpireDateFieldName(String)).GridDatabaseCheckpointSpi.setExpireDateFieldType(String)).GridDatabaseCheckpointSpi.setNumberOfRetries(int)).GridDatabaseCheckpointSpi.setUser(String)).GridDatabaseCheckpointSpi.setPassword(String)).
GridDatabaseCheckpointSpi checkpointSpi = new GridDatabaseCheckpointSpi();
javax.sql.DataSource ds = ... // Set datasource.
// Set database checkpoint SPI parameters.
checkpointSpi.setDataSource(ds);
checkpointSpi.setUser("test");
checkpointSpi.setPassword("test");
GridConfigurationAdapter cfg = new GridConfigurationAdapter();
// Override default checkpoint SPI.
cfg.setCheckpointSpi(checkpointSpi);
// Start grid.
GridFactory.start(cfg);
<bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfigurationAdapter" singleton="true">
...
<property name="checkpointSpi">
<bean class="org.gridgain.grid.spi.checkpoint.database.GridDatabaseCheckpointSpi">
<property name="dataSource"><ref bean="anyPoolledDataSourceBean" /></property>
<property name="checkpointTableName" value="GRID_CHECKPOINTS" />
<property name="user" value="test" />
<property name="password" value="test" />
</bean>
</property>
...
</bean>
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_CHECKPOINT_TABLE_NAME
Default checkpoint table name (value is CHECKPOINTS). |
static String |
DFLT_EXPIRE_DATE_FIELD_NAME
Default expiration date field name (value is EXPIRE_DATE). |
static String |
DFLT_EXPIRE_DATE_FIELD_TYPE
Default expiration date field type (value is DATETIME). |
static String |
DFLT_KEY_FIELD_NAME
Default checkpoint key field name (value is NAME). |
static String |
DFLT_KEY_FIELD_TYPE
Default checkpoint key field type (value is VARCHAR(256)). |
static int |
DFLT_NUMBER_OF_RETRIES
Default number of retries in case of errors (value is 2). |
static String |
DFLT_VALUE_FIELD_NAME
Default checkpoint value field name (value is VALUE). |
static String |
DFLT_VALUE_FIELD_TYPE
Default checkpoint value field type (value is BLOB). |
| Constructor Summary | |
|---|---|
GridDatabaseCheckpointSpi()
|
|
| Method Summary | |
|---|---|
String |
getCheckpointTableName()
Gets checkpoint table name. |
String |
getDataSourceInfo()
Gets data source description. |
String |
getExpireDateFieldName()
Gets expiration date field name for checkpoint table. |
String |
getExpireDateFieldType()
Gets expiration date field type for checkpoint table. |
String |
getKeyFieldName()
Gets key field name for checkpoint table. |
String |
getKeyFieldType()
Gets key field type for checkpoint table. |
int |
getNumberOfRetries()
Gets number of retries in case of DB failure. |
String |
getPassword()
Gets checkpoint database password. |
String |
getUser()
Gets checkpoint database user name. |
String |
getValueFieldName()
Gets value field name for checkpoint table. |
String |
getValueFieldType()
Gets value field type for checkpoint table. |
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 |
setCheckpointTableName(String cpTableName)
Sets checkpoint table name. |
void |
setDataSource(DataSource dataSource)
Sets DataSource to use for database access. |
void |
setExpireDateFieldName(String expireDateFieldName)
Sets checkpoint expiration date field name. |
void |
setExpireDateFieldType(String expireDateFieldType)
Sets checkpoint expiration date field type. |
void |
setKeyFieldName(String keyFieldName)
Sets checkpoint key field name. |
void |
setKeyFieldType(String keyFieldType)
Sets checkpoint key field type. |
void |
setNumberOfRetries(int retryNum)
Sets number of retries in case of any database errors. |
void |
setPassword(String password)
Sets checkpoint database password. |
void |
setUser(String user)
Sets checkpoint database user name. |
void |
setValueFieldName(String valFieldName)
Sets checkpoint value field name. |
void |
setValueFieldType(String valFieldType)
Sets checkpoint value field type. |
void |
spiStart(String gridName)
This method is called to start SPI. |
void |
spiStop()
This method is called to stop SPI. |
| Methods inherited from class org.gridgain.grid.spi.GridSpiAdapter |
|---|
assertParameter, configInfo, createSpiAttributeName, getAuthor, getConsistentAttributeNames, 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, toString, 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 |
|---|
public static final int DFLT_NUMBER_OF_RETRIES
public static final String DFLT_EXPIRE_DATE_FIELD_TYPE
public static final String DFLT_EXPIRE_DATE_FIELD_NAME
public static final String DFLT_VALUE_FIELD_TYPE
public static final String DFLT_VALUE_FIELD_NAME
public static final String DFLT_KEY_FIELD_TYPE
public static final String DFLT_KEY_FIELD_NAME
public static final String DFLT_CHECKPOINT_TABLE_NAME
| Constructor Detail |
|---|
public GridDatabaseCheckpointSpi()
| Method Detail |
|---|
public int getNumberOfRetries()
getNumberOfRetries in interface GridDatabaseCheckpointSpiMBeanpublic String getDataSourceInfo()
getDataSourceInfo in interface GridDatabaseCheckpointSpiMBeanpublic String getUser()
getUser in interface GridDatabaseCheckpointSpiMBeanpublic String getPassword()
getPassword in interface GridDatabaseCheckpointSpiMBeanpublic String getCheckpointTableName()
getCheckpointTableName in interface GridDatabaseCheckpointSpiMBeanpublic String getKeyFieldName()
getKeyFieldName in interface GridDatabaseCheckpointSpiMBeanpublic String getKeyFieldType()
getKeyFieldType in interface GridDatabaseCheckpointSpiMBeanpublic String getValueFieldName()
getValueFieldName in interface GridDatabaseCheckpointSpiMBeanpublic String getValueFieldType()
getValueFieldType in interface GridDatabaseCheckpointSpiMBeanpublic String getExpireDateFieldName()
getExpireDateFieldName in interface GridDatabaseCheckpointSpiMBeanpublic String getExpireDateFieldType()
getExpireDateFieldType in interface GridDatabaseCheckpointSpiMBean@GridSpiConfiguration(optional=false) public void setDataSource(DataSource dataSource)
Apache DBCP project provides various wrappers for data sources and connection pools. You can use these wrappers as Spring beans to configure this SPI from Spring configuration file. Refer to Apache DBCP project for more information.
dataSource - DataSource object to set.@GridSpiConfiguration(optional=true) public void setNumberOfRetries(int retryNum)
GridDatabaseCheckpointSpi.DFLT_NUMBER_OF_RETRIES.
retryNum - Number of retries in case of any database errors.@GridSpiConfiguration(optional=true) public void setUser(String user)
user - Checkpoint database user name to set.GridDatabaseCheckpointSpi.setPassword(String)@GridSpiConfiguration(optional=true) public void setPassword(String password)
password - Checkpoint database password to set.GridDatabaseCheckpointSpi.setUser(String)@GridSpiConfiguration(optional=true) public void setCheckpointTableName(String cpTableName)
GridDatabaseCheckpointSpi.DFLT_CHECKPOINT_TABLE_NAME
is used.
cpTableName - Checkpoint table name to set.@GridSpiConfiguration(optional=true) public void setKeyFieldName(String keyFieldName)
GridDatabaseCheckpointSpi.DFLT_KEY_FIELD_NAME is used. Note that you may also want to
change key field type (see GridDatabaseCheckpointSpi.setKeyFieldType(String)).
keyFieldName - Checkpoint key field name to set.@GridSpiConfiguration(optional=true) public void setKeyFieldType(String keyFieldType)
GridDatabaseCheckpointSpi.DFLT_EXPIRE_DATE_FIELD_TYPE is used.
keyFieldType - Checkpoint key field type to set.@GridSpiConfiguration(optional=true) public void setValueFieldName(String valFieldName)
GridDatabaseCheckpointSpi.DFLT_VALUE_FIELD_NAME
is used. Note that you may also want to change the value type
(see GridDatabaseCheckpointSpi.setValueFieldType(String)).
valFieldName - Checkpoint value field name to set.@GridSpiConfiguration(optional=true) public void setValueFieldType(String valFieldType)
GridDatabaseCheckpointSpi.DFLT_VALUE_FIELD_TYPE, which is
BLOB, won't work for all databases. For example, if using HSQL DB,
then the type should be longvarbinary.
valFieldType - Checkpoint value field type to set.@GridSpiConfiguration(optional=true) public void setExpireDateFieldName(String expireDateFieldName)
GridDatabaseCheckpointSpi.DFLT_EXPIRE_DATE_FIELD_NAME is used. Note that you may also
want to change the expiration date field type
(see GridDatabaseCheckpointSpi.setExpireDateFieldType(String)).
expireDateFieldName - Checkpoint expiration date field name to set.@GridSpiConfiguration(optional=true) public void setExpireDateFieldType(String expireDateFieldType)
GridDatabaseCheckpointSpi.DFLT_EXPIRE_DATE_FIELD_TYPE is used. The field should have
corresponding SQL DATETIME type.
expireDateFieldType - Checkpoint expiration date field type to set.
public void spiStart(String gridName)
throws GridSpiException
spiStart in interface GridSpiGridSpiException - Throws in case of any error during SPI start.gridName - Name of grid instance this SPI is being started for
(null for default grid).
public void spiStop()
throws GridSpiException
spiStop in interface GridSpiGridSpiException - Thrown in case of any error during SPI stop.
public byte[] loadCheckpoint(String key)
throws GridSpiException
loadCheckpoint in interface GridCheckpointSpiGridSpiException - 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.key - Checkpoint key.
public boolean removeCheckpoint(String key)
removeCheckpoint in interface GridCheckpointSpikey - Key for the checkpoint to remove.
public void saveCheckpoint(String key,
byte[] state,
long timeout)
throws GridSpiException
saveCheckpoint in interface GridCheckpointSpiGridSpiException - Thrown in case of any error while saving
checkpoint data.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.
|
GridGain 2.1.0
Java API Specification |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
|
GridGain - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved. |
|
|