Package org.apache.batchee.container.services.persistence

## Class JDBCPersistenceManagerService

- java.lang.Object
- - org.apache.batchee.container.services.persistence.JDBCPersistenceManagerService

- All Implemented Interfaces:
    `BatchService`, `PersistenceManagerService`

      public class JDBCPersistenceManagerService
      extends Object
      implements PersistenceManagerService

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.apache.batchee.spi.PersistenceManagerService

      `PersistenceManagerService.TimestampType`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected DataSource` | `dataSource` |
    `protected String` | `driver` |
    `protected String` | `jndiName` |
    `protected String` | `pwd` |
    `protected String` | `schema` |
    `protected String` | `url` |
    `protected String` | `user` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `JDBCPersistenceManagerService()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `cleanUp​(long instanceId)` |
    `void` | `cleanUp​(Date until)` |
    `void` | `createCheckpointData​(CheckpointDataKey key, CheckpointData value)` |
    `RuntimeFlowInSplitExecution` | `createFlowInSplitExecution​(javax.batch.runtime.JobInstance jobInstance, javax.batch.runtime.BatchStatus batchStatus)` |
    `RuntimeJobExecution` | `createJobExecution​(javax.batch.runtime.JobInstance jobInstance, Properties jobParameters, javax.batch.runtime.BatchStatus batchStatus)` | Create a JobExecution
    `javax.batch.runtime.JobInstance` | `createJobInstance​(String name, String jobXml)` | Creates a JobIntance
    `JobStatus` | `createJobStatus​(long jobInstanceId)` | Create a JobStatus
    `StepExecutionImpl` | `createStepExecution​(long rootJobExecId, StepContextImpl stepContext)` | Create a StepExecution
    `StepStatus` | `createStepStatus​(long stepExecId)` | Create a StepStatus
    `javax.batch.runtime.JobInstance` | `createSubJobInstance​(String name)` |
    `CheckpointData` | `getCheckpointData​(CheckpointDataKey key)` |
    `protected Connection` | `getConnection()` |
    `protected Connection` | `getConnectionToDefaultSchema()` |
    `long` | `getJobInstanceIdByExecutionId​(long executionId)` |
    `Set<String>` | `getJobNames()` |
    `JobStatus` | `getJobStatus​(long instanceId)` | Get a JobStatus
    `JobStatus` | `getJobStatusFromExecution​(long executionId)` |
    `long` | `getMostRecentExecutionId​(long jobInstanceId)` |
    `Properties` | `getParameters​(long executionId)` |
    `javax.batch.runtime.StepExecution` | `getStepExecutionByStepExecutionId​(long stepExecId)` |
    `List<javax.batch.runtime.StepExecution>` | `getStepExecutionsForJobExecution​(long execid)` |
    `StepStatus` | `getStepStatus​(long instanceId, String stepName)` | Get a StepStatus
    `void` | `init​(Properties batchConfig)` |
    `InternalJobExecution` | `jobOperatorGetJobExecution​(long jobExecutionId)` |
    `List<InternalJobExecution>` | `jobOperatorGetJobExecutions​(long jobInstanceId)` |
    `int` | `jobOperatorGetJobInstanceCount​(String jobName)` | JOB OPERATOR ONLY METHODS
    `List<Long>` | `jobOperatorGetJobInstanceIds​(String jobName, int start, int count)` |
    `Set<Long>` | `jobOperatorGetRunningExecutions​(String jobName)` |
    `String` | `jobOperatorQueryJobExecutionBatchStatus​(long key)` |
    `String` | `jobOperatorQueryJobExecutionExitStatus​(long key)` |
    `Timestamp` | `jobOperatorQueryJobExecutionTimestamp​(long key, PersistenceManagerService.TimestampType timestampType)` |
    `void` | `markJobStarted​(long key, Timestamp startTS)` |
    `void` | `setCheckpointData​(CheckpointDataKey key, CheckpointData value)` |
    `String` | `toString()` |
    `void` | `updateBatchStatusOnly​(long key, javax.batch.runtime.BatchStatus batchStatus, Timestamp updatets)` |
    `void` | `updateJobStatus​(long instanceId, JobStatus jobStatus)` | Update a JobStatus
    `void` | `updateStepExecution​(long rootJobExecId, StepContextImpl stepContext)` | Update a StepExecution
    `void` | `updateStepStatus​(long stepExecutionId, StepStatus stepStatus)` | Update a StepStatus
    `void` | `updateWithFinalExecutionStatusesAndTimestamps​(long key, javax.batch.runtime.BatchStatus batchStatus, String exitStatus, Timestamp updatets)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### dataSource

          protected DataSource dataSource

    - #### jndiName

          protected String jndiName

    - #### driver

          protected String driver

    - #### schema

          protected String schema

    - #### url

          protected String url

    - #### user

          protected String user

    - #### pwd

          protected String pwd

  - ### Constructor Detail

    - #### JDBCPersistenceManagerService

          public JDBCPersistenceManagerService()

  - ### Method Detail

    - #### init

          public void init​(Properties batchConfig)
                    throws BatchContainerServiceException

      Specified by:
        `init` in interface `BatchService`
      Throws:
        `BatchContainerServiceException`

    - #### getConnection

          protected Connection getConnection()
                                      throws SQLException

      Throws:
        `SQLException`

    - #### createCheckpointData

          public void createCheckpointData​(CheckpointDataKey key,
                                           CheckpointData value)

    - #### getCheckpointData

          public CheckpointData getCheckpointData​(CheckpointDataKey key)

      Specified by:
        `getCheckpointData` in interface `PersistenceManagerService`

    - #### setCheckpointData

          public void setCheckpointData​(CheckpointDataKey key,
                                        CheckpointData value)

      Specified by:
        `setCheckpointData` in interface `PersistenceManagerService`

    - #### getConnectionToDefaultSchema

          protected Connection getConnectionToDefaultSchema()
                                                     throws SQLException

      Returns:
        the database connection. The schema is set to whatever default its used by the underlying database.
      Throws:
        `SQLException`

    - #### jobOperatorGetJobInstanceCount

          public int jobOperatorGetJobInstanceCount​(String jobName)

      Description copied from interface: `PersistenceManagerService`
      JOB OPERATOR ONLY METHODS
      Specified by:
        `jobOperatorGetJobInstanceCount` in interface `PersistenceManagerService`

    - #### jobOperatorGetJobInstanceIds

          public List<Long> jobOperatorGetJobInstanceIds​(String jobName,
                                                         int start,
                                                         int count)

      Specified by:
        `jobOperatorGetJobInstanceIds` in interface `PersistenceManagerService`

    - #### getJobNames

          public Set<String> getJobNames()

      Specified by:
        `getJobNames` in interface `PersistenceManagerService`

    - #### jobOperatorQueryJobExecutionTimestamp

          public Timestamp jobOperatorQueryJobExecutionTimestamp​(long key,
                                                                 PersistenceManagerService.TimestampType timestampType)

      Specified by:
        `jobOperatorQueryJobExecutionTimestamp` in interface `PersistenceManagerService`

    - #### jobOperatorQueryJobExecutionBatchStatus

          public String jobOperatorQueryJobExecutionBatchStatus​(long key)

      Specified by:
        `jobOperatorQueryJobExecutionBatchStatus` in interface `PersistenceManagerService`

    - #### jobOperatorQueryJobExecutionExitStatus

          public String jobOperatorQueryJobExecutionExitStatus​(long key)

      Specified by:
        `jobOperatorQueryJobExecutionExitStatus` in interface `PersistenceManagerService`

    - #### getParameters

          public Properties getParameters​(long executionId)
                                   throws javax.batch.operations.NoSuchJobExecutionException

      Specified by:
        `getParameters` in interface `PersistenceManagerService`
      Throws:
        `javax.batch.operations.NoSuchJobExecutionException`

    - #### getStepExecutionsForJobExecution

          public List<javax.batch.runtime.StepExecution> getStepExecutionsForJobExecution​(long execid)

      Specified by:
        `getStepExecutionsForJobExecution` in interface `PersistenceManagerService`

    - #### getStepExecutionByStepExecutionId

          public javax.batch.runtime.StepExecution getStepExecutionByStepExecutionId​(long stepExecId)

      Specified by:
        `getStepExecutionByStepExecutionId` in interface `PersistenceManagerService`

    - #### updateBatchStatusOnly

          public void updateBatchStatusOnly​(long key,
                                            javax.batch.runtime.BatchStatus batchStatus,
                                            Timestamp updatets)

      Specified by:
        `updateBatchStatusOnly` in interface `PersistenceManagerService`

    - #### updateWithFinalExecutionStatusesAndTimestamps

          public void updateWithFinalExecutionStatusesAndTimestamps​(long key,
                                                                    javax.batch.runtime.BatchStatus batchStatus,
                                                                    String exitStatus,
                                                                    Timestamp updatets)

      Specified by:
        `updateWithFinalExecutionStatusesAndTimestamps` in interface `PersistenceManagerService`

    - #### markJobStarted

          public void markJobStarted​(long key,
                                     Timestamp startTS)

      Specified by:
        `markJobStarted` in interface `PersistenceManagerService`

    - #### jobOperatorGetJobExecution

          public InternalJobExecution jobOperatorGetJobExecution​(long jobExecutionId)

      Specified by:
        `jobOperatorGetJobExecution` in interface `PersistenceManagerService`

    - #### jobOperatorGetJobExecutions

          public List<InternalJobExecution> jobOperatorGetJobExecutions​(long jobInstanceId)

      Specified by:
        `jobOperatorGetJobExecutions` in interface `PersistenceManagerService`

    - #### jobOperatorGetRunningExecutions

          public Set<Long> jobOperatorGetRunningExecutions​(String jobName)

      Specified by:
        `jobOperatorGetRunningExecutions` in interface `PersistenceManagerService`

    - #### getJobStatusFromExecution

          public JobStatus getJobStatusFromExecution​(long executionId)

      Specified by:
        `getJobStatusFromExecution` in interface `PersistenceManagerService`

    - #### getJobInstanceIdByExecutionId

          public long getJobInstanceIdByExecutionId​(long executionId)
                                             throws javax.batch.operations.NoSuchJobExecutionException

      Specified by:
        `getJobInstanceIdByExecutionId` in interface `PersistenceManagerService`
      Throws:
        `javax.batch.operations.NoSuchJobExecutionException`

    - #### createSubJobInstance

          public javax.batch.runtime.JobInstance createSubJobInstance​(String name)

      Specified by:
        `createSubJobInstance` in interface `PersistenceManagerService`

    - #### createJobInstance

          public javax.batch.runtime.JobInstance createJobInstance​(String name,
                                                                   String jobXml)

      Description copied from interface: `PersistenceManagerService`
      Creates a JobIntance
      Specified by:
        `createJobInstance` in interface `PersistenceManagerService`
      Parameters:
        `name` - the job id from job.xml
        `jobXml` - the resolved job xml
      Returns:
        the job instance

    - #### createJobExecution

          public RuntimeJobExecution createJobExecution​(javax.batch.runtime.JobInstance jobInstance,
                                                        Properties jobParameters,
                                                        javax.batch.runtime.BatchStatus batchStatus)

      Description copied from interface: `PersistenceManagerService`
      Create a JobExecution
      Specified by:
        `createJobExecution` in interface `PersistenceManagerService`
      Parameters:
        `jobInstance` - the parent job instance
        `jobParameters` - the parent job instance parameters
        `batchStatus` - the current BatchStatus
      Returns:
        the RuntimeJobExecution class for this JobExecution

    - #### createFlowInSplitExecution

          public RuntimeFlowInSplitExecution createFlowInSplitExecution​(javax.batch.runtime.JobInstance jobInstance,
                                                                        javax.batch.runtime.BatchStatus batchStatus)

      Specified by:
        `createFlowInSplitExecution` in interface `PersistenceManagerService`

    - #### createStepExecution

          public StepExecutionImpl createStepExecution​(long rootJobExecId,
                                                       StepContextImpl stepContext)

      Description copied from interface: `PersistenceManagerService`
      Create a StepExecution
      Specified by:
        `createStepExecution` in interface `PersistenceManagerService`
      Parameters:
        `rootJobExecId` - the parent JobExecution id
        `stepContext` - the step context for this step execution
      Returns:
        the StepExecution

    - #### updateStepExecution

          public void updateStepExecution​(long rootJobExecId,
                                          StepContextImpl stepContext)

      Description copied from interface: `PersistenceManagerService`
      Update a StepExecution
      Specified by:
        `updateStepExecution` in interface `PersistenceManagerService`
      Parameters:
        `rootJobExecId` - the parent JobExecution id
        `stepContext` - the step context for this step execution

    - #### createJobStatus

          public JobStatus createJobStatus​(long jobInstanceId)

      Description copied from interface: `PersistenceManagerService`
      Create a JobStatus
      Specified by:
        `createJobStatus` in interface `PersistenceManagerService`
      Parameters:
        `jobInstanceId` - the parent job instance id
      Returns:
        the JobStatus

    - #### getJobStatus

          public JobStatus getJobStatus​(long instanceId)

      Description copied from interface: `PersistenceManagerService`
      Get a JobStatus
      Specified by:
        `getJobStatus` in interface `PersistenceManagerService`
      Parameters:
        `instanceId` - the parent job instance id
      Returns:
        the JobStatus

    - #### updateJobStatus

          public void updateJobStatus​(long instanceId,
                                      JobStatus jobStatus)

      Description copied from interface: `PersistenceManagerService`
      Update a JobStatus
      Specified by:
        `updateJobStatus` in interface `PersistenceManagerService`
      Parameters:
        `instanceId` - the parent job instance id
        `jobStatus` - the job status to be updated

    - #### createStepStatus

          public StepStatus createStepStatus​(long stepExecId)

      Description copied from interface: `PersistenceManagerService`
      Create a StepStatus
      Specified by:
        `createStepStatus` in interface `PersistenceManagerService`
      Parameters:
        `stepExecId` - the parent step execution id
      Returns:
        the StepStatus

    - #### getStepStatus

          public StepStatus getStepStatus​(long instanceId,
                                          String stepName)

      Description copied from interface: `PersistenceManagerService`
      Get a StepStatus

      The parent job instance id and this step name from the job xml are used to determine if the current step execution have previously run.

      Specified by:
        `getStepStatus` in interface `PersistenceManagerService`
      Parameters:
        `instanceId` - the parent job instance id
        `stepName` - the step name
      Returns:
        the StepStatus

    - #### updateStepStatus

          public void updateStepStatus​(long stepExecutionId,
                                       StepStatus stepStatus)

      Description copied from interface: `PersistenceManagerService`
      Update a StepStatus
      Specified by:
        `updateStepStatus` in interface `PersistenceManagerService`
      Parameters:
        `stepExecutionId` - the parent step execution id
        `stepStatus` - the step status to be updated

    - #### getMostRecentExecutionId

          public long getMostRecentExecutionId​(long jobInstanceId)

      Specified by:
        `getMostRecentExecutionId` in interface `PersistenceManagerService`

    - #### cleanUp

          public void cleanUp​(long instanceId)

      Specified by:
        `cleanUp` in interface `PersistenceManagerService`

    - #### cleanUp

          public void cleanUp​(Date until)

      Specified by:
        `cleanUp` in interface `PersistenceManagerService`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`