Class SimpleJobService
java.lang.Object
org.springframework.cloud.dataflow.server.batch.SimpleJobService
- All Implemented Interfaces:
JobService
Implementation of
JobService
that delegates most of its work to other
off-the-shelf components.- Author:
- Dave Syer, Michael Minella, Glenn Renfro, Corneil du Plessis
-
Constructor Summary
ConstructorDescriptionSimpleJobService
(SearchableJobInstanceDao jobInstanceDao, SearchableJobExecutionDao jobExecutionDao, SearchableStepExecutionDao stepExecutionDao, org.springframework.batch.core.repository.JobRepository jobRepository, org.springframework.batch.core.repository.dao.ExecutionContextDao executionContextDao, org.springframework.batch.core.launch.JobOperator jobOperator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStepExecutions
(org.springframework.batch.core.JobExecution jobExecution) int
Count the maximum number of executions that could be returned byJobService.listJobExecutions(int, int)
.int
countJobExecutionsForJob
(String name, 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> taskExecutionIds) 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 name, 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.void
setShutdownTimeout
(int shutdownTimeout) Timeout for shutdown waiting for jobs to finish processing.org.springframework.batch.core.JobExecution
Send a signal to a job execution to stop processing.
-
Constructor Details
-
SimpleJobService
public SimpleJobService(SearchableJobInstanceDao jobInstanceDao, SearchableJobExecutionDao jobExecutionDao, SearchableStepExecutionDao stepExecutionDao, org.springframework.batch.core.repository.JobRepository jobRepository, org.springframework.batch.core.repository.dao.ExecutionContextDao executionContextDao, org.springframework.batch.core.launch.JobOperator jobOperator)
-
-
Method Details
-
setShutdownTimeout
public void setShutdownTimeout(int shutdownTimeout) Timeout for shutdown waiting for jobs to finish processing.- Parameters:
shutdownTimeout
- in milliseconds (default 60 secs)
-
getStepExecutions
public Collection<org.springframework.batch.core.StepExecution> getStepExecutions(Long jobExecutionId) throws org.springframework.batch.core.launch.NoSuchJobExecutionException Description copied from interface:JobService
Get thestep executions
for a given job execution (by id).- Specified by:
getStepExecutions
in interfaceJobService
- 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
public Collection<org.springframework.batch.core.StepExecution> getStepExecutions(org.springframework.batch.core.JobExecution jobExecution) - Specified by:
getStepExecutions
in interfaceJobService
-
addStepExecutions
public void addStepExecutions(org.springframework.batch.core.JobExecution jobExecution) - Specified by:
addStepExecutions
in interfaceJobService
-
restart
public org.springframework.batch.core.JobExecution restart(Long jobExecutionId, org.springframework.batch.core.JobParameters params) throws org.springframework.batch.core.launch.NoSuchJobException Description copied from interface:JobService
Launch a job with the parameters provided. JSR-352 supports restarting of jobs with a new set of parameters. This method exposes this functionality- Specified by:
restart
in interfaceJobService
- 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.NoSuchJobException
- thrown if job specified does not exist
-
listJobExecutions
public Collection<org.springframework.batch.core.JobExecution> listJobExecutions(int start, int count) Description copied from interface:JobService
List thejob executions
in descending order of creation (usually close to execution order).- Specified by:
listJobExecutions
in interfaceJobService
- Parameters:
start
- the index of the first execution to returncount
- the maximum number of executions- Returns:
- a collection of
JobExecution
-
listJobExecutionsWithStepCount
Description copied from interface:JobService
List theJobExecutions
in descending order of creation (usually close to execution order) without step execution data.- Specified by:
listJobExecutionsWithStepCount
in interfaceJobService
- Parameters:
start
- the index of the first execution to returncount
- the maximum number of executions- Returns:
- a collection of
JobExecutionWithStepCount
-
countJobExecutions
public int countJobExecutions()Description copied from interface:JobService
Count the maximum number of executions that could be returned byJobService.listJobExecutions(int, int)
.- Specified by:
countJobExecutions
in interfaceJobService
- Returns:
- the number of job executions in the job repository
-
stop
public org.springframework.batch.core.JobExecution stop(Long jobExecutionId) throws org.springframework.batch.core.launch.NoSuchJobExecutionException, org.springframework.batch.core.launch.JobExecutionNotRunningException Description copied from interface:JobService
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.- Specified by:
stop
in interfaceJobService
- 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
-
countJobExecutionsForJob
public int countJobExecutionsForJob(String name, org.springframework.batch.core.BatchStatus status) throws org.springframework.batch.core.launch.NoSuchJobException Description copied from interface:JobService
Count the job executions in the repository for a job.- Specified by:
countJobExecutionsForJob
in interfaceJobService
- Parameters:
name
- 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
-
getJobExecution
public org.springframework.batch.core.JobExecution getJobExecution(Long jobExecutionId) throws org.springframework.batch.core.launch.NoSuchJobExecutionException Description copied from interface:JobService
Get aJobExecution
by id.- Specified by:
getJobExecution
in interfaceJobService
- Parameters:
jobExecutionId
- the job execution id- Returns:
- the
JobExecution
- Throws:
org.springframework.batch.core.launch.NoSuchJobExecutionException
- thrown if job execution specified does not exist
-
getJobExecutionsForJobInstance
public Collection<org.springframework.batch.core.JobExecution> getJobExecutionsForJobInstance(String name, Long jobInstanceId) throws org.springframework.batch.core.launch.NoSuchJobException Description copied from interface:JobService
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.- Specified by:
getJobExecutionsForJobInstance
in interfaceJobService
- Parameters:
name
- 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
-
getStepExecution
public org.springframework.batch.core.StepExecution getStepExecution(Long jobExecutionId, Long stepExecutionId) throws org.springframework.batch.core.launch.NoSuchJobExecutionException, NoSuchStepExecutionException Description copied from interface:JobService
Locate aStepExecution
from its id and that of its parentJobExecution
.- Specified by:
getStepExecution
in interfaceJobService
- Parameters:
jobExecutionId
- the job execution idstepExecutionId
- the step execution id- Returns:
- the
StepExecution
- Throws:
org.springframework.batch.core.launch.NoSuchJobExecutionException
- thrown if job execution specified does not existNoSuchStepExecutionException
- thrown if the step execution specified does not exist
-
getStepExecution
public org.springframework.batch.core.StepExecution getStepExecution(org.springframework.batch.core.JobExecution jobExecution, Long stepExecutionId) throws NoSuchStepExecutionException - Specified by:
getStepExecution
in interfaceJobService
- Throws:
NoSuchStepExecutionException
-
listJobExecutionsForJobWithStepCount
public Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCount(String jobName, int start, int count) throws org.springframework.batch.core.launch.NoSuchJobException Description copied from interface:JobService
List thejob executions
for a job in descending order of creation (usually close to execution order).- Specified by:
listJobExecutionsForJobWithStepCount
in interfaceJobService
- 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
-
listStepExecutionsForStep
public Collection<org.springframework.batch.core.StepExecution> listStepExecutionsForStep(String jobName, String stepName, int start, int count) throws org.springframework.batch.core.step.NoSuchStepException Description copied from interface:JobService
List thestep executions
for a step in descending order of creation (usually close to execution order).- Specified by:
listStepExecutionsForStep
in interfaceJobService
- 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
public int countStepExecutionsForStep(String jobName, String stepName) throws org.springframework.batch.core.step.NoSuchStepException Description copied from interface:JobService
Count the step executions in the repository for a given step name (or pattern).- Specified by:
countStepExecutionsForStep
in interfaceJobService
- 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
-
getJobInstance
public org.springframework.batch.core.JobInstance getJobInstance(long jobInstanceId) throws org.springframework.batch.core.launch.NoSuchJobInstanceException Description copied from interface:JobService
Get ajob instance
by id.- Specified by:
getJobInstance
in interfaceJobService
- 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
public Collection<org.springframework.batch.core.JobInstance> listJobInstances(String jobName, int start, int count) throws org.springframework.batch.core.launch.NoSuchJobException Description copied from interface:JobService
List thejob instances
in descending order of creation (usually close to order of execution).- Specified by:
listJobInstances
in interfaceJobService
- 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
-
listJobExecutionsForJob
public Collection<org.springframework.batch.core.JobExecution> listJobExecutionsForJob(String jobName, org.springframework.batch.core.BatchStatus status, int pageOffset, int pageSize) Description copied from interface:JobService
List thejob executions
for a job in descending order of creation (usually close to execution order).- Specified by:
listJobExecutionsForJob
in interfaceJobService
- 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
-
listJobExecutionsForJobWithStepCount
public Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCount(Date fromDate, Date toDate, int start, int count) Description copied from interface:JobService
List thejob executions
filtered by date range in descending order of creation (usually close to execution order).- Specified by:
listJobExecutionsForJobWithStepCount
in interfaceJobService
- 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
public Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByJobInstanceId(int jobInstanceId, int start, int count) Description copied from interface:JobService
List thejob executions
filtered by job instance id in descending order of creation (usually close to execution order).- Specified by:
listJobExecutionsForJobWithStepCountFilteredByJobInstanceId
in interfaceJobService
- 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
public Collection<JobExecutionWithStepCount> listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId(int taskExecutionId, int start, int count) Description copied from interface:JobService
List thejob executions
filtered by task execution id in descending order of creation (usually close to execution order).- Specified by:
listJobExecutionsForJobWithStepCountFilteredByTaskExecutionId
in interfaceJobService
- 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
Description copied from interface:JobService
Returns a collection job execution ids given a collection of task execution ids that is mapped by id.- Specified by:
getJobExecutionIdsByTaskExecutionIds
in interfaceJobService
- Parameters:
taskExecutionIds
- 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.
-