@IgniteSpiMultipleInstancesSupport(value=true) public class JdbcCheckpointSpi extends IgniteSpiAdapter implements CheckpointSpi
setDataSource(DataSource)
).setCheckpointTableName(String)
).setKeyFieldName(String)
). setKeyFieldType(String)
). setValueFieldName(String)
).setValueFieldType(String)
).setExpireDateFieldName(String)
).setExpireDateFieldType(String)
).setNumberOfRetries(int)
).setUser(String)
).setPwd(String)
).Apache DBCP
project for more information.
JdbcCheckpointSpi
can 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);
JdbcCheckpointSpi
can 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
Modifier and Type | Field and Description |
---|---|
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 ). |
ignite, igniteInstanceName
Constructor and Description |
---|
JdbcCheckpointSpi() |
Modifier and Type | Method and Description |
---|---|
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 |
getPwd()
Gets checkpoint jdbc password.
|
String |
getUser()
Gets checkpoint jdbc 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.
|
protected void |
onContextDestroyed0()
Method to be called in the beginning of onContextDestroyed() 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.
|
void |
setCheckpointListener(CheckpointListener lsnr)
Sets the checkpoint listener.
|
JdbcCheckpointSpi |
setCheckpointTableName(String tblName)
Sets checkpoint table name.
|
JdbcCheckpointSpi |
setDataSource(DataSource dataSrc)
Sets DataSource to use for database access.
|
JdbcCheckpointSpi |
setExpireDateFieldName(String expDateName)
Sets checkpoint expiration date field name.
|
JdbcCheckpointSpi |
setExpireDateFieldType(String expDateType)
Sets checkpoint expiration date field type.
|
JdbcCheckpointSpi |
setKeyFieldName(String keyName)
Sets checkpoint key field name.
|
JdbcCheckpointSpi |
setKeyFieldType(String keyType)
Sets checkpoint key field type.
|
JdbcCheckpointSpi |
setName(String name)
Sets SPI name.
|
JdbcCheckpointSpi |
setNumberOfRetries(int retryNum)
Sets number of retries in case of any database errors.
|
JdbcCheckpointSpi |
setPwd(String pwd)
Sets checkpoint database password.
|
JdbcCheckpointSpi |
setUser(String user)
Sets checkpoint database user name.
|
JdbcCheckpointSpi |
setValueFieldName(String valName)
Sets checkpoint value field name.
|
JdbcCheckpointSpi |
setValueFieldType(String valType)
Sets checkpoint value field type.
|
void |
spiStart(String igniteInstanceName)
This method is called to start SPI.
|
void |
spiStop()
This method is called to stop SPI.
|
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, onContextInitialized0, registerMBean, removeTimeoutObject, started, startInfo, startStopwatch, stopInfo, unregisterMBean
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getNodeAttributes, onClientDisconnected, onClientReconnected, onContextDestroyed, onContextInitialized
public static final int DFLT_NUMBER_OF_RETRIES
2
).public static final String DFLT_EXPIRE_DATE_FIELD_TYPE
DATETIME
).public static final String DFLT_EXPIRE_DATE_FIELD_NAME
EXPIRE_DATE
).public static final String DFLT_VALUE_FIELD_TYPE
BLOB
).public static final String DFLT_VALUE_FIELD_NAME
VALUE
).public static final String DFLT_KEY_FIELD_TYPE
VARCHAR(256)
).public static final String DFLT_KEY_FIELD_NAME
NAME
).public static final String DFLT_CHECKPOINT_TABLE_NAME
CHECKPOINTS
).public int getNumberOfRetries()
public String getDataSourceInfo()
public String getUser()
public String getPwd()
public String getCheckpointTableName()
public String getKeyFieldName()
public String getKeyFieldType()
public String getValueFieldName()
public String getValueFieldType()
public String getExpireDateFieldName()
public String getExpireDateFieldType()
@IgniteSpiConfiguration(optional=false) public JdbcCheckpointSpi setDataSource(DataSource dataSrc)
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.
dataSrc
- DataSource object to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setNumberOfRetries(int retryNum)
DFLT_NUMBER_OF_RETRIES
.retryNum
- Number of retries in case of any database errors.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setUser(String user)
user
and password
are set.user
- Checkpoint database user name to set. null
is a valid value that means that no user
provided. Authentication won't be performed in this case.this
for chaining.setPwd(String)
@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setPwd(String pwd)
user
and password
are set.pwd
- Checkpoint database password to set. null
is a valid value that means that no password
provided. Authentication won't be performed in this case.this
for chaining.setUser(String)
@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setCheckpointTableName(String tblName)
DFLT_CHECKPOINT_TABLE_NAME
is used.tblName
- Checkpoint table name to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setKeyFieldName(String keyName)
DFLT_KEY_FIELD_NAME
is used. Note that you may also want to
change key field type (see setKeyFieldType(String)
).keyName
- Checkpoint key field name to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setKeyFieldType(String keyType)
VARCHAR
, for example).
By default DFLT_EXPIRE_DATE_FIELD_TYPE
is used.keyType
- Checkpoint key field type to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setValueFieldName(String valName)
DFLT_VALUE_FIELD_NAME
is used. Note that you may also want to change the value type
(see setValueFieldType(String)
).valName
- Checkpoint value field name to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setValueFieldType(String valType)
BLOB
type, and the default value of 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
.valType
- Checkpoint value field type to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setExpireDateFieldName(String expDateName)
DFLT_EXPIRE_DATE_FIELD_NAME
is used. Note that you may also
want to change the expiration date field type
(see setExpireDateFieldType(String)
).expDateName
- Checkpoint expiration date field name to set.this
for chaining.@IgniteSpiConfiguration(optional=true) public JdbcCheckpointSpi setExpireDateFieldType(String expDateType)
DFLT_EXPIRE_DATE_FIELD_TYPE
is used. The field should have
corresponding SQL DATETIME
type.expDateType
- Checkpoint expiration date field type to set.this
for chaining.public void spiStart(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.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
public 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 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 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 void setCheckpointListener(CheckpointListener lsnr)
setCheckpointListener
in interface CheckpointSpi
lsnr
- The listener to set or null
.public JdbcCheckpointSpi setName(String name)
setName
in class IgniteSpiAdapter
name
- SPI name.this
for chaining.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023