org.springframework.cloud.dataflow.server.batch

## Interface JobService

- All Known Implementing Classes:
    SimpleJobService

      public interface JobService

  Interface for general purpose monitoring and management of Batch jobs. The features here can generally be composed from existing Spring Batch interfaces (although for performance reasons, implementations might choose special-purpose optimisations via a relation database, for instance).
  Author:
    Dave Syer, Glenn Renfro

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.springframework.batch.core.JobExecution` | `abandon(Long jobExecutionId)` Mark the `JobExecution` as ABANDONED.
    `int` | `countJobExecutions()` Count the maximum number of executions that could be returned by `listJobExecutions(int, int)`.
    `int` | `countJobExecutionsForJob(String jobName, org.springframework.batch.core.BatchStatus status)` Count the job executions in the repository for a job.
    `int` | `countJobInstances(String jobName)` Count the number of `job instances` in the repository for a given job name.
    `int` | `countJobs()` Count the total number of jobs that can be returned by `listJobs(int, int)`.
    `int` | `countStepExecutionsForJobExecution(long jobExecutionId)` Count the step executions in the repository for a given job execution.
    `int` | `countStepExecutionsForStep(String jobName, String stepName)` Count the step executions in the repository for a given step name (or pattern).
    `org.springframework.batch.core.JobExecution` | `getJobExecution(Long jobExecutionId)` Get a `JobExecution` by id.
    `Collection<org.springframework.batch.core.JobExecution>` | `getJobExecutionsForJobInstance(String jobName, Long jobInstanceId)` Get all the job executions for a given job instance.
    `org.springframework.batch.core.JobInstance` | `getJobInstance(long jobInstanceId)` Get a `job instance` by id.
    `org.springframework.batch.core.JobParameters` | `getLastJobParameters(String jobName)` Get the last `JobParameters` used to execute a job successfully.
    `org.springframework.batch.core.StepExecution` | `getStepExecution(Long jobExecutionId, Long stepExecutionId)` Locate a `StepExecution` from its id and that of its parent `JobExecution`.
    `Collection<org.springframework.batch.core.StepExecution>` | `getStepExecutions(Long jobExecutionId)` Get the `step executions` for a given job execution (by id).
    `Collection<String>` | `getStepNamesForJob(String jobName)` Get the names of the steps in a job (or a historical list of recent execution names if the Job is not launchable).
    `org.springframework.batch.core.JobExecution` | `launch(String jobName, org.springframework.batch.core.JobParameters params)` Launch a job with the parameters provided.
    `Collection<org.springframework.batch.core.JobExecution>` | `listJobExecutions(int start, int count)` List the `job executions` in descending order of creation (usually close to execution order).
    `Collection<org.springframework.batch.core.JobExecution>` | `listJobExecutionsForJob(String jobName, org.springframework.batch.core.BatchStatus status, int pageOffset, int pageSize)` List the `job executions` for a job in descending order of creation (usually close to execution order).
    `Collection<JobExecutionWithStepCount>` | `listJobExecutionsForJobWithStepCount(Date fromDate, Date toDate, int start, int count)` List the `job executions` filtered by date range in descending order of creation (usually close to execution order).
    `Collection<JobExecutionWithStepCount>` | `listJobExecutionsForJobWithStepCount(String jobName, int start, int count)` List the `job executions` for a job in descending order of creation (usually close to execution order).
    `Collection<JobExecutionWithStepCount>` | `listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(int jobInstanceId, int start, int count)` List the `job executions` filtered by job instance id in descending order of creation (usually close to execution order).
    `Collection<JobExecutionWithStepCount>` | `listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(int taskExecutionId, int start, int count)` List the `job executions` filtered by task execution id in descending order of creation (usually close to execution order).
    `Collection<JobExecutionWithStepCount>` | `listJobExecutionsWithStepCount(int start, int count)` List the `JobExecutions` in descending order of creation (usually close to execution order) without step execution data.
    `Collection<org.springframework.batch.core.JobInstance>` | `listJobInstances(String jobName, int start, int count)` List the `job instances` in descending order of creation (usually close to order of execution).
    `Collection<String>` | `listJobs(int start, int count)` Query the job names in the system, either launchable or not.
    `Collection<org.springframework.batch.core.StepExecution>` | `listStepExecutionsForStep(String jobName, String stepName, int start, int count)` List the `step executions` for a step in descending order of creation (usually close to execution order).
    `org.springframework.batch.core.JobExecution` | `restart(Long jobExecutionId)` Launch a job with the parameters provided.
    `org.springframework.batch.core.JobExecution` | `restart(Long jobExecutionId, org.springframework.batch.core.JobParameters params)` Launch a job with the parameters provided.
    `org.springframework.batch.core.JobExecution` | `stop(Long jobExecutionId)` Send a signal to a job execution to stop processing.
    `int` | `stopAll()` Send a stop signal to all running job executions.

- - ### Method Detail

    - #### launch

          org.springframework.batch.core.JobExecution launch(String jobName,
                                                             org.springframework.batch.core.JobParameters params)
                                                      throws org.springframework.batch.core.launch.NoSuchJobException,
                                                             org.springframework.batch.core.repository.JobExecutionAlreadyRunningException,
                                                             org.springframework.batch.core.repository.JobRestartException,
                                                             org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException,
                                                             org.springframework.batch.core.JobParametersInvalidException

      Launch a job with the parameters provided. If an instance with the parameters provided has already failed (and is not abandoned) it will be restarted.
      Parameters:
        `jobName` - the job name
        `params` - the `JobParameters`
      Returns:
        the resulting `JobExecution` if successful
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist
        `org.springframework.batch.core.repository.JobExecutionAlreadyRunningException` - thrown if job is already executing
        `org.springframework.batch.core.repository.JobRestartException` - thrown if job failed to restart
        `org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException` - thrown if job was already complete
        `org.springframework.batch.core.JobParametersInvalidException` - thrown if job parameters are invalid

    - #### getLastJobParameters

          org.springframework.batch.core.JobParameters getLastJobParameters(String jobName)
                                                                     throws org.springframework.batch.core.launch.NoSuchJobException

      Get the last `JobParameters` used to execute a job successfully.
      Parameters:
        `jobName` - the name of the job
      Returns:
        the last parameters used to execute this job or empty if there are none
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### restart

          org.springframework.batch.core.JobExecution restart(Long jobExecutionId)
                                                       throws org.springframework.batch.core.launch.NoSuchJobExecutionException,
                                                              org.springframework.batch.core.repository.JobExecutionAlreadyRunningException,
                                                              org.springframework.batch.core.repository.JobRestartException,
                                                              org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException,
                                                              org.springframework.batch.core.launch.NoSuchJobException,
                                                              org.springframework.batch.core.JobParametersInvalidException

      Launch a job with the parameters provided.
      Parameters:
        `jobExecutionId` - the job execution to restart
      Returns:
        the resulting `JobExecution` if successful
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist
        `org.springframework.batch.core.repository.JobExecutionAlreadyRunningException` - thrown if job is already executing
        `org.springframework.batch.core.repository.JobRestartException` - thrown if job failed to restart
        `org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException` - thrown if job was already complete
        `org.springframework.batch.core.JobParametersInvalidException` - thrown if job parameters are invalid

    - #### restart

          org.springframework.batch.core.JobExecution restart(Long jobExecutionId,
                                                              org.springframework.batch.core.JobParameters params)
                                                       throws org.springframework.batch.core.launch.NoSuchJobExecutionException,
                                                              org.springframework.batch.core.repository.JobExecutionAlreadyRunningException,
                                                              org.springframework.batch.core.repository.JobRestartException,
                                                              org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException,
                                                              org.springframework.batch.core.launch.NoSuchJobException,
                                                              org.springframework.batch.core.JobParametersInvalidException

      Launch a job with the parameters provided. JSR-352 supports restarting of jobs with a new set of parameters. This method exposes this functionality
      Parameters:
        `jobExecutionId` - the job execution to restart
        `params` - the job parameters to use in the restart
      Returns:
        the resulting `JobExecution` if successful
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist
        `org.springframework.batch.core.repository.JobExecutionAlreadyRunningException` - thrown if job is already executing
        `org.springframework.batch.core.repository.JobRestartException` - thrown if job failed to restart
        `org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException` - thrown if job was already complete
        `org.springframework.batch.core.JobParametersInvalidException` - thrown if job parameters are invalid

    - #### stop

          org.springframework.batch.core.JobExecution stop(Long jobExecutionId)
                                                    throws org.springframework.batch.core.launch.NoSuchJobExecutionException,
                                                           org.springframework.batch.core.launch.JobExecutionNotRunningException

      Send a signal to a job execution to stop processing. This method does not guarantee that the processing will stop, only that the signal will be delivered. It is up to the individual `Job` and `Step` implementations to ensure that the signal is obeyed. In particular, if users provide a custom `Tasklet` to a `Step` it must check the signal in the `JobExecution` itself.
      Parameters:
        `jobExecutionId` - the job execution id to stop
      Returns:
        the `JobExecution` that was stopped
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist
        `org.springframework.batch.core.launch.JobExecutionNotRunningException` - thrown if the job execution specified is not running

    - #### abandon

          org.springframework.batch.core.JobExecution abandon(Long jobExecutionId)
                                                       throws org.springframework.batch.core.launch.NoSuchJobExecutionException,
                                                              org.springframework.batch.core.repository.JobExecutionAlreadyRunningException

      Mark the `JobExecution` as ABANDONED. If a stop signal is ignored because the process died this is the best way to mark a job as finished with (as opposed to STOPPED). An abandoned job execution can be restarted, but a stopping one cannot.
      Parameters:
        `jobExecutionId` - the job execution id to abort
      Returns:
        the `JobExecution` that was aborted
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist
        `org.springframework.batch.core.repository.JobExecutionAlreadyRunningException` - thrown if the job is running (it should be stopped first)

    - #### listJobs

          Collection<String> listJobs(int start,
                                      int count)

      Query the job names in the system, either launchable or not. If not launchable, then there must be a history of the job having been launched previously in the `JobRepository`.
      Parameters:
        `start` - the start index of the job names to return
        `count` - the maximum number of job names to return
      Returns:
        a collection of job names

    - #### countJobs

          int countJobs()

      Count the total number of jobs that can be returned by `listJobs(int, int)`.
      Returns:
        the total number of jobs

    - #### getJobInstance

          org.springframework.batch.core.JobInstance getJobInstance(long jobInstanceId)
                                                             throws org.springframework.batch.core.launch.NoSuchJobInstanceException

      Get a `job instance` by id.
      Parameters:
        `jobInstanceId` - the id of the instance
      Returns:
        a `job instance`
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobInstanceException` - thrown if the job instance specified does not exist

    - #### listJobInstances

          Collection<org.springframework.batch.core.JobInstance> listJobInstances(String jobName,
                                                                                  int start,
                                                                                  int count)
                                                                           throws org.springframework.batch.core.launch.NoSuchJobException

      List the `job instances` in descending order of creation (usually close to order of execution).
      Parameters:
        `jobName` - the name of the job
        `start` - the index of the first to return
        `count` - the maximum number of instances to return
      Returns:
        a collection of `job instances`
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### countJobInstances

          int countJobInstances(String jobName)
                         throws org.springframework.batch.core.launch.NoSuchJobException

      Count the number of `job instances` in the repository for a given job name.
      Parameters:
        `jobName` - the name of the job
      Returns:
        the number of job instances available
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### listJobExecutionsForJobWithStepCount

          Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCount(String jobName,
                                                                                     int start,
                                                                                     int count)
                                                                              throws org.springframework.batch.core.launch.NoSuchJobException

      List the `job executions` for a job in descending order of creation (usually close to execution order).
      Parameters:
        `jobName` - the job name
        `start` - the start index of the first job execution
        `count` - the maximum number of executions to return
      Returns:
        a collection of `JobExecutionWithStepCount`
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### countJobExecutionsForJob

          int countJobExecutionsForJob(String jobName,
                                       org.springframework.batch.core.BatchStatus status)
                                throws org.springframework.batch.core.launch.NoSuchJobException

      Count the job executions in the repository for a job.
      Parameters:
        `jobName` - the job name
        `status` - the status of the job
      Returns:
        the number of executions
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### getJobExecutionsForJobInstance

          Collection<org.springframework.batch.core.JobExecution> getJobExecutionsForJobInstance(String jobName,
                                                                                                 Long jobInstanceId)
                                                                                          throws org.springframework.batch.core.launch.NoSuchJobException

      Get all the job executions for a given job instance. On a sunny day there would be only one. If there have been failures and restarts there may be many, and they will be listed in reverse order of primary key.
      Parameters:
        `jobName` - the name of the job
        `jobInstanceId` - the id of the job instance
      Returns:
        all the job executions
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### listJobExecutions

          Collection<org.springframework.batch.core.JobExecution> listJobExecutions(int start,
                                                                                    int count)

      List the `job executions` in descending order of creation (usually close to execution order).
      Parameters:
        `start` - the index of the first execution to return
        `count` - the maximum number of executions
      Returns:
        a collection of `JobExecution`

    - #### listJobExecutionsWithStepCount

          Collection<JobExecutionWithStepCount> listJobExecutionsWithStepCount(int start,
                                                                               int count)

      List the `JobExecutions` in descending order of creation (usually close to execution order) without step execution data.
      Parameters:
        `start` - the index of the first execution to return
        `count` - the maximum number of executions
      Returns:
        a collection of `JobExecutionWithStepCount`

    - #### countJobExecutions

          int countJobExecutions()

      Count the maximum number of executions that could be returned by `listJobExecutions(int, int)`.
      Returns:
        the number of job executions in the job repository

    - #### getJobExecution

          org.springframework.batch.core.JobExecution getJobExecution(Long jobExecutionId)
                                                               throws org.springframework.batch.core.launch.NoSuchJobExecutionException

      Get a `JobExecution` by id.
      Parameters:
        `jobExecutionId` - the job execution id
      Returns:
        the `JobExecution`
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist

    - #### getStepExecutions

          Collection<org.springframework.batch.core.StepExecution> getStepExecutions(Long jobExecutionId)
                                                                              throws org.springframework.batch.core.launch.NoSuchJobExecutionException

      Get the `step executions` for a given job execution (by id).
      Parameters:
        `jobExecutionId` - the parent job execution id
      Returns:
        the step executions for the job execution
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist

    - #### listStepExecutionsForStep

          Collection<org.springframework.batch.core.StepExecution> listStepExecutionsForStep(String jobName,
                                                                                             String stepName,
                                                                                             int start,
                                                                                             int count)
                                                                                      throws org.springframework.batch.core.step.NoSuchStepException

      List the `step executions` for a step in descending order of creation (usually close to execution order).
      Parameters:
        `jobName` - the name of the job associated with the step (or a pattern with wildcards)
        `stepName` - the step name (or a pattern with wildcards)
        `start` - the start index of the first execution
        `count` - the maximum number of executions to return
      Returns:
        a collection of `StepExecution`
      Throws:
        `org.springframework.batch.core.step.NoSuchStepException` - thrown if step specified does not exist

    - #### countStepExecutionsForStep

          int countStepExecutionsForStep(String jobName,
                                         String stepName)
                                  throws org.springframework.batch.core.step.NoSuchStepException

      Count the step executions in the repository for a given step name (or pattern).
      Parameters:
        `jobName` - the job name (or a pattern with wildcards)
        `stepName` - the step name (or a pattern with wildcards)
      Returns:
        the number of executions
      Throws:
        `org.springframework.batch.core.step.NoSuchStepException` - thrown if step specified does not exist

    - #### countStepExecutionsForJobExecution

          int countStepExecutionsForJobExecution(long jobExecutionId)

      Count the step executions in the repository for a given job execution.
      Parameters:
        `jobExecutionId` - the id of the job execution.
      Returns:
        the number of executions.

    - #### getStepExecution

          org.springframework.batch.core.StepExecution getStepExecution(Long jobExecutionId,
                                                                        Long stepExecutionId)
                                                                 throws NoSuchStepExecutionException,
                                                                        org.springframework.batch.core.launch.NoSuchJobExecutionException

      Locate a `StepExecution` from its id and that of its parent `JobExecution`.
      Parameters:
        `jobExecutionId` - the job execution id
        `stepExecutionId` - the step execution id
      Returns:
        the `StepExecution`
      Throws:
        `NoSuchStepExecutionException` - thrown if the step execution specified does not exist
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if job execution specified does not exist

    - #### stopAll

          int stopAll()

      Send a stop signal to all running job executions.
      Returns:
        the number of executions affected

    - #### getStepNamesForJob

          Collection<String> getStepNamesForJob(String jobName)
                                         throws org.springframework.batch.core.launch.NoSuchJobException

      Get the names of the steps in a job (or a historical list of recent execution names if the Job is not launchable).
      Parameters:
        `jobName` - the name of the job
      Returns:
        `Collection` of step names.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if the job name cannot be located

    - #### listJobExecutionsForJob

          Collection<org.springframework.batch.core.JobExecution> listJobExecutionsForJob(String jobName,
                                                                                          org.springframework.batch.core.BatchStatus status,
                                                                                          int pageOffset,
                                                                                          int pageSize)
                                                                                   throws org.springframework.batch.core.launch.NoSuchJobException

      List the `job executions` for a job in descending order of creation (usually close to execution order).
      Parameters:
        `jobName` - the job name
        `status` - the status of the job execution
        `pageOffset` - the start index of the first job execution
        `pageSize` - the maximum number of executions to return
      Returns:
        a collection of `JobExecution`
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - thrown if job specified does not exist

    - #### listJobExecutionsForJobWithStepCount

          Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCount(Date fromDate,
                                                                                     Date toDate,
                                                                                     int start,
                                                                                     int count)

      List the `job executions` filtered by date range in descending order of creation (usually close to execution order).
      Parameters:
        `fromDate` - the date which start date must be greater than.
        `toDate` - the date which start date must be less than.
        `start` - the start index of the first job execution
        `count` - the maximum number of executions to return
      Returns:
        a collection of `JobExecutionWithStepCount`

    - #### listJobExecutionsForJobWithStepCountFilteredByJobInstanceId

          Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(int jobInstanceId,
                                                                                                            int start,
                                                                                                            int count)

      List the `job executions` filtered by job instance id in descending order of creation (usually close to execution order).
      Parameters:
        `jobInstanceId` - the job instance id associated with the execution.
        `start` - the start index of the first job execution
        `count` - the maximum number of executions to return
      Returns:
        a collection of `JobExecutionWithStepCount`

    - #### listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId

          Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(int taskExecutionId,
                                                                                                              int start,
                                                                                                              int count)

      List the `job executions` filtered by task execution id in descending order of creation (usually close to execution order).
      Parameters:
        `taskExecutionId` - the task execution id associated with the execution.
        `start` - the start index of the first job execution
        `count` - the maximum number of executions to return
      Returns:
        a collection of `JobExecutionWithStepCount`

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.