Class JdbcCheckpointSpi
- java.lang.Object
- 
- org.apache.ignite.spi.IgniteSpiAdapter
- 
- org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi
 
 
- 
- All Implemented Interfaces:
- CheckpointSpi,- IgniteSpi
 
 @IgniteSpiMultipleInstancesSupport(true) public class JdbcCheckpointSpi extends IgniteSpiAdapter implements CheckpointSpi This class defines JDBC 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).ConfigurationMandatoryThis SPI has following mandatory configuration parameters.- DataSource (see setDataSource(DataSource)).
 OptionalThis SPI has following optional configuration parameters:- Checkpoint table name (see setCheckpointTableName(String)).
- Checkpoint key field name (see setKeyFieldName(String)).
- Checkpoint key field type (see setKeyFieldType(String)).
- Checkpoint value field name (see setValueFieldName(String)).
- Checkpoint value field type (see setValueFieldType(String)).
- Checkpoint expiration date field name (see setExpireDateFieldName(String)).
- Checkpoint expiration date field type (see setExpireDateFieldType(String)).
- Number of retries in case of any failure (see setNumberOfRetries(int)).
- User name (see setUser(String)).
- Password (see setPwd(String)).
 Apache DBCPApache 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 toApache DBCPproject for more information.Java ExampleJdbcCheckpointSpican be configured as follows:IgniteConfiguration cfg = new IgniteConfiguration(); GridJdbcCheckpointSpi checkpointSpi = new GridJdbcCheckpointSpi(); javax.sql.DataSource ds = ... // Set datasource. // Set jdbc checkpoint SPI parameters. checkpointSpi.setDataSource(ds); checkpointSpi.setUser("test"); checkpointSpi.setPassword("test"); // Override default checkpoint SPI. cfg.setCheckpointSpi(checkpointSpi); // Starts grid. G.start(cfg);Spring ExampleJdbcCheckpointSpican 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.jdbc.JdbcCheckpointSpi"> <property name="dataSrc"><ref bean="anyPooledDataSourceBean" /></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
- 
- 
Field SummaryFields Modifier and Type Field Description static StringDFLT_CHECKPOINT_TABLE_NAMEDefault checkpoint table name (value isCHECKPOINTS).static StringDFLT_EXPIRE_DATE_FIELD_NAMEDefault expiration date field name (value isEXPIRE_DATE).static StringDFLT_EXPIRE_DATE_FIELD_TYPEDefault expiration date field type (value isDATETIME).static StringDFLT_KEY_FIELD_NAMEDefault checkpoint key field name (value isNAME).static StringDFLT_KEY_FIELD_TYPEDefault checkpoint key field type (value isVARCHAR(256)).static intDFLT_NUMBER_OF_RETRIESDefault number of retries in case of errors (value is2).static StringDFLT_VALUE_FIELD_NAMEDefault checkpoint value field name (value isVALUE).static StringDFLT_VALUE_FIELD_TYPEDefault checkpoint value field type (value isBLOB).- 
Fields inherited from class org.apache.ignite.spi.IgniteSpiAdapterignite, igniteInstanceName
 
- 
 - 
Constructor SummaryConstructors Constructor Description JdbcCheckpointSpi()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCheckpointTableName()Gets checkpoint table name.StringgetDataSourceInfo()Gets data source description.StringgetExpireDateFieldName()Gets expiration date field name for checkpoint table.StringgetExpireDateFieldType()Gets expiration date field type for checkpoint table.StringgetKeyFieldName()Gets key field name for checkpoint table.StringgetKeyFieldType()Gets key field type for checkpoint table.intgetNumberOfRetries()Gets number of retries in case of DB failure.StringgetPwd()Gets checkpoint jdbc password.StringgetUser()Gets checkpoint jdbc user name.StringgetValueFieldName()Gets value field name for checkpoint table.StringgetValueFieldType()Gets value field type for checkpoint table.byte[]loadCheckpoint(String key)Loads checkpoint from storage by its unique key.protected voidonContextDestroyed0()Method to be called in the beginning of onContextDestroyed() method.booleanremoveCheckpoint(String key)This method instructs the checkpoint provider to clean saved data for a givenkey.booleansaveCheckpoint(String key, byte[] state, long timeout, boolean overwrite)Saves checkpoint to the storage.voidsetCheckpointListener(CheckpointListener lsnr)Sets the checkpoint listener.JdbcCheckpointSpisetCheckpointTableName(String tblName)Sets checkpoint table name.JdbcCheckpointSpisetDataSource(DataSource dataSrc)Sets DataSource to use for database access.JdbcCheckpointSpisetExpireDateFieldName(String expDateName)Sets checkpoint expiration date field name.JdbcCheckpointSpisetExpireDateFieldType(String expDateType)Sets checkpoint expiration date field type.JdbcCheckpointSpisetKeyFieldName(String keyName)Sets checkpoint key field name.JdbcCheckpointSpisetKeyFieldType(String keyType)Sets checkpoint key field type.JdbcCheckpointSpisetName(String name)Sets SPI name.JdbcCheckpointSpisetNumberOfRetries(int retryNum)Sets number of retries in case of any database errors.JdbcCheckpointSpisetPwd(String pwd)Sets checkpoint database password.JdbcCheckpointSpisetUser(String user)Sets checkpoint database user name.JdbcCheckpointSpisetValueFieldName(String valName)Sets checkpoint value field name.JdbcCheckpointSpisetValueFieldType(String valType)Sets checkpoint value field type.voidspiStart(String igniteInstanceName)This method is called to start SPI.voidspiStop()This method is called to stop SPI.- 
Methods inherited from class org.apache.ignite.spi.IgniteSpiAdapteraddTimeoutObject, assertParameter, checkConfigurationConsistency0, clientFailureDetectionTimeout, configInfo, createSpiAttributeName, failureDetectionTimeout, failureDetectionTimeoutEnabled, failureDetectionTimeoutEnabled, getConsistentAttributeNames, getExceptionRegistry, getLocalNode, getName, getNodeAttributes, getSpiContext, ignite, initFailureDetectionTimeout, injectables, injectResources, isNodeStopping, onBeforeStart, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.ignite.spi.IgniteSpigetName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
 
- 
 
- 
- 
- 
Field Detail- 
DFLT_NUMBER_OF_RETRIESpublic static final int DFLT_NUMBER_OF_RETRIES Default number of retries in case of errors (value is2).- See Also:
- Constant Field Values
 
 - 
DFLT_EXPIRE_DATE_FIELD_TYPEpublic static final String DFLT_EXPIRE_DATE_FIELD_TYPE Default expiration date field type (value isDATETIME).- See Also:
- Constant Field Values
 
 - 
DFLT_EXPIRE_DATE_FIELD_NAMEpublic static final String DFLT_EXPIRE_DATE_FIELD_NAME Default expiration date field name (value isEXPIRE_DATE).- See Also:
- Constant Field Values
 
 - 
DFLT_VALUE_FIELD_TYPEpublic static final String DFLT_VALUE_FIELD_TYPE Default checkpoint value field type (value isBLOB).- See Also:
- Constant Field Values
 
 - 
DFLT_VALUE_FIELD_NAMEpublic static final String DFLT_VALUE_FIELD_NAME Default checkpoint value field name (value isVALUE).- See Also:
- Constant Field Values
 
 - 
DFLT_KEY_FIELD_TYPEpublic static final String DFLT_KEY_FIELD_TYPE Default checkpoint key field type (value isVARCHAR(256)).- See Also:
- Constant Field Values
 
 - 
DFLT_KEY_FIELD_NAMEpublic static final String DFLT_KEY_FIELD_NAME Default checkpoint key field name (value isNAME).- See Also:
- Constant Field Values
 
 - 
DFLT_CHECKPOINT_TABLE_NAMEpublic static final String DFLT_CHECKPOINT_TABLE_NAME Default checkpoint table name (value isCHECKPOINTS).- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getNumberOfRetriespublic int getNumberOfRetries() Gets number of retries in case of DB failure.- Returns:
- Number of retries.
 
 - 
getDataSourceInfopublic String getDataSourceInfo() Gets data source description.- Returns:
- Description for data source.
 
 - 
getUserpublic String getUser() Gets checkpoint jdbc user name.- Returns:
- User name for checkpoint jdbc.
 
 - 
getPwdpublic String getPwd() Gets checkpoint jdbc password.- Returns:
- Password for checkpoint jdbc.
 
 - 
getCheckpointTableNamepublic String getCheckpointTableName() Gets checkpoint table name.- Returns:
- Checkpoint table name.
 
 - 
getKeyFieldNamepublic String getKeyFieldName() Gets key field name for checkpoint table.- Returns:
- Key field name for checkpoint table.
 
 - 
getKeyFieldTypepublic String getKeyFieldType() Gets key field type for checkpoint table.- Returns:
- Key field type for checkpoint table.
 
 - 
getValueFieldNamepublic String getValueFieldName() Gets value field name for checkpoint table.- Returns:
- Value field name for checkpoint table.
 
 - 
getValueFieldTypepublic String getValueFieldType() Gets value field type for checkpoint table.- Returns:
- Value field type for checkpoint table.
 
 - 
getExpireDateFieldNamepublic String getExpireDateFieldName() Gets expiration date field name for checkpoint table.- Returns:
- Create date field name for checkpoint table.
 
 - 
getExpireDateFieldTypepublic String getExpireDateFieldType() Gets expiration date field type for checkpoint table.- Returns:
- Expiration date field type for checkpoint table.
 
 - 
setDataSource@IgniteSpiConfiguration(optional=false) public JdbcCheckpointSpi setDataSource(DataSource dataSrc) Sets DataSource to use for database access. This parameter is mandatory and must be provided for this SPI to be able to start.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 DBCPproject for more information.- Parameters:
- dataSrc- DataSource object to set.
- Returns:
- thisfor chaining.
 
 - 
setNumberOfRetries@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setNumberOfRetries(int retryNum) Sets number of retries in case of any database errors. By default the value isDFLT_NUMBER_OF_RETRIES.- Parameters:
- retryNum- Number of retries in case of any database errors.
- Returns:
- thisfor chaining.
 
 - 
setUser@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setUser(String user) Sets checkpoint database user name. Note that authentication will be performed only if both,userandpasswordare set.- Parameters:
- user- Checkpoint database user name to set.- nullis a valid value that means that no user provided. Authentication won't be performed in this case.
- Returns:
- thisfor chaining.
- See Also:
- setPwd(String)
 
 - 
setPwd@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setPwd(String pwd) Sets checkpoint database password. Note that authentication will be performed only if both,userandpasswordare set.- Parameters:
- pwd- Checkpoint database password to set.- nullis a valid value that means that no password provided. Authentication won't be performed in this case.
- Returns:
- thisfor chaining.
- See Also:
- setUser(String)
 
 - 
setCheckpointTableName@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setCheckpointTableName(String tblName) Sets checkpoint table name. By defaultDFLT_CHECKPOINT_TABLE_NAMEis used.- Parameters:
- tblName- Checkpoint table name to set.
- Returns:
- thisfor chaining.
 
 - 
setKeyFieldName@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setKeyFieldName(String keyName) Sets checkpoint key field name. By default,DFLT_KEY_FIELD_NAMEis used. Note that you may also want to change key field type (seesetKeyFieldType(String)).- Parameters:
- keyName- Checkpoint key field name to set.
- Returns:
- thisfor chaining.
 
 - 
setKeyFieldType@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setKeyFieldType(String keyType) Sets checkpoint key field type. The field should have corresponding SQL string type (VARCHAR, for example). By defaultDFLT_EXPIRE_DATE_FIELD_TYPEis used.- Parameters:
- keyType- Checkpoint key field type to set.
- Returns:
- thisfor chaining.
 
 - 
setValueFieldName@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setValueFieldName(String valName) Sets checkpoint value field name. By defaultDFLT_VALUE_FIELD_NAMEis used. Note that you may also want to change the value type (seesetValueFieldType(String)).- Parameters:
- valName- Checkpoint value field name to set.
- Returns:
- thisfor chaining.
 
 - 
setValueFieldType@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setValueFieldType(String valType) Sets checkpoint value field type. Note, that the field should have corresponding SQLBLOBtype, and the default value ofDFLT_VALUE_FIELD_TYPE, which isBLOB, won't work for all databases. For example, if usingHSQL DB, then the type should belongvarbinary.- Parameters:
- valType- Checkpoint value field type to set.
- Returns:
- thisfor chaining.
 
 - 
setExpireDateFieldName@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setExpireDateFieldName(String expDateName) Sets checkpoint expiration date field name. By defaultDFLT_EXPIRE_DATE_FIELD_NAMEis used. Note that you may also want to change the expiration date field type (seesetExpireDateFieldType(String)).- Parameters:
- expDateName- Checkpoint expiration date field name to set.
- Returns:
- thisfor chaining.
 
 - 
setExpireDateFieldType@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setExpireDateFieldType(String expDateType) Sets checkpoint expiration date field type. By defaultDFLT_EXPIRE_DATE_FIELD_TYPEis used. The field should have corresponding SQLDATETIMEtype.- Parameters:
- expDateType- Checkpoint expiration date field type to set.
- Returns:
- thisfor chaining.
 
 - 
spiStartpublic void spiStart(String igniteInstanceName) throws IgniteSpiException This method is called to start SPI. After this method returns successfully kernel assumes that SPI is fully operational.- Specified by:
- spiStartin interface- IgniteSpi
- Parameters:
- igniteInstanceName- Name of Ignite instance this SPI is being started for (- nullfor default Ignite instance).
- Throws:
- IgniteSpiException- Throws in case of any error during SPI start.
 
 - 
spiStoppublic void spiStop() throws IgniteSpiExceptionThis 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:
- spiStopin interface- IgniteSpi
- Throws:
- IgniteSpiException- Thrown in case of any error during SPI stop.
 
 - 
onContextDestroyed0protected void onContextDestroyed0() Method to be called in the beginning of onContextDestroyed() method.- Overrides:
- onContextDestroyed0in class- IgniteSpiAdapter
 
 - 
loadCheckpointpublic byte[] loadCheckpoint(String key) throws IgniteSpiException Loads checkpoint from storage by its unique key.- Specified by:
- loadCheckpointin interface- CheckpointSpi
- Parameters:
- key- Checkpoint key.
- Returns:
- Loaded data or nullif there is no data for a given key.
- Throws:
- IgniteSpiException- Thrown in case of any error while loading checkpoint data. Note that in case when given- keyis not found this method will return- null.
 
 - 
removeCheckpointpublic boolean removeCheckpoint(String key) This method instructs the checkpoint provider to clean saved data for a givenkey.- Specified by:
- removeCheckpointin interface- CheckpointSpi
- Parameters:
- key- Key for the checkpoint to remove.
- Returns:
- trueif data has been actually removed,- falseotherwise.
 
 - 
saveCheckpointpublic boolean saveCheckpoint(String key, byte[] state, long timeout, boolean overwrite) throws IgniteSpiException Saves checkpoint to the storage.- Specified by:
- saveCheckpointin interface- CheckpointSpi
- 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- 0means that timeout will never expire.
- overwrite- Whether or not overwrite checkpoint if it already exists.
- Returns:
- trueif checkpoint has been actually saved,- falseotherwise.
- Throws:
- IgniteSpiException- Thrown in case of any error while saving checkpoint data.
 
 - 
setCheckpointListenerpublic void setCheckpointListener(CheckpointListener lsnr) Sets the checkpoint listener.- Specified by:
- setCheckpointListenerin interface- CheckpointSpi
- Parameters:
- lsnr- The listener to set or- null.
 
 - 
setNamepublic JdbcCheckpointSpi setName(String name) Sets SPI name.- Overrides:
- setNamein class- IgniteSpiAdapter
- Parameters:
- name- SPI name.
- Returns:
- thisfor chaining.
 
 
- 
 
-