Package org.jppf.job.persistence.impl
Class AsynchronousPersistence
java.lang.Object
org.jppf.job.persistence.impl.AsynchronousPersistence
- All Implemented Interfaces:
JobPersistence
An asynchronous wrapper for any other job persistence implementation. The methods of
JobPersistence that do not return a result
(void return type) are non-blocking and return immediately. All other methods will block until they are executed and their result is available.
The execution of the interface's methods are delegated to a thread pool, whose size can be defined in the configuration or defaults to Runtime.getRuntime().availableProcessors().
This asynchronous persistence can be configured in two forms:
# shorten the configuration value for clarity wrapper = org.jppf.job.persistence.impl.AsynchronousPersistence # asynchronous persistence with default thread pool size jppf.job.persistence = ${wrapper} <actual_persistence> <param1> ... <paramN> # asynchronous persistence with a specified thread pool size jppf.job.persistence = ${wrapper} <pool_size> <actual_persistence> <param1> ... <paramN>
Here is an example configuration for an asynchronous database persistence:
pkg = org.jppf.job.persistence.impl # asynchronous database persistence with pool of 4 threads, # a table named 'JPPF_TEST' and datasource named 'JobDS' jppf.job.persistence = ${pkg}.AsynchronousPersistence 4 ${pkg}.DefaultDatabasePersistence JPPF_TEST JobDS
- Author:
- Laurent Cohen
-
Constructor Summary
ConstructorsConstructorDescriptionAsynchronousPersistence(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
-
AsynchronousPersistence
Initialize this persistence with the specified parameters.- Parameters:
params- if the first parameter is a number, then it represents the number of threads that perform the asynchronous processing, 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.
-