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 Summary
Modifier and TypeMethodDescriptionvoid
addStepExecutions
(org.springframework.batch.core.JobExecution jobExecution) int
Count the maximum number of executions that could be returned bylistJobExecutions(int, int)
.int
countJobExecutionsForJob
(String jobName, org.springframework.batch.core.BatchStatus status) Count the job executions in the repository for a job.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 aJobExecution
by id.getJobExecutionIdsByTaskExecutionIds
(Collection<Long> taskExecutionId) Returns a collection job execution ids given a collection of task execution ids that is mapped 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 ajob instance
by id.org.springframework.batch.core.StepExecution
getStepExecution
(Long jobExecutionId, Long stepExecutionId) Locate aStepExecution
from its id and that of its parentJobExecution
.org.springframework.batch.core.StepExecution
getStepExecution
(org.springframework.batch.core.JobExecution jobExecution, Long stepExecutionId) Collection<org.springframework.batch.core.StepExecution>
getStepExecutions
(Long jobExecutionId) Get thestep executions
for a given job execution (by id).Collection<org.springframework.batch.core.StepExecution>
getStepExecutions
(org.springframework.batch.core.JobExecution jobExecution) Collection<org.springframework.batch.core.JobExecution>
listJobExecutions
(int start, int count) List thejob 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 thejob executions
for a job in descending order of creation (usually close to execution order).listJobExecutionsForJobWithStepCount
(String jobName, int start, int count) List thejob executions
for a job in descending order of creation (usually close to execution order).listJobExecutionsForJobWithStepCount
(Date fromDate, Date toDate, int start, int count) List thejob executions
filtered by date range in descending order of creation (usually close to execution order).listJobExecutionsForJobWithStepCountFilteredByJobInstanceId
(int jobInstanceId, int start, int count) List thejob executions
filtered by job instance id in descending order of creation (usually close to execution order).listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId
(int taskExecutionId, int start, int count) List thejob executions
filtered by task execution id in descending order of creation (usually close to execution order).listJobExecutionsWithStepCount
(int start, int count) List theJobExecutions
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 thejob instances
in descending order of creation (usually close to order of execution).Collection<org.springframework.batch.core.StepExecution>
listStepExecutionsForStep
(String jobName, String stepName, int start, int count) List thestep executions
for a step in descending order of creation (usually close to execution order).org.springframework.batch.core.JobExecution
Launch a job with the parameters provided.org.springframework.batch.core.JobExecution
Send a signal to a job execution to stop processing.
-
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 restartparams
- 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 existorg.springframework.batch.core.launch.NoSuchJobException
- thrown if job specified does not existorg.springframework.batch.core.repository.JobExecutionAlreadyRunningException
- thrown if job is already executingorg.springframework.batch.core.repository.JobRestartException
- thrown if job failed to restartorg.springframework.batch.core.repository.JobInstanceAlreadyCompleteException
- thrown if job was already completeorg.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 individualJob
andStep
implementations to ensure that the signal is obeyed. In particular, if users provide a customTasklet
to aStep
it must check the signal in theJobExecution
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 existorg.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 ajob 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 thejob instances
in descending order of creation (usually close to order of execution).- Parameters:
jobName
- the name of the jobstart
- the index of the first to returncount
- 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 thejob executions
for a job in descending order of creation (usually close to execution order).- Parameters:
jobName
- the job namestart
- the start index of the first job executioncount
- 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 namestatus
- 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 jobjobInstanceId
- 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
List thejob executions
in descending order of creation (usually close to execution order).- Parameters:
start
- the index of the first execution to returncount
- the maximum number of executions- Returns:
- a collection of
JobExecution
-
listJobExecutionsWithStepCount
List theJobExecutions
in descending order of creation (usually close to execution order) without step execution data.- Parameters:
start
- the index of the first execution to returncount
- the maximum number of executions- Returns:
- a collection of
JobExecutionWithStepCount
-
countJobExecutions
int countJobExecutions()Count the maximum number of executions that could be returned bylistJobExecutions(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 aJobExecution
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 thestep 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 thestep 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 executioncount
- 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 aStepExecution
from its id and that of its parentJobExecution
.- Parameters:
jobExecutionId
- the job execution idstepExecutionId
- the step execution id- Returns:
- the
StepExecution
- Throws:
NoSuchStepExecutionException
- thrown if the step execution specified does not existorg.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 thejob executions
for a job in descending order of creation (usually close to execution order).- Parameters:
jobName
- the job namestatus
- the status of the job executionpageOffset
- the start index of the first job executionpageSize
- 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 thejob 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 executioncount
- the maximum number of executions to return- Returns:
- a collection of
JobExecutionWithStepCount
-
listJobExecutionsForJobWithStepCountFilteredByJobInstanceId
Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(int jobInstanceId, int start, int count) List thejob 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 executioncount
- the maximum number of executions to return- Returns:
- a collection of
JobExecutionWithStepCount
-
listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId
Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(int taskExecutionId, int start, int count) List thejob 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 executioncount
- the maximum number of executions to return- Returns:
- a collection of
JobExecutionWithStepCount
-
getJobExecutionIdsByTaskExecutionIds
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.
-