Class AsynchronousPersistence

java.lang.Object
org.jppf.job.persistence.impl.AsynchronousPersistence
All Implemented Interfaces:
JobPersistence

public class AsynchronousPersistence extends Object implements 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 Details

    • AsynchronousPersistence

      public AsynchronousPersistence(String... params) throws JobPersistenceException
      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