|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.core.repository.support.SimpleJobRepository
public class SimpleJobRepository
Implementation of JobRepository
that stores JobInstances,
JobExecutions, and StepExecutions using the injected DAOs.
JobRepository
,
JobInstanceDao
,
JobExecutionDao
,
StepExecutionDao
Constructor Summary | |
---|---|
SimpleJobRepository(JobInstanceDao jobInstanceDao,
JobExecutionDao jobExecutionDao,
StepExecutionDao stepExecutionDao)
|
Method Summary | |
---|---|
JobExecution |
createJobExecution(Job job,
JobParameters jobParameters)
Create a JobExecution based on the passed in Job and
JobParameters . |
StepExecution |
getLastStepExecution(JobInstance jobInstance,
Step step)
|
int |
getStepExecutionCount(JobInstance jobInstance,
Step step)
|
void |
saveOrUpdate(JobExecution jobExecution)
Save or Update a JobExecution. |
void |
saveOrUpdate(StepExecution stepExecution)
Save or Update the given StepExecution. |
void |
saveOrUpdateExecutionContext(StepExecution stepExecution)
Save the ExecutionContext of the given StepExecution . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleJobRepository(JobInstanceDao jobInstanceDao, JobExecutionDao jobExecutionDao, StepExecutionDao stepExecutionDao)
Method Detail |
---|
public JobExecution createJobExecution(Job job, JobParameters jobParameters) throws JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException
Create a JobExecution
based on the passed in Job
and
JobParameters
. However, unique identification of a job can only
come from the database, and therefore must come from JobDao by either
creating a new job instance or finding an existing one, which will ensure
that the id of the job instance is populated with the correct value.
There are two ways in which the method determines if a job should be
created or an existing one should be returned. The first is
restartability. The Job
restartable property will be checked
first. If it is false, a new job will be created, regardless of whether
or not one exists. If it is true, the JobInstanceDao
will be
checked to determine if the job already exists, if it does, it's steps
will be populated (there must be at least 1) and a new
JobExecution
will be returned. If no job instance is found, a new
one will be created.
A check is made to see if any job executions are already running, and an
exception will be thrown if one is detected. To detect a running job
execution we use the JobExecutionDao
:
JobParameters
and job nameJob
is marked restartable, then we
create a new JobInstance
Job
is not marked as
restartable, it is an error. This could be caused by a job whose
restartable flag has changed to be more strict (true not false)
after it has been executed at least once.JobInstance
then we check
the JobExecution
instances for that job, and if any of them tells
us it is running (see JobExecution.isRunning()
) then it is an
error.Isolation.REPEATABLE_READ
or better, then this
method should block if another transaction is already executing it (for
the same JobParameters
and job name). The first transaction to
complete in this scenario obtains a valid JobExecution
, and
others throw JobExecutionAlreadyRunningException
(or timeout).
There are no such guarantees if the JobInstanceDao
and
JobExecutionDao
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).
createJobExecution
in interface JobRepository
job
- the job the execution should be associated with.jobParameters
- the runtime parameters for the job
JobExecution
for the arguments provided
JobExecutionAlreadyRunningException
- if there is a
JobExecution
already running for the job instance with the
provided job and parameters.
JobRestartException
- if one or more existing JobInstance
s
is found with the same parameters and Job.isRestartable()
is
false.
JobInstanceAlreadyCompleteException
- if a JobInstance
is
found and was already completed successfully.JobRepository.createJobExecution(Job, JobParameters)
public void saveOrUpdate(JobExecution jobExecution)
saveOrUpdate
in interface JobRepository
jobExecution
- to be stored.
IllegalArgumentException
- if jobExecution is null.public void saveOrUpdate(StepExecution stepExecution)
saveOrUpdate
in interface JobRepository
stepExecution
- to be saved.
IllegalArgumentException
- if stepExecution is null.public void saveOrUpdateExecutionContext(StepExecution stepExecution)
JobRepository
ExecutionContext
of the given StepExecution
.
Implementations are allowed to ensure that the StepExecution
is
already saved by calling JobRepository.saveOrUpdate(StepExecution)
before
saving the ExecutionContext
.
saveOrUpdateExecutionContext
in interface JobRepository
stepExecution
- the StepExecution
containing the
ExecutionContext
to be saved.public StepExecution getLastStepExecution(JobInstance jobInstance, Step step)
getLastStepExecution
in interface JobRepository
public int getStepExecutionCount(JobInstance jobInstance, Step step)
getStepExecutionCount
in interface JobRepository
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |