Package org.jppf.client.persistence
Class DefaultFilePersistenceManager
java.lang.Object
org.jppf.client.persistence.DefaultFilePersistenceManager
- All Implemented Interfaces:
JobPersistence<String>
This implementation of
JobPersistence stores jobs on the file system using
Java serialization to a file for each job, and uses the jobs uuids as keys to retrieve them.
The underlying datastore is a file folder with a flat structure, where each file represents a serialized job.
This implementation will use the serialisation scheme, if any, that is configured for the JPPF client.
Note that this implementation is very naive and has a sub-optimal performance, as it stores jobs data in a synchronous, blocking way.
- Author:
- Laurent Cohen
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInitialize this persistence manager with the specified root path, usingDEFAULT_PREFIXas the files prefix andDEFAULT_EXTas the extension.DefaultFilePersistenceManager(File root, String prefix, String ext) Initialize this persistence manager with the specified root path, file prefix and extension.Initialize this persistence manager with the specified root path, using "job" as the files prefix and ".ser" as the extension.DefaultFilePersistenceManager(String root, String prefix, String ext) Initialize this persistence manager with the specified root path. -
Method Summary
Modifier and TypeMethodDescriptionallKeys()Get the keys of all jobs in the persistence store.voidclose()Close this store and release any used resources.computeKey(JPPFJob job) Compute the key assigned ot the specified job.voidDelete the job with the specified key from the persistence store.Load a job from the persistence store given its key.voidStore the specified job.toString()
-
Field Details
-
DEFAULT_PREFIX
The default prefix for the files in the store.- See Also:
-
DEFAULT_EXT
The default extension for the files in the store.- See Also:
-
-
Constructor Details
-
DefaultFilePersistenceManager
Initialize this persistence manager with the specified root path, usingDEFAULT_PREFIXas the files prefix andDEFAULT_EXTas the extension. If the root does not exist, the persistence manager attempts to create it.- Parameters:
root- the root path for this persistence manager, where the persisted jobs are stored.- Throws:
IllegalArgumentException- if the root path is invalid or could not be created.
-
DefaultFilePersistenceManager
Initialize this persistence manager with the specified root path, file prefix and extension. If the root does not exist, the persistence manager attempts to create it.- Parameters:
root- the root path for this persistence manager, where the persisted jobs are stored.prefix- the prefix for the names of the files in the store.ext- the extension for the names of the files in the store.- Throws:
IllegalArgumentException- if the root path is invalid or could not be created.
-
DefaultFilePersistenceManager
Initialize this persistence manager with the specified root path, using "job" as the files prefix and ".ser" as the extension.- Parameters:
root- the root path for this persistence manager, where the persisted jobs are stored.- Throws:
IllegalArgumentException- if the root path is invalid or could not be created.
-
DefaultFilePersistenceManager
Initialize this persistence manager with the specified root path.- Parameters:
root- the root path for this persistence manager, where the persisted jobs are stored.prefix- the prefix for the names of the files in the store.ext- the extension for the names of the files in the store.- Throws:
IllegalArgumentException- if the root path is invalid or could not be created.
-
-
Method Details
-
computeKey
Compute the key assigned ot the specified job.- Specified by:
computeKeyin interfaceJobPersistence<String>- Parameters:
job- the job for which to get a key.- Returns:
- the job's UUID.
-
allKeys
Description copied from interface:JobPersistenceGet the keys of all jobs in the persistence store.- Specified by:
allKeysin interfaceJobPersistence<String>- Returns:
- a collection of objects representing the keys.
- Throws:
JobPersistenceException- if any error occurs while retrieving the keys.
-
loadJob
Description copied from interface:JobPersistenceLoad a job from the persistence store given its key.- Specified by:
loadJobin interfaceJobPersistence<String>- Parameters:
key- the key allowing to locate the job in the persistence store.- Returns:
- a JPPFJob instance, retrieved from the store.
- Throws:
JobPersistenceException- if any error occurs while loading the job.
-
storeJob
public void storeJob(String key, JPPFJob job, List<org.jppf.node.protocol.Task<?>> tasks) throws JobPersistenceException Store the specified job. This implementation serializes the entire job to a file, the first time it is called for a job. On subsequent calls, only the deltas are persisted.- Specified by:
storeJobin interfaceJobPersistence<String>- Parameters:
key- the key allowing to locate the job in the persistence store.job- the job to store.tasks- the newly received completed tasks, may be used to only store the delta for better performance.- Throws:
JobPersistenceException- if any error occurs while storing the job.
-
deleteJob
Description copied from interface:JobPersistenceDelete the job with the specified key from the persistence store.- Specified by:
deleteJobin interfaceJobPersistence<String>- Parameters:
key- the key allowing to locate the job in the persistence store.- Throws:
JobPersistenceException- if any error occurs while deleting the job.
-
toString
-
close
public void close()Description copied from interface:JobPersistenceClose this store and release any used resources.- Specified by:
closein interfaceJobPersistence<String>
-