Class DefaultDatabasePersistence

java.lang.Object
org.jppf.persistence.AbstractDatabasePersistence<PersistenceInfo>
org.jppf.job.persistence.impl.DefaultDatabasePersistence
All Implemented Interfaces:
JobPersistence

public class DefaultDatabasePersistence extends AbstractDatabasePersistence<PersistenceInfo> implements JobPersistence
A job persistence implementation which stores jobs in a single database table. The table has the following structure:
 CREATE TABLE <table_name> (
   UUID varchar(250) NOT NULL,
   TYPE varchar(20) NOT NULL,
   POSITION int NOT NULL,
   CONTENT blob NOT NULL,
   PRIMARY KEY (UUID, TYPE, POSITION)
 );

Where:

  • the UUID column represents the job uuid
  • the TYPE column represents the type of object, taken from the PersistenceObjectType enum
  • the POSITION column represents the object's position in the job if TYPE is 'task' or 'task_result', otherwise -1
  • the CONTENT column represents the serialized object

The table name is specified in the JPPF configuration like this:
jppf.job.persistence = org.jppf.job.persistence.impl.DefaultDatabasePersistence <table_name>
If unspecified, it defaults to the default table name 'JOB_PERSISTENCE'. If the table does not exist, JPPF will attempt to create it. If this fails for any reason, for instance if the user does not have sufficient privileges, then persistence will be disabled.

This database persistence implementation uses a HikariCP connection pool and datasource. The datasource is specified by name in the configuration:
jppf.job.persistence = org.jppf.job.persistence.impl.DefaultDatabasePersistence <table_name> <datasource_name>
If unspecified, it defaults to 'job_persistence'. The datasource properties must be defined in the JPPF configuration like so:

 jppf.datasource.<configId>.name = <datasource_name>
 jppf.datasource.<configId>.<hikaricp_property> = <value>

Where:

  • configId is used to distinguish the datasource properties when multiple datasources are defined
  • the datasource name is mandatory and is used to store and retrieve the datasource in a custom registry. It is also the datasource name used in the configuration of this job persistence implementation
  • hikaricp_property desginates any valid HikariCP configuration property. Properties not supported by HikariCP are simply ignored

Here is a full example configuration:

 # persistence definition
 jppf.job.persistence = org.jppf.job.persistence.impl.DefaultDatabasePersistence MY_TABLE jobDS

 # datasource definition
 jppf.datasource.jobs.name = jobDS
 jppf.datasource.jobs.driverClassName = com.mysql.jdbc.Driver
 jppf.datasource.jobs.jdbcUrl = jdbc:mysql://localhost:3306/testjppf
 jppf.datasource.jobs.username = testjppf
 jppf.datasource.jobs.password = testjppf
 jppf.datasource.jobs.minimumIdle = 5
 jppf.datasource.jobs.maximumPoolSize = 10
 jppf.datasource.jobs.connectionTimeout = 30000
 jppf.datasource.jobs.idleTimeout = 600000
Author:
Laurent Cohen