Package javax.batch.operations
Interface JobOperator
public interface JobOperator
JobOperator provide the interface for operating on batch jobs.
Through the JobOperator a program can start, stop, and restart jobs.
It can additionally inspect job history, to discover what jobs
are currently running and what jobs have previously run.
The JobOperator interface imposes no security constraints. However,
the implementer is free to limit JobOperator methods with a security
scheme of its choice. The implementer should terminate any method
that is limited by the security scheme with a JobSecurityException.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abandon
(long executionId) Set batch status to ABANDONED.getJobExecution
(long executionId) Return job execution for specified execution idgetJobExecutions
(JobInstance instance) Return all job executions belonging to the specified job instance.getJobInstance
(long executionId) Return the job instance for the specified execution id.int
getJobInstanceCount
(String jobName) Returns number of instances of a job with a particular name.getJobInstances
(String jobName, int start, int count) Returns all JobInstances belonging to a job with a particular name in reverse chronological order.Returns a set of all job names known to the batch runtime.getParameters
(long executionId) Returns job parameters for a specified job instance.getRunningExecutions
(String jobName) Returns execution ids for job instances with the specified name that have running executions.getStepExecutions
(long jobExecutionId) Return StepExecutions for specified execution id.long
restart
(long executionId, Properties restartParameters) Restarts a failed or stopped job instance.long
start
(String jobXMLName, Properties jobParameters) Creates a new job instance and starts the first execution of that instance.void
stop
(long executionId) Request a running job execution stops.
-
Method Details
-
getJobNames
Returns a set of all job names known to the batch runtime.- Returns:
- a set of job names.
- Throws:
JobSecurityException
-
getJobInstanceCount
Returns number of instances of a job with a particular name.- Parameters:
jobName
- specifies the name of the job.- Returns:
- count of instances of the named job.
- Throws:
NoSuchJobException
JobSecurityException
-
getJobInstances
List<JobInstance> getJobInstances(String jobName, int start, int count) throws NoSuchJobException, JobSecurityException Returns all JobInstances belonging to a job with a particular name in reverse chronological order.- Parameters:
jobName
- specifies the job name.start
- specifies the relative starting number (zero based) to return from the maximal list of job instances.count
- specifies the number of job instances to return from the starting position of the maximal list of job instances.- Returns:
- list of JobInstances.
- Throws:
NoSuchJobException
JobSecurityException
-
getRunningExecutions
Returns execution ids for job instances with the specified name that have running executions.- Parameters:
jobName
- specifies the job name.- Returns:
- a list of execution ids.
- Throws:
NoSuchJobException
JobSecurityException
-
getParameters
Returns job parameters for a specified job instance. These are the key/value pairs specified when the instance was originally created by the start method.- Parameters:
executionId
- specifies the execution from which to retrieve the parameters.- Returns:
- a Properties object containing the key/value job parameter pairs.
- Throws:
NoSuchJobExecutionException
JobSecurityException
-
start
long start(String jobXMLName, Properties jobParameters) throws JobStartException, JobSecurityException Creates a new job instance and starts the first execution of that instance. Note the Job XML describing the job is first searched for by name according to a means prescribed by the batch runtime implementation. This may vary by implementation. If the Job XML is not found by that means, then the batch runtime must search for the specified Job XML as a resource from the META-INF/batch-jobs directory based on the current class loader. Job XML files under META-INF/batch-jobs directory follow a naming convention of "name".xml where "name" is the value of the jobXMLName parameter (see below).- Parameters:
jobXMLName
- specifies the name of the Job XML describing the job.jobParameters
- specifies the keyword/value pairs for attribute substitution in the Job XML.- Returns:
- executionId for the job execution.
- Throws:
JobStartException
JobSecurityException
-
restart
long restart(long executionId, Properties restartParameters) throws JobExecutionAlreadyCompleteException, NoSuchJobExecutionException, JobExecutionNotMostRecentException, JobRestartException, JobSecurityException Restarts a failed or stopped job instance.- Parameters:
executionId
- specifies the execution to to restart. This execution must be the most recent execution that ran.restartParameters
- specifies the keyword/value pairs for attribute substitution in the Job XML.- Returns:
- new executionId
- Throws:
JobExecutionAlreadyCompleteException
NoSuchJobExecutionException
JobRestartException
JobSecurityException
JobExecutionNotMostRecentException
-
stop
void stop(long executionId) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException Request a running job execution stops. This method notifies the job execution to stop and then returns. The job execution normally stops and does so asynchronously. Note JobOperator cannot guarantee the jobs stops: it is possible a badly behaved batch application does not relinquish control.Note for partitioned batchlet steps the Batchlet stop method is invoked on each thread actively processing a partition.
- Parameters:
executionId
- specifies the job execution to stop. The job execution must be running.- Throws:
NoSuchJobExecutionException
JobExecutionNotRunningException
JobSecurityException
-
abandon
void abandon(long executionId) throws NoSuchJobExecutionException, JobExecutionIsRunningException, JobSecurityException Set batch status to ABANDONED. The instance must have no running execution.Note that ABANDONED executions cannot be restarted.
- Parameters:
executionId
- specifies the job execution to abandon.- Throws:
NoSuchJobExecutionException
JobExecutionIsRunningException
JobSecurityException
-
getJobInstance
JobInstance getJobInstance(long executionId) throws NoSuchJobExecutionException, JobSecurityException Return the job instance for the specified execution id.- Parameters:
executionId
- specifies the job execution.- Returns:
- job instance
- Throws:
NoSuchJobExecutionException
JobSecurityException
-
getJobExecutions
List<JobExecution> getJobExecutions(JobInstance instance) throws NoSuchJobInstanceException, JobSecurityException Return all job executions belonging to the specified job instance.- Parameters:
jobInstance
- specifies the job instance.- Returns:
- list of job executions
- Throws:
NoSuchJobInstanceException
JobSecurityException
-
getJobExecution
JobExecution getJobExecution(long executionId) throws NoSuchJobExecutionException, JobSecurityException Return job execution for specified execution id- Parameters:
executionId
- specifies the job execution.- Returns:
- job execution
- Throws:
NoSuchJobExecutionException
JobSecurityException
-
getStepExecutions
List<StepExecution> getStepExecutions(long jobExecutionId) throws NoSuchJobExecutionException, JobSecurityException Return StepExecutions for specified execution id.- Parameters:
executionId
- specifies the job execution.- Returns:
- step executions (order not guaranteed)
- Throws:
NoSuchJobExecutionException
JobSecurityException
-