public class SimpleJobOperator extends java.lang.Object implements JobOperator, org.springframework.beans.factory.InitializingBean
| Constructor and Description |
|---|
SimpleJobOperator() |
| Modifier and Type | Method and Description |
|---|---|
JobExecution |
abandon(long jobExecutionId)
Mark the
JobExecution as ABANDONED. |
void |
afterPropertiesSet()
Check mandatory properties.
|
java.util.List<java.lang.Long> |
getExecutions(long instanceId)
List the
JobExecutions associated with a particular
JobInstance, in reverse order of creation (and therefore usually
of execution). |
java.util.List<java.lang.Long> |
getJobInstances(java.lang.String jobName,
int start,
int count)
List the
JobInstances for a given job name, in
reverse order of creation (and therefore usually of first execution). |
java.util.Set<java.lang.String> |
getJobNames()
List the available job names that can be launched with
JobOperator.start(String, String). |
java.lang.String |
getParameters(long executionId)
Get the
JobParameters as an easily readable String. |
java.util.Set<java.lang.Long> |
getRunningExecutions(java.lang.String jobName)
Get the id values of all the running
JobExecutions
with the given job name. |
java.util.Map<java.lang.Long,java.lang.String> |
getStepExecutionSummaries(long executionId)
Summarise the
StepExecution instances belonging to the
JobExecution with the supplied id, giving details of status,
start and end times etc. |
java.lang.String |
getSummary(long executionId)
Summarise the
JobExecution with the supplied id, giving details
of status, start and end times etc. |
java.lang.Long |
restart(long executionId)
Restart a failed or stopped
JobExecution. |
void |
setJobExplorer(JobExplorer jobExplorer)
Public setter for the
JobExplorer. |
void |
setJobLauncher(JobLauncher jobLauncher)
Public setter for the
JobLauncher. |
void |
setJobParametersConverter(JobParametersConverter jobParametersConverter)
Public setter for the
JobParametersConverter. |
void |
setJobRegistry(ListableJobLocator jobRegistry)
Public setter for the
ListableJobLocator. |
void |
setJobRepository(JobRepository jobRepository) |
java.lang.Long |
start(java.lang.String jobName,
java.lang.String parameters)
Start a new instance of a job with the parameters specified.
|
java.lang.Long |
startNextInstance(java.lang.String jobName)
Launch the next in a sequence of
JobInstance determined by the
JobParametersIncrementer attached to the specified job. |
boolean |
stop(long executionId)
Send a stop signal to the
JobExecution with the supplied id. |
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.ExceptionInitializingBean.afterPropertiesSet()public void setJobParametersConverter(JobParametersConverter jobParametersConverter)
JobParametersConverter.jobParametersConverter - the JobParametersConverter to setpublic void setJobRegistry(ListableJobLocator jobRegistry)
ListableJobLocator.jobRegistry - the ListableJobLocator to setpublic void setJobExplorer(JobExplorer jobExplorer)
JobExplorer.jobExplorer - the JobExplorer to setpublic void setJobRepository(JobRepository jobRepository)
public void setJobLauncher(JobLauncher jobLauncher)
JobLauncher.jobLauncher - the JobLauncher to setpublic java.util.List<java.lang.Long> getExecutions(long instanceId)
throws NoSuchJobInstanceException
JobOperatorJobExecutions associated with a particular
JobInstance, in reverse order of creation (and therefore usually
of execution).getExecutions in interface JobOperatorinstanceId - the id of a JobInstanceJobExecutions
associated with this instanceNoSuchJobInstanceExceptionpublic java.util.Set<java.lang.String> getJobNames()
JobOperatorJobOperator.start(String, String).getJobNames in interface JobOperatorpublic java.util.List<java.lang.Long> getJobInstances(java.lang.String jobName,
int start,
int count)
throws NoSuchJobException
JobOperatorJobInstances for a given job name, in
reverse order of creation (and therefore usually of first execution).getJobInstances in interface JobOperatorjobName - the job name that all the instances havestart - the start index of the instancescount - the maximum number of values to returnJobInstancesNoSuchJobExceptionpublic java.lang.String getParameters(long executionId)
throws NoSuchJobExecutionException
JobOperatorJobParameters as an easily readable String.getParameters in interface JobOperatorexecutionId - the id of an existing JobExecutionNoSuchJobExecutionException - if the id was not associated with any
JobExecutionpublic java.util.Set<java.lang.Long> getRunningExecutions(java.lang.String jobName)
throws NoSuchJobException
JobOperatorJobExecutions
with the given job name.getRunningExecutions in interface JobOperatorjobName - the name of the job to search underJobExecution instancesNoSuchJobException - if there are no JobExecutions with that job namepublic java.util.Map<java.lang.Long,java.lang.String> getStepExecutionSummaries(long executionId)
throws NoSuchJobExecutionException
JobOperatorStepExecution instances belonging to the
JobExecution with the supplied id, giving details of status,
start and end times etc.getStepExecutionSummaries in interface JobOperatorexecutionId - the id of an existing JobExecutionNoSuchJobExecutionException - if there is no JobExecution
with the supplied idpublic java.lang.String getSummary(long executionId)
throws NoSuchJobExecutionException
JobOperatorJobExecution with the supplied id, giving details
of status, start and end times etc.getSummary in interface JobOperatorexecutionId - the id of an existing JobExecutionNoSuchJobExecutionException - if there is no JobExecution
with the supplied idpublic java.lang.Long restart(long executionId)
throws JobInstanceAlreadyCompleteException,
NoSuchJobExecutionException,
NoSuchJobException,
JobRestartException,
JobParametersInvalidException
JobOperatorJobExecution. Fails with an exception
if the id provided does not exist or corresponds to a JobInstance
that in normal circumstances already completed successfully.restart in interface JobOperatorexecutionId - the id of a failed or stopped JobExecutionJobExecution that was startedJobInstanceAlreadyCompleteException - if the job was already
successfully completedNoSuchJobExecutionException - if the id was not associated with any
JobExecutionNoSuchJobException - if the JobExecution was found, but its
corresponding Job is no longer available for launchingJobRestartException - if there is a non-specific error with the
restart (e.g. corrupt or inconsistent restart data)JobParametersInvalidException - if the parameters are not valid for
this jobpublic java.lang.Long start(java.lang.String jobName,
java.lang.String parameters)
throws NoSuchJobException,
JobInstanceAlreadyExistsException,
JobParametersInvalidException
JobOperatorstart in interface JobOperatorjobName - the name of the Job to launchparameters - the parameters to launch it with (comma or newline
separated name=value pairs)JobExecution that is launchedNoSuchJobException - if there is no Job with the specified
nameJobInstanceAlreadyExistsException - if a job instance with this
name and parameters already existsJobParametersInvalidExceptionpublic java.lang.Long startNextInstance(java.lang.String jobName)
throws NoSuchJobException,
JobParametersNotFoundException,
UnexpectedJobExecutionException,
JobParametersInvalidException
JobOperatorJobInstance determined by the
JobParametersIncrementer attached to the specified job. If the
previous instance is still in a failed state, this method should still
create a new instance and run it with different parameters (as long as
the JobParametersIncrementer is working).startNextInstance in interface JobOperatorjobName - the name of the job to launchJobExecution id of the execution created when the job
is launchedNoSuchJobException - if there is no such job definition availableJobParametersNotFoundException - if the parameters cannot be foundUnexpectedJobExecutionExceptionJobParametersInvalidException@Transactional
public boolean stop(long executionId)
throws NoSuchJobExecutionException,
JobExecutionNotRunningException
JobOperatorJobExecution with the supplied id. The
signal is successfully sent if this method returns true, but that doesn't
mean that the job has stopped. The only way to be sure of that is to poll
the job execution status.stop in interface JobOperatorexecutionId - the id of a running JobExecutionNoSuchJobExecutionException - if there is no JobExecution
with the id suppliedJobExecutionNotRunningException - if the JobExecution is
not running (so cannot be stopped)public JobExecution abandon(long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException
JobOperatorJobExecution as ABANDONED. If a stop signal is ignored
because the process died this is the best way to mark a job as finished
with (as opposed to STOPPED). An abandoned job execution can be
restarted, but a stopping one cannot.abandon in interface JobOperatorjobExecutionId - the job execution id to abortJobExecution that was abortedNoSuchJobExecutionExceptionJobExecutionAlreadyRunningException - if the job is running (it
should be stopped first)