org.springframework.cloud.dataflow.server.service.impl

## Class DefaultTaskJobService

- java.lang.Object
- - org.springframework.cloud.dataflow.server.service.impl.DefaultTaskJobService

- All Implemented Interfaces:
    TaskJobService

      @Transactional
      public class DefaultTaskJobService
      extends Object
      implements TaskJobService

  Repository that retrieves Tasks and JobExecutions/Instances and the associations between them.
  Author:
    Glenn Renfro., Gunnar Hillert, Mark Fisher, Ilayaperumal Gopinathan

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultTaskJobService(JobService jobService, org.springframework.cloud.task.repository.TaskExplorer taskExplorer, TaskDefinitionRepository taskDefinitionRepository, TaskExecutionService taskExecutionService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countJobExecutions()` Retrieves the total number of the job executions.
    `int` | `countJobExecutionsForJob(String jobName, org.springframework.batch.core.BatchStatus status)` Retrieves the total number `JobExecution` that match a specific job name.
    `int` | `countJobInstances(String jobName)` Retrieves the total number of job instances for a job name.
    `TaskJobExecution` | `getJobExecution(long id)` Retrieves a JobExecution from the JobRepository and matches it with a task id.
    `JobInstanceExecutions` | `getJobInstance(long id)` Retrieves a `JobInstance` from the JobRepository and matches it with the associated `JobExecution`s.
    `List<TaskJobExecution>` | `listJobExecutions(org.springframework.data.domain.Pageable pageable)` Retrieves Pageable list of `JobExecution`s from the JobRepository and matches the data with a task id.
    `List<TaskJobExecution>` | `listJobExecutionsForJob(org.springframework.data.domain.Pageable pageable, String jobName, org.springframework.batch.core.BatchStatus status)` Retrieves Pageable list of `JobExecution` from the JobRepository with a specific jobName, status and matches the data with a task id.
    `List<TaskJobExecution>` | `listJobExecutionsForJobWithStepCount(org.springframework.data.domain.Pageable pageable, Date fromDate, Date toDate)` Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the date range.
    `List<TaskJobExecution>` | `listJobExecutionsForJobWithStepCount(org.springframework.data.domain.Pageable pageable, String jobName)` Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository with a specific jobName and matches the data with a task id.
    `List<TaskJobExecution>` | `listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(org.springframework.data.domain.Pageable pageable, int jobInstanceId)` Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the job instance id.
    `List<TaskJobExecution>` | `listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(org.springframework.data.domain.Pageable pageable, int taskExecutionId)` Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the task execution id.
    `List<TaskJobExecution>` | `listJobExecutionsWithStepCount(org.springframework.data.domain.Pageable pageable)` Retrieves Pageable list of `JobExecutionWithStepCount`s from the JobRepository and matches the data with a task id but excludes the step executions.
    `List<JobInstanceExecutions>` | `listTaskJobInstancesForJobName(org.springframework.data.domain.Pageable pageable, String jobName)` Retrieves Pageable list of `JobInstanceExecutions` from the JobRepository with a specific jobName and matches the data with the associated JobExecutions.
    `void` | `restartJobExecution(long jobExecutionId)` Restarts a `JobExecution` IF the respective `JobExecution` is actually deemed restartable.
    `void` | `stopJobExecution(long jobExecutionId)` Requests a `JobExecution` to stop.

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

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

- - ### Constructor Detail

    - #### DefaultTaskJobService

          public DefaultTaskJobService(JobService jobService,
                                       org.springframework.cloud.task.repository.TaskExplorer taskExplorer,
                                       TaskDefinitionRepository taskDefinitionRepository,
                                       TaskExecutionService taskExecutionService)

  - ### Method Detail

    - #### listJobExecutions

          public List<TaskJobExecution> listJobExecutions(org.springframework.data.domain.Pageable pageable)
                                                   throws org.springframework.batch.core.launch.NoSuchJobExecutionException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecution`s from the JobRepository and matches the data with a task id.
      Specified by:
        `listJobExecutions` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
      Returns:
        List containing `TaskJobExecution`s.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - in the event that a job execution id specified is not present when looking up stepExecutions for the result.

    - #### listJobExecutionsWithStepCount

          public List<TaskJobExecution> listJobExecutionsWithStepCount(org.springframework.data.domain.Pageable pageable)

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecutionWithStepCount`s from the JobRepository and matches the data with a task id but excludes the step executions.
      Specified by:
        `listJobExecutionsWithStepCount` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
      Returns:
        List containing `TaskJobExecution`s.

    - #### listJobExecutionsForJob

          public List<TaskJobExecution> listJobExecutionsForJob(org.springframework.data.domain.Pageable pageable,
                                                                String jobName,
                                                                org.springframework.batch.core.BatchStatus status)
                                                         throws org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecution` from the JobRepository with a specific jobName, status and matches the data with a task id.
      Specified by:
        `listJobExecutionsForJob` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `jobName` - the name of the job for which to findByTaskNameContains.
        `status` - the BatchStatus of the job execution.
      Returns:
        List containing `TaskJobExecution`s.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job with the given name does not exist.

    - #### listJobExecutionsForJobWithStepCount

          public List<TaskJobExecution> listJobExecutionsForJobWithStepCount(org.springframework.data.domain.Pageable pageable,
                                                                             Date fromDate,
                                                                             Date toDate)

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the date range.
      Specified by:
        `listJobExecutionsForJobWithStepCount` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `fromDate` - the date which start date must be greater than.
        `toDate` - the date which start date must be less than.
      Returns:
        List containing `JobExecutionWithStepCount`s.

    - #### listJobExecutionsForJobWithStepCountFilteredByJobInstanceId

          public List<TaskJobExecution> listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(org.springframework.data.domain.Pageable pageable,
                                                                                                    int jobInstanceId)
                                                                                             throws org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the job instance id.
      Specified by:
        `listJobExecutionsForJobWithStepCountFilteredByJobInstanceId` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `jobInstanceId` - the job instance id associated with the execution.
      Returns:
        List containing `JobExecutionWithStepCount`s.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job with the given name does not exist.

    - #### listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId

          public List<TaskJobExecution> listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(org.springframework.data.domain.Pageable pageable,
                                                                                                      int taskExecutionId)
                                                                                               throws org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository filtered by the task execution id.
      Specified by:
        `listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `taskExecutionId` - the task execution id associated with the execution.
      Returns:
        List containing `JobExecutionWithStepCount`s.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job with the given name does not exist.

    - #### listJobExecutionsForJobWithStepCount

          public List<TaskJobExecution> listJobExecutionsForJobWithStepCount(org.springframework.data.domain.Pageable pageable,
                                                                             String jobName)
                                                                      throws org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobExecutionWithStepCount` from the JobRepository with a specific jobName and matches the data with a task id.
      Specified by:
        `listJobExecutionsForJobWithStepCount` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `jobName` - the name of the job for which to findByTaskNameContains.
      Returns:
        List containing `JobExecutionWithStepCount`s.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job with the given name does not exist.

    - #### getJobExecution

          public TaskJobExecution getJobExecution(long id)
                                           throws org.springframework.batch.core.launch.NoSuchJobExecutionException

      Description copied from interface: `TaskJobService`
      Retrieves a JobExecution from the JobRepository and matches it with a task id.
      Specified by:
        `getJobExecution` in interface `TaskJobService`
      Parameters:
        `id` - the id of the `JobExecution`
      Returns:
        the `TaskJobExecution`s associated with the id.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - if the specified job execution for the id does not exist.

    - #### listTaskJobInstancesForJobName

          public List<JobInstanceExecutions> listTaskJobInstancesForJobName(org.springframework.data.domain.Pageable pageable,
                                                                            String jobName)
                                                                     throws org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves Pageable list of `JobInstanceExecutions` from the JobRepository with a specific jobName and matches the data with the associated JobExecutions.
      Specified by:
        `listTaskJobInstancesForJobName` in interface `TaskJobService`
      Parameters:
        `pageable` - enumerates the data to be returned.
        `jobName` - the name of the job for which to findByTaskNameContains.
      Returns:
        List containing `JobInstanceExecutions`.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job for the jobName specified does not exist.

    - #### getJobInstance

          public JobInstanceExecutions getJobInstance(long id)
                                               throws org.springframework.batch.core.launch.NoSuchJobInstanceException,
                                                      org.springframework.batch.core.launch.NoSuchJobException

      Description copied from interface: `TaskJobService`
      Retrieves a `JobInstance` from the JobRepository and matches it with the associated `JobExecution`s.
      Specified by:
        `getJobInstance` in interface `TaskJobService`
      Parameters:
        `id` - the id of the `JobInstance`
      Returns:
        the `JobInstanceExecutions` associated with the id.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobInstanceException` - if job instance id does not exist.
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job for the job instance does not exist.

    - #### countJobInstances

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

      Description copied from interface: `TaskJobService`
      Retrieves the total number of job instances for a job name.
      Specified by:
        `countJobInstances` in interface `TaskJobService`
      Parameters:
        `jobName` - the name of the job instance.
      Returns:
        the number of job instances associated with the jobName.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job for jobName specified does not exist.

    - #### countJobExecutions

          public int countJobExecutions()

      Description copied from interface: `TaskJobService`
      Retrieves the total number of the job executions.
      Specified by:
        `countJobExecutions` in interface `TaskJobService`
      Returns:
        the total number of job executions.

    - #### countJobExecutionsForJob

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

      Description copied from interface: `TaskJobService`
      Retrieves the total number `JobExecution` that match a specific job name.
      Specified by:
        `countJobExecutionsForJob` in interface `TaskJobService`
      Parameters:
        `jobName` - the job name to findByTaskNameContains.
        `status` - the status of the job execution
      Returns:
        the number of `JobExecution`s that match the job name.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobException` - if the job for the jobName does not exist.

    - #### restartJobExecution

          public void restartJobExecution(long jobExecutionId)
                                   throws org.springframework.batch.core.launch.NoSuchJobExecutionException

      Description copied from interface: `TaskJobService`
      Restarts a `JobExecution` IF the respective `JobExecution` is actually deemed restartable. Otherwise a `JobNotRestartableException` is being thrown.
      Specified by:
        `restartJobExecution` in interface `TaskJobService`
      Parameters:
        `jobExecutionId` - The id of the JobExecution to restart.
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - if the JobExecution for the provided id does not exist.

    - #### stopJobExecution

          public void stopJobExecution(long jobExecutionId)
                                throws org.springframework.batch.core.launch.NoSuchJobExecutionException,
                                       org.springframework.batch.core.launch.JobExecutionNotRunningException

      Description copied from interface: `TaskJobService`
      Requests a `JobExecution` to stop.

      Please remember, that calling this method only requests a job execution to stop processing. This method does not guarantee a `JobExecution` to stop. It is the responsibility of the implementor of the `Job` to react to that request. Furthermore, this method does not interfere with the associated `TaskExecution`.

      Specified by:
        `stopJobExecution` in interface `TaskJobService`
      Parameters:
        `jobExecutionId` - The id of the `JobExecution` to stop
      Throws:
        `org.springframework.batch.core.launch.NoSuchJobExecutionException` - thrown if no job execution exists for the jobExecutionId.
        `org.springframework.batch.core.launch.JobExecutionNotRunningException` - thrown if a stop is requested on a job that is not running.
      See Also:
        `JobService.stop(Long)`

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