Dashboard > GridGain User Guide > Table Of Contents > GridGain Book > Checkpoint SPI > GridJdbcCheckpointSpi
GridJdbcCheckpointSpi
Added by Yakov Zhdanov, last edited by Yakov Zhdanov on Apr 14, 2011
Labels: 
(None)


Click on Javadoc link to open Javadoc documentation.

Package

org.gridgain.grid.spi.checkpoint.jdbc Javadoc

Description

GridJdbcCheckpointSpi Javadoc uses database to store checkpoints. 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).

Configuration

The following configuration parameters can be used to configure GridJdbcCheckpointSpi Javadoc :

Setter Method Description Optional Default
setDataSource(DataSource) Javadoc Sets DataSource to use for database access. No
setCheckpointTableName(String) Javadoc Sets checkpoint table name. Yes CHECKPOINTS
setKeyFieldName(String) Javadoc Sets checkpoint key field name. Yes NAME
setKeyFieldType(String) Javadoc Sets checkpoint key field type. The field should have corresponding SQL string type (VARCHAR, for example). Yes VARCHAR(256)
setValueFieldName(String) Javadoc Sets checkpoint value field name. Yes VALUE
setValueFieldType(String) Javadoc Sets checkpoint value field type. Note, that the field should have corresponding SQL BLOB type. The default value is BLOB, won't work for all databases. For example, if using HSQL DB, then the type should be longvarbinary. Yes BLOB
setExpireDateFieldName(String) Javadoc Sets checkpoint expiration date field name. Yes EXPIRE_DATE
setExpireDateFieldType(String) Javadoc Sets checkpoint expiration date field type. The field should have corresponding SQL DATETIME type. Yes DATETIME
setNumberOfRetries(int) Javadoc Sets number of retries in case of any database errors. Yes 2
setUser(String) Javadoc Sets checkpoint database user name. Note that authentication will be performed only if both, user and password are set. Yes
setPassword(String) Javadoc Sets checkpoint database password. Yes

Apache DBCP

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.

Examples

GridJdbcCheckpointSpi Javadoc can be configured as follows:

GridJdbcCheckpointSpi checkpointSpi = new GridJdbcCheckpointSpi();

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);

or 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.database.GridJdbcCheckpointSpi">
            <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 more information about using Spring framework for configuration click here.

Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators