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, Corneil du Plessis
  • Method Details

    • 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
    • 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
    • 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
    • getStepExecutions

      Collection<org.springframework.batch.core.StepExecution> getStepExecutions(org.springframework.batch.core.JobExecution jobExecution) throws org.springframework.batch.core.launch.NoSuchJobExecutionException
      Throws:
      org.springframework.batch.core.launch.NoSuchJobExecutionException
    • addStepExecutions

      void addStepExecutions(org.springframework.batch.core.JobExecution jobExecution)
    • 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
    • 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
    • getStepExecution

      org.springframework.batch.core.StepExecution getStepExecution(org.springframework.batch.core.JobExecution jobExecution, Long stepExecutionId) throws NoSuchStepExecutionException
      Throws:
      NoSuchStepExecutionException
    • 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
    • getJobExecutionIdsByTaskExecutionIds

      Map<Long,Set<Long>> getJobExecutionIdsByTaskExecutionIds(Collection<Long> taskExecutionId)
      Returns a collection job execution ids given a collection of task execution ids that is mapped by id.
      Parameters:
      taskExecutionId - Collection of task execution ids that requestor to search for associated Job Ids.
      Returns:
      Map with the task execution id as the key and the set of job execution ids as values.