| Constructor and Description |
|---|
Job(IJobScheduler scheduler)
Initializes a new instance of the
Job class. |
| Modifier and Type | Method and Description |
|---|---|
void |
addJobCompletedListener(JobCompletedListener listener)
Add a
JobCompletedListener to this job. |
void |
addJobSubmittedListener(JobSubmittedListener listener)
Add a
JobSubmittedListener to this job. |
void |
addTask(Task task)
Adds a task to Job.
|
void |
addTaskCompletedListener(TaskCompletedListener listener)
Add a
TaskCompletedListener to this job. |
void |
addTaskProgressListener(TaskProgressUpdatedListener listener)
Add a
TaskProgressUpdatedListener to this job. |
void |
addTaskStateChangeListener(TaskStateChangedListener listener)
Add a
TaskStateChangedListener to this job. |
void |
cancel()
Cancels all tasks in this job.
|
void |
cancel(boolean listenForCancellationEvent)
Cancels all tasks in this job.
|
java.util.List<java.lang.String> |
getAdditionalJars()
Gets the list of additional jars that are sent with this job.
|
java.util.List<java.lang.String> |
getAdditionalNativeLibraries()
Gets the list of additional native libraries that are sent with this jar.
|
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.
|
java.util.List<java.lang.String> |
getExcludedJars()
Gets the list of excluded jars that are not sent with this job.
|
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.
|
JobPriority |
getPriority()
Gets the job priority.
|
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.
|
TaskPreconditionCollection |
getTaskPreconditions()
Gets the list of task pre conditions.
|
TaskCollection |
getTasks()
Gets the tasks that are contained in this
Job. |
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 value)
Sets the Job name.
|
void |
setPriority(JobPriority value)
Sets the job priority.
|
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.
|
public Job(IJobScheduler scheduler)
Job class.scheduler - The scheduler which job is submitted to.public void addTaskCompletedListener(TaskCompletedListener listener)
TaskCompletedListener to this job.public void addTaskStateChangeListener(TaskStateChangedListener listener)
TaskStateChangedListener to this job.public void addTaskProgressListener(TaskProgressUpdatedListener listener)
TaskProgressUpdatedListener to this job.public void addJobSubmittedListener(JobSubmittedListener listener)
JobSubmittedListener to this job.public void addJobCompletedListener(JobCompletedListener listener)
JobCompletedListener to this job.public final java.util.UUID getId()
IJobpublic final TaskCollection getTasks()
Job.public final java.util.List<java.lang.String> getAdditionalJars()
public final java.util.List<java.lang.String> getExcludedJars()
public final java.util.List<java.lang.String> getAdditionalNativeLibraries()
public final TaskPreconditionCollection getTaskPreconditions()
public final TaskEnvironment getTaskEnvironment()
IJobTaskEnvironment (get /
set) By default, an instance of
DefaultTaskEnvironment is set as the task
environment of a new job.getTaskEnvironment in interface IJobpublic final void setTaskEnvironment(TaskEnvironment value)
IJobTaskEnvironment (get /
set)
By default, an instance of
DefaultTaskEnvironment is set as the task
environment of a new job.
setTaskEnvironment in interface IJobvalue - The task environment.public final boolean getCancelOnClientDisconnection()
IJobCancelOnClientDisconnection 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.
getCancelOnClientDisconnection in interface IJobtrue if task should be canceled when the client disconnects.
false otherwise.public final void setCancelOnClientDisconnection(boolean value)
IJobCancelOnClientDisconnection 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.
setCancelOnClientDisconnection in interface IJobvalue - true if task should be canceled when the client
disconnects. false otherwise.public final boolean getCancelOnTaskFailure()
IJobTask 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.
getCancelOnTaskFailure in interface IJobpublic final void setCancelOnTaskFailure(boolean value)
IJobTask 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.
setCancelOnTaskFailure in interface IJobpublic final boolean getFailIfPreconditionsNotSatisfied()
IJobFailIfPreconditionsNotSatisfied 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.
getFailIfPreconditionsNotSatisfied in interface IJobpublic final void setFailIfPreconditionsNotSatisfied(boolean value)
IJobFailIfPreconditionsNotSatisfied 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.
setFailIfPreconditionsNotSatisfied in interface IJobpublic final boolean getMinimizeClientMessaging()
IJobgetMinimizeClientMessaging in interface IJobpublic final void setMinimizeClientMessaging(boolean value)
IJobsetMinimizeClientMessaging in interface IJobpublic final short getMaxTaskInterruptedRetryAttempts()
IJobWhile 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.
getMaxTaskInterruptedRetryAttempts in interface IJobpublic final void setMaxTaskInterruptedRetryAttempts(short value)
IJobWhile 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.
setMaxTaskInterruptedRetryAttempts in interface IJobpublic final boolean getExclusiveExecution()
IJobTasks 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.
getExclusiveExecution in interface IJobpublic final void setExclusiveExecution(boolean value)
IJobTasks 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.
setExclusiveExecution in interface IJobpublic final int getTaskExecutionTimeout()
IJobTaskExecutionTimeout 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.
getTaskExecutionTimeout in interface IJobpublic final void setTaskExecutionTimeout(int value)
IJobTaskExecutionTimeout 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.
setTaskExecutionTimeout in interface IJobvalue - Timeout (in milliseconds)public final JobPriority getPriority()
public final void setPriority(JobPriority value)
public final AgentSelectionType getAgentSelectionPreference()
IJobgetAgentSelectionPreference in interface IJobpublic final void setAgentSelectionPreference(AgentSelectionType value)
IJobsetAgentSelectionPreference in interface IJobvalue - The agent selection preference.public final java.lang.String getName()
IJobpublic final void setName(java.lang.String value)
IJobpublic final java.lang.String getDescription()
IJobgetDescription in interface IJobpublic final void setDescription(java.lang.String value)
IJobsetDescription in interface IJobvalue - The description.public final boolean getIsCanceled()
IJobgetIsCanceled in interface IJobtrue if the job is canceled; otherwise,
false.public final void addTask(Task task) throws java.lang.IllegalArgumentException
IJobpublic final void submit()
throws JobSchedulerException
IJobsubmit in interface IJobJobSchedulerException - If error occurs with job scheduler.public final boolean waitUntilDone()
throws JobSchedulerException
IJobwaitUntilDone in interface IJobTrue if the call completed without timing out.JobSchedulerException - If error occurs with job scheduler such as the client timing
out.public final boolean waitUntilDone(int millisecondsTimeout)
throws JobSchedulerException
IJobwaitUntilDone in interface IJobmillisecondsTimeout - The number of milliseconds to wait. Pass
to wait indefinitely.JobSchedulerException - If error occurs with job scheduler such as the client timing
out.public final boolean waitUntilDone(int millisecondsTimeout,
java.lang.Runnable heartbeatCallback,
int millisecondsHeartbeat)
throws JobSchedulerException
IJobmillisecondsHeartbeat argument.waitUntilDone in interface IJobmillisecondsTimeout - 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.public final void cancel()
throws JobSchedulerException
IJobcancel in interface IJobJobSchedulerExceptionpublic final void cancel(boolean listenForCancellationEvent)
throws JobSchedulerException
IJobcancel in interface IJoblistenForCancellationEvent - if set to true, client will listen for the
cancellation event. Otherwise, cancellation events can be ignored.JobSchedulerException