public interface IJob
Modifier and Type | Method and Description |
---|---|
void |
addTask(Task task)
Adds a task to Job.
|
void |
cancel()
Cancels all tasks in this job.
|
void |
cancel(boolean listenForCancellationEvent)
Cancels all tasks in this job.
|
AgentSelectionType |
getAgentSelectionPreference()
Gets the agent selection preference.
|
boolean |
getCancelOnClientDisconnection()
Gets a value indicating whether to cancel the tasks of this Job when the
client disconnects.
|
boolean |
getCancelOnTaskFailure()
Gets a value indicating whether to cancel other tasks on this Job if another
Task fails. |
java.lang.String |
getDescription()
Gets the Job description.
|
boolean |
getExclusiveExecution()
Gets a value indicating whether the tasks on this job should have exclusive
access to the resource it is running on.
|
boolean |
getFailIfPreconditionsNotSatisfied()
Gets a value indicating whether to fail all tasks immediately of this Job if
the precondition is not satisfied.
|
java.util.UUID |
getId()
Gets the job's id.
|
boolean |
getIsCanceled()
Gets a value indicating whether this job has been canceled.
|
short |
getMaxTaskInterruptedRetryAttempts()
Gets the maximum number of times task will be retried if task gets
interrupted.
|
boolean |
getMinimizeClientMessaging()
Gets a value indicating whether to minimize sending some messages from the
Coordinator.
|
java.lang.String |
getName()
Gets the Job name.
|
TaskEnvironment |
getTaskEnvironment()
Gets Job's
TaskEnvironment (get /
set ) By default, an instance of
DefaultTaskEnvironment is set as the task
environment of a new job. |
int |
getTaskExecutionTimeout()
Gets the timeout for task execution in milliseconds.
|
void |
setAgentSelectionPreference(AgentSelectionType value)
Sets the agent selection preference.
|
void |
setCancelOnClientDisconnection(boolean value)
Sets a value indicating whether to cancel the tasks of this Job when the
client disconnects.
|
void |
setCancelOnTaskFailure(boolean value)
Sets a value indicating whether to cancel other tasks on this Job if another
Task fails. |
void |
setDescription(java.lang.String value)
Sets the Job description.
|
void |
setExclusiveExecution(boolean value)
Sets a value indicating whether the tasks on this job should have exclusive
access to the resource it is running on.
|
void |
setFailIfPreconditionsNotSatisfied(boolean value)
Sets a value indicating whether to fail all tasks immediately of this Job if
the precondition is not satisfied.
|
void |
setMaxTaskInterruptedRetryAttempts(short value)
Sets the maximum number of times task will be retried if task gets
interrupted.
|
void |
setMinimizeClientMessaging(boolean value)
Sets a value indicating whether to minimize sending some messages from the
Coordinator.
|
void |
setName(java.lang.String name)
Sets the Job name.
|
void |
setTaskEnvironment(TaskEnvironment value)
|
void |
setTaskExecutionTimeout(int value)
Sets the timeout for task execution in milliseconds.
|
void |
submit()
Submits job to job scheduler.
|
boolean |
waitUntilDone()
Blocks until all tasks in this job complete.
|
boolean |
waitUntilDone(int millisecondsTimeout)
Blocks until all tasks in this job complete or the operation times out.
|
boolean |
waitUntilDone(int millisecondsTimeout,
java.lang.Runnable heartbeatCallback,
int millisecondsHeartbeat)
Blocks until all tasks in this job complete or the operation times out.
|
java.util.UUID getId()
TaskEnvironment getTaskEnvironment()
TaskEnvironment
(get
/
set
) By default, an instance of
DefaultTaskEnvironment
is set as the task
environment of a new job.void setTaskEnvironment(TaskEnvironment value)
TaskEnvironment
(get
/
set
)
By default, an instance of
DefaultTaskEnvironment
is set as the task
environment of a new job.
value
- The task environment.boolean getCancelOnClientDisconnection()
CancelOnClientDisconnection ensures that a task does not remain in the coordinator's task queue if the client is no longer connected. If a client disconnects unexpectedly, all tasks in the job are canceled. This is useful for interactive jobs which only makes sense to run if the client is connected and is waiting to process the result of the task.
true
if task should be canceled when the client disconnects.
false
otherwise.void setCancelOnClientDisconnection(boolean value)
CancelOnClientDisconnection ensures that a task does not remain in the coordinator's task queue if the client is no longer connected. If a client disconnects unexpectedly, all tasks in the job are canceled. This is useful for interactive jobs which only makes sense to run if the client is connected and is waiting to process the result of the task.
value
- true
if task should be canceled when the client
disconnects. false
otherwise.boolean getCancelOnTaskFailure()
Task
fails.
CancelOnTaskFailure ensures that a task does not remain in the coordinator's task queue if the task fails. This is useful for jobs which are considered logically successful if all the tasks are successful. That is, if a single task fails, then the whole job should be considered a failure.
void setCancelOnTaskFailure(boolean value)
Task
fails.
CancelOnTaskFailure ensures that a task does not remain in the coordinator's task queue if the task fails. This is useful for jobs which are considered logically successful if all the tasks are successful. That is, if a single task fails, then the whole job should be considered a failure.
boolean getFailIfPreconditionsNotSatisfied()
FailIfPreconditionsNotSatisfied ensures that a task does not remain in the coordinator's task queue if there are currently no agents which meet the preconditions. This is useful for applications which would rather fail fast if a job can't be run rather than wait for certain conditions to become true in the future.
void setFailIfPreconditionsNotSatisfied(boolean value)
FailIfPreconditionsNotSatisfied ensures that a task does not remain in the coordinator's task queue if there are currently no agents which meet the preconditions. This is useful for applications which would rather fail fast if a job can't be run rather than wait for certain conditions to become true in the future.
boolean getMinimizeClientMessaging()
void setMinimizeClientMessaging(boolean value)
short getMaxTaskInterruptedRetryAttempts()
While executing a task, there are a number of system errors that may occur that may happen no matter how well your task is coded. Some examples include the host process exiting abnormally or an agent disconnecting from the coordinator while the agent "owns" a task. Normally, these errors are recoverable; if the task was retried again the task may succeed. As such, the system will try to reassign the task for execution for as many times as MaxTaskInterruptedRetryAttempts is specified.
Setting the maximum task interrupted retry attempts to 0
means
that the task will never be retried if there is a system exception while
executing the task.
void setMaxTaskInterruptedRetryAttempts(short value)
While executing a task, there are a number of system errors that may occur that may happen no matter how well your task is coded. Some examples include the host process exiting abnormally or an agent disconnecting from the coordinator while the agent "owns" a task. Normally, these errors are recoverable; if the task was retried again the task may succeed. As such, the system will try to reassign the task for execution for as many times as MaxTaskInterruptedRetryAttempts is specified.
Setting the maximum task interrupted retry attempts to 0
means
that the task will never be retried if there is a system exception while
executing the task.
java.lang.IllegalArgumentException
- Value must be equal or greater than 0
.boolean getExclusiveExecution()
Tasks can either consume a single core of all the cores of an agent. An exclusive job means that all the task of a job will consume all the cores of an agent. The ExclusiveExecution flag prevents any other task to be executed concurrently.
void setExclusiveExecution(boolean value)
Tasks can either consume a single core of all the cores of an agent. An exclusive job means that all the task of a job will consume all the cores of an agent. The ExclusiveExecution flag prevents any other task to be executed concurrently.
int getTaskExecutionTimeout()
TaskExecutionTimeout is the number of milliseconds that a task can run before it is considered timed out. The TaskExecutionTimeout applies to the task execution, it does not include TaskEnvironment setup time or the time duration that passes after a task has been submitted.
void setTaskExecutionTimeout(int value)
TaskExecutionTimeout is the number of milliseconds that a task can run before it is considered timed out. The TaskExecutionTimeout applies to the task execution, it does not include TaskEnvironment setup time or the time duration that passes after a task has been submitted.
value
- Timeout (in milliseconds)AgentSelectionType getAgentSelectionPreference()
void setAgentSelectionPreference(AgentSelectionType value)
value
- The agent selection preference.java.lang.String getName()
void setName(java.lang.String name)
name
- Job name.java.lang.String getDescription()
void setDescription(java.lang.String value)
value
- The description.boolean getIsCanceled()
true
if the job is canceled; otherwise,
false
.void addTask(Task task)
task
- The task to be added to Job.void submit() throws JobSchedulerException
JobSchedulerException
- If error occurs with job scheduler.boolean waitUntilDone() throws JobSchedulerException
True
if the call completed without timing out.JobSchedulerException
- If error occurs with job scheduler such as the client timing
out.boolean waitUntilDone(int millisecondsTimeout) throws JobSchedulerException
millisecondsTimeout
- The number of milliseconds to wait. Pass
to wait indefinitely.JobSchedulerException
- If error occurs with job scheduler such as the client timing
out.boolean waitUntilDone(int millisecondsTimeout, java.lang.Runnable heartbeatCallback, int millisecondsHeartbeat) throws JobSchedulerException
millisecondsHeartbeat
argument.millisecondsTimeout
- The timeout (in milliseconds).heartbeatCallback
- The heartbeat callback.millisecondsHeartbeat
- The heartbeat period (in milliseconds).true
if job completed, false
if timed-out.JobSchedulerException
- If error occurs with job scheduler such as the client timing
out.void cancel() throws JobSchedulerException
JobSchedulerException
void cancel(boolean listenForCancellationEvent) throws JobSchedulerException
listenForCancellationEvent
- if set to true
, client will listen for the
cancellation event. Otherwise, cancellation events can be ignored.JobSchedulerException