Package org.jppf.job.persistence.impl
Class CacheablePersistence
java.lang.Object
org.jppf.job.persistence.impl.CacheablePersistence
- All Implemented Interfaces:
JobPersistence
A caching wrapper for any other implementation of
JobPersistence.
The cached artifacts are those handled by the load() and store() methods,
that is, job headers, data providers, tasks and task results. The cache is an LRU cache of soft references to the artifacts.
It guarantees that all its entries will be cleared before an out of memory error is raised. Additionally the cache has a capacity which can be
specified in the configuration and which defaults to 1024.
This cacheable persistence is configured as follows:
# shorten the configuration value for clarity wrapper = org.jppf.job.persistence.impl.CacheablePersistence # cacheable persistence with default capacity of 1024 jppf.job.persistence = ${wrapper} <actual_persistence> <param1> ... <paramN> # cacheable persistence with a specified capacity jppf.job.persistence = ${wrapper} <capacity> <actual_persistence> <param1> ... <paramN>
Here is a concrete example wrapping a default database persistence:
# shortcut for the package name pkg = org.jppf.job.persistence.impl # cacheable database persistence with a capacity of 10000, # a table named 'JPPF_TEST' and datasource named 'JobDS' jppf.job.persistence = ${pkg}.CacheablePersistence 10000 ${pkg}.DefaultDatabasePersistence JPPF_TEST JobDS
- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsConstructorDescriptionCacheablePersistence(String... params) Initialize this persistence with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoidDelete the persisted job with the psecified UUID.Get the UUIDs of all persisted job.int[]getTaskPositions(String jobUuid) Get the positions of all the tasks in the specified job.int[]getTaskResultPositions(String jobUuid) Get the positions of all the task results in the specified job.booleanisJobPersisted(String jobUuid) Determine whether a job is persisted, that is, present in the persistence store.load(Collection<PersistenceInfo> infos) Load the specified job elements.voidstore(Collection<PersistenceInfo> infos) Store the specified job elements.
-
Constructor Details
-
CacheablePersistence
Initialize this persistence with the specified parameters.- Parameters:
params- if the first parameter is a number, then it represents the cache size, and the remaining parameters represent the wrapped persistence implementation. Otherwise it represents the wrapped persistence and the remaining parameters are those of the wrapped persistence.- Throws:
JobPersistenceException- if any error occurs.
-
-
Method Details
-
store
Description copied from interface:JobPersistenceStore the specified job elements. All elements are assumed to be part of the same job.- Specified by:
storein interfaceJobPersistence- Parameters:
infos- collection of information objects on the job elements to store.- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
load
Description copied from interface:JobPersistenceLoad the specified job elements. All elements are assumed to be part of the same job.- Specified by:
loadin interfaceJobPersistence- Parameters:
infos- information on the persisted job elements to load.- Returns:
- an input stream providing the serialized job header.
- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
getPersistedJobUuids
Description copied from interface:JobPersistenceGet the UUIDs of all persisted job.- Specified by:
getPersistedJobUuidsin interfaceJobPersistence- Returns:
- a list of strings reprensenting job UUIDs.
- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
getTaskPositions
Description copied from interface:JobPersistenceGet the positions of all the tasks in the specified job.- Specified by:
getTaskPositionsin interfaceJobPersistence- Parameters:
jobUuid- the uuid of the job for which to find the task positions.- Returns:
- an array of int representing the positions.
- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
getTaskResultPositions
Description copied from interface:JobPersistenceGet the positions of all the task results in the specified job.- Specified by:
getTaskResultPositionsin interfaceJobPersistence- Parameters:
jobUuid- the uuid of the job for which to find the task result positions.- Returns:
- an array of int representing the positions.
- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
deleteJob
Description copied from interface:JobPersistenceDelete the persisted job with the psecified UUID.- Specified by:
deleteJobin interfaceJobPersistence- Parameters:
jobUuid- the UUID of the job to load.- Throws:
JobPersistenceException- if any erorr occurs during the persistence operation.
-
isJobPersisted
Description copied from interface:JobPersistenceDetermine whether a job is persisted, that is, present in the persistence store.- Specified by:
isJobPersistedin interfaceJobPersistence- Parameters:
jobUuid- the UUID of the job to check.- Returns:
trueif the job is in the persistence store,falseotherwise.- Throws:
JobPersistenceException- if any error occurs while accessing the persistence store.
-