public class DefaultFilePersistenceManager extends Object implements JobPersistence<String>
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.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_EXT
The default extension for the files in the store.
|
static String |
DEFAULT_PREFIX
The default prefix for the files in the store.
|
| Constructor and Description |
|---|
DefaultFilePersistenceManager(File root)
Initialize this persistence manager with the specified root path, using
DEFAULT_PREFIX
as the files prefix and DEFAULT_EXT as the extension. |
DefaultFilePersistenceManager(File root,
String prefix,
String ext)
Initialize this persistence manager with the specified root path, file prefix and extension.
|
DefaultFilePersistenceManager(String root)
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.
|
| Modifier and Type | Method and Description |
|---|---|
Collection<String> |
allKeys()
Get the keys of all jobs in the persistence store.
|
void |
close()
Close this store and release any used resources.
|
String |
computeKey(JPPFJob job)
Compute the key assigned ot the specified job.
|
void |
deleteJob(String key)
Delete the job with the specified key from the persistence store.
|
JPPFJob |
loadJob(String key)
Load a job from the persistence store given its key.
|
void |
storeJob(String key,
JPPFJob job,
List<org.jppf.node.protocol.Task<?>> tasks)
Store the specified job.
|
String |
toString() |
public static final String DEFAULT_PREFIX
public static final String DEFAULT_EXT
public DefaultFilePersistenceManager(File root)
DEFAULT_PREFIX
as the files prefix and DEFAULT_EXT as the extension.
If the root does not exist, the persistence manager attempts to create it.root - the root path for this persistence manager, where the persisted jobs are stored.IllegalArgumentException - if the root path is invalid or could not be created.public DefaultFilePersistenceManager(File root, String prefix, String ext)
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.IllegalArgumentException - if the root path is invalid or could not be created.public DefaultFilePersistenceManager(String root)
root - the root path for this persistence manager, where the persisted jobs are stored.IllegalArgumentException - if the root path is invalid or could not be created.public DefaultFilePersistenceManager(String root, String prefix, String ext)
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.IllegalArgumentException - if the root path is invalid or could not be created.public String computeKey(JPPFJob job)
computeKey in interface JobPersistence<String>job - the job for which to get a key.public Collection<String> allKeys() throws JobPersistenceException
JobPersistenceallKeys in interface JobPersistence<String>JobPersistenceException - if any error occurs while retrieving the keys.public JPPFJob loadJob(String key) throws JobPersistenceException
JobPersistenceloadJob in interface JobPersistence<String>key - the key allowing to locate the job in the persistence store.JobPersistenceException - if any error occurs while loading the job.public void storeJob(String key, JPPFJob job, List<org.jppf.node.protocol.Task<?>> tasks) throws JobPersistenceException
storeJob in interface JobPersistence<String>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.JobPersistenceException - if any error occurs while storing the job.public void deleteJob(String key) throws JobPersistenceException
JobPersistencedeleteJob in interface JobPersistence<String>key - the key allowing to locate the job in the persistence store.JobPersistenceException - if any error occurs while deleting the job.public void close()
JobPersistenceclose in interface JobPersistence<String>Copyright © 2005-2019 JPPF Team.