Interface JobRepository
- All Known Implementing Classes:
SimpleJobRepository
Repository responsible for persistence of batch meta-data entities.
- Author:
- Lucas Ward, Dave Syer, Robert Kasanicky, David Turanski, Michael Minella, Mahmoud Ben Hassine
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(StepExecution stepExecution) Save theStepExecution
and itsExecutionContext
.void
addAll
(Collection<StepExecution> stepExecutions) Save a collection ofStepExecution
s and eachExecutionContext
.createJobExecution
(String jobName, JobParameters jobParameters) createJobInstance
(String jobName, JobParameters jobParameters) Create a newJobInstance
with the name and job parameters provided.getLastJobExecution
(String jobName, JobParameters jobParameters) getLastStepExecution
(JobInstance jobInstance, String stepName) int
getStepExecutionCount
(JobInstance jobInstance, String stepName) boolean
isJobInstanceExists
(String jobName, JobParameters jobParameters) Check if an instance of this job already exists with the parameters provided.void
update
(JobExecution jobExecution) Update theJobExecution
(but not itsExecutionContext
).void
update
(StepExecution stepExecution) Update theStepExecution
(but not itsExecutionContext
).void
updateExecutionContext
(JobExecution jobExecution) Persist the updatedExecutionContext
of the givenJobExecution
.void
updateExecutionContext
(StepExecution stepExecution) Persist the updatedExecutionContext
s of the givenStepExecution
.
-
Method Details
-
isJobInstanceExists
Check if an instance of this job already exists with the parameters provided.- Parameters:
jobName
- the name of the jobjobParameters
- the parameters to match- Returns:
- true if a
JobInstance
already exists for this job name and job parameters
-
createJobInstance
Create a newJobInstance
with the name and job parameters provided.- Parameters:
jobName
- logical name of the jobjobParameters
- parameters used to execute the job- Returns:
- the new
JobInstance
-
createJobExecution
JobExecution createJobExecution(String jobName, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException Create a
JobExecution
for a givenJob
andJobParameters
. If matchingJobInstance
already exists, the job must be restartable and it's last JobExecution must *not* be completed. If matchingJobInstance
does not exist yet it will be created.If this method is run in a transaction (as it normally would be) with isolation level at
Isolation.REPEATABLE_READ
or better, then this method should block if another transaction is already executing it (for the sameJobParameters
and job name). The first transaction to complete in this scenario obtains a validJobExecution
, and others throwJobExecutionAlreadyRunningException
(or timeout). There are no such guarantees if theJobInstanceDao
andJobExecutionDao
do not respect the transaction isolation levels (e.g. if using a non-relational data-store, or if the platform does not support the higher isolation levels).- Parameters:
jobName
- the name of the job that is to be executedjobParameters
- the runtime parameters for the job- Returns:
- a valid
JobExecution
for the arguments provided - Throws:
JobExecutionAlreadyRunningException
- if there is aJobExecution
already running for the job instance with the provided job and parameters.JobRestartException
- if one or more existingJobInstance
s is found with the same parameters andJob.isRestartable()
is false.JobInstanceAlreadyCompleteException
- if aJobInstance
is found and was already completed successfully.
-
update
Update theJobExecution
(but not itsExecutionContext
). Preconditions:JobExecution
must contain a validJobInstance
and be saved (have an id assigned).- Parameters:
jobExecution
-JobExecution
instance to be updated in the repo.
-
add
Save theStepExecution
and itsExecutionContext
. ID will be assigned - it is not permitted that an ID be assigned before calling this method. Instead, it should be left blank, to be assigned by aJobRepository
. Preconditions:StepExecution
must have a validStep
.- Parameters:
stepExecution
-StepExecution
instance to be added to the repo.
-
addAll
Save a collection ofStepExecution
s and eachExecutionContext
. The StepExecution ID will be assigned - it is not permitted that an ID be assigned before calling this method. Instead, it should be left blank, to be assigned byJobRepository
. Preconditions:StepExecution
must have a validStep
.- Parameters:
stepExecutions
- collection ofStepExecution
instances to be added to the repo.
-
update
Update theStepExecution
(but not itsExecutionContext
). Preconditions:StepExecution
must be saved (have an id assigned).- Parameters:
stepExecution
-StepExecution
instance to be updated in the repo.
-
updateExecutionContext
Persist the updatedExecutionContext
s of the givenStepExecution
.- Parameters:
stepExecution
-StepExecution
instance to be used to update the context.
-
updateExecutionContext
Persist the updatedExecutionContext
of the givenJobExecution
.- Parameters:
jobExecution
-JobExecution
instance to be used to update the context.
-
getLastStepExecution
- Parameters:
jobInstance
-JobInstance
instance containing the step executions.stepName
- the name of the step execution that might have run.- Returns:
- the last execution of step for the given job instance.
-
getStepExecutionCount
- Parameters:
jobInstance
-JobInstance
instance containing the step executions.stepName
- the name of the step execution that might have run.- Returns:
- the execution count of the step within the given job instance.
-
getLastJobExecution
- Parameters:
jobName
- the name of the job that might have runjobParameters
- parameters identifying theJobInstance
- Returns:
- the last execution of job if exists, null otherwise
-