Package org.gridgain.cache.store.jdbc
Class JdbcCacheStoreFactory
java.lang.Object
org.gridgain.cache.store.jdbc.JdbcCacheStoreFactory
- All Implemented Interfaces:
CacheStoreFactory
JDBC cache store factory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault batch size for put and remove operations.static final intDefault batch size for put and remove operations.static final intDefault value for write attempts. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<K,V> CacheStore<K, V> Create a cache store suitable to work with given key and value types.intGet maximum batch size for delete and delete operations.Get data source.Get database dialect.Get executor.intGets maximum number of write attempts in case of database error.intParallel load cache minimum row count threshold.Gets types transformer.getType()Gets types known by store.booleanIftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName").setBatchSize(int batchSize) Set maximum batch size for write and delete operations.setDataSource(DataSource dataSrc) Sets data source.setDialect(JdbcDialect dialect) Set database dialect.setExecutor(ExecutorService executor) Sets the executor for accessing the database.setMaximumWriteAttempts(int maxWrtAttempts) Sets maximum number of write attempts in case of database error.setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold) Parallel load cache minimum row count threshold.setSqlEscapeAll(boolean sqlEscapeAll) Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName").setTransformer(JdbcTypesTransformer transformer) Sets types transformer.Sets store configurations.toString()
-
Field Details
-
DFLT_WRITE_ATTEMPTS
public static final int DFLT_WRITE_ATTEMPTSDefault value for write attempts.- See Also:
-
DFLT_BATCH_SIZE
public static final int DFLT_BATCH_SIZEDefault batch size for put and remove operations.- See Also:
-
DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLD
public static final int DFLT_PARALLEL_LOAD_CACHE_MINIMUM_THRESHOLDDefault batch size for put and remove operations.- See Also:
-
-
Constructor Details
-
JdbcCacheStoreFactory
public JdbcCacheStoreFactory()
-
-
Method Details
-
create
Description copied from interface:CacheStoreFactoryCreate a cache store suitable to work with given key and value types.- Specified by:
createin interfaceCacheStoreFactory- Type Parameters:
K- Key type.V- Value type.- Parameters:
keyCls- Key class.valCls- Value class.- Returns:
- The cache store instance.
-
getExecutor
Get executor.- Returns:
- The executor.
-
setExecutor
Sets the executor for accessing the database. By defaultForkJoinPool.commonPool()executor is used.Thread safety note: it's possible to run into deadlock issue then using a connection pool if a number of user threads accessing cache store is larger than underlying pool size. To mitigate this issue make sure the executor's pool size is large enough, or use a single-threaded executor. This is the safest option.
- Parameters:
executor- The executor.- Returns:
Thisfor chaining.
-
getDataSource
Get data source.- Returns:
- Data source.
-
setDataSource
Sets data source. Data source should be fully configured and ready-to-use.- Parameters:
dataSrc- Data source.- Returns:
Thisfor chaining.
-
getBatchSize
public int getBatchSize()Get maximum batch size for delete and delete operations.- Returns:
- Maximum batch size.
-
setBatchSize
Set maximum batch size for write and delete operations.- Parameters:
batchSize- Maximum batch size.- Returns:
Thisfor chaining.
-
getDialect
Get database dialect.- Returns:
- Database dialect.
-
setDialect
Set database dialect.- Parameters:
dialect- Database dialect.- Returns:
Thisfor chaining.
-
getMaximumWriteAttempts
public int getMaximumWriteAttempts()Gets maximum number of write attempts in case of database error.- Returns:
- Maximum number of write attempts.
-
setMaximumWriteAttempts
Sets maximum number of write attempts in case of database error.- Parameters:
maxWrtAttempts- Number of write attempts.- Returns:
Thisfor chaining.
-
getParallelLoadCacheMinimumThreshold
public int getParallelLoadCacheMinimumThreshold()Parallel load cache minimum row count threshold.- Returns:
- If
0then load sequentially.
-
setParallelLoadCacheMinimumThreshold
public JdbcCacheStoreFactory setParallelLoadCacheMinimumThreshold(int parallelLoadCacheMinThreshold) Parallel load cache minimum row count threshold.- Parameters:
parallelLoadCacheMinThreshold- Minimum row count threshold. If0then load sequentially.- Returns:
Thisfor chaining.
-
getType
Gets types known by store.- Returns:
- Types known by store.
-
setType
Sets store configurations.- Parameters:
type- Store should process.- Returns:
Thisfor chaining.
-
getTransformer
Gets types transformer.- Returns:
- Types transformer.
-
setTransformer
Sets types transformer.- Parameters:
transformer- Types transformer.- Returns:
Thisfor chaining.
-
isSqlEscapeAll
public boolean isSqlEscapeAll()Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName"). This enforces case sensitivity for field names and also allows having special characters in table and field names.- Returns:
- Flag value.
-
setSqlEscapeAll
Iftrueall the SQL table and field names will be escaped with double quotes like ("tableName"."fieldsName"). This enforces case sensitivity for field names and also allows having special characters in table and field names.- Parameters:
sqlEscapeAll- Flag value.- Returns:
thisfor chaining.
-
toString
-