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()
IJob
public 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()
IJob
TaskEnvironment
(get
/
set
) By default, an instance of
DefaultTaskEnvironment
is set as the task
environment of a new job.getTaskEnvironment
in interface IJob
public final void setTaskEnvironment(TaskEnvironment value)
IJob
TaskEnvironment
(get
/
set
)
By default, an instance of
DefaultTaskEnvironment
is set as the task
environment of a new job.
setTaskEnvironment
in interface IJob
value
- The task environment.public final boolean getCancelOnClientDisconnection()
IJob
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.
getCancelOnClientDisconnection
in interface IJob
true
if task should be canceled when the client disconnects.
false
otherwise.public final void setCancelOnClientDisconnection(boolean value)
IJob
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.
setCancelOnClientDisconnection
in interface IJob
value
- true
if task should be canceled when the client
disconnects. false
otherwise.public final boolean getCancelOnTaskFailure()
IJob
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.
getCancelOnTaskFailure
in interface IJob
public final void setCancelOnTaskFailure(boolean value)
IJob
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.
setCancelOnTaskFailure
in interface IJob
public final boolean getFailIfPreconditionsNotSatisfied()
IJob
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.
getFailIfPreconditionsNotSatisfied
in interface IJob
public final void setFailIfPreconditionsNotSatisfied(boolean value)
IJob
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.
setFailIfPreconditionsNotSatisfied
in interface IJob
public final boolean getMinimizeClientMessaging()
IJob
getMinimizeClientMessaging
in interface IJob
public final void setMinimizeClientMessaging(boolean value)
IJob
setMinimizeClientMessaging
in interface IJob
public final short getMaxTaskInterruptedRetryAttempts()
IJob
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.
getMaxTaskInterruptedRetryAttempts
in interface IJob
public final void setMaxTaskInterruptedRetryAttempts(short value)
IJob
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.
setMaxTaskInterruptedRetryAttempts
in interface IJob
public final boolean getExclusiveExecution()
IJob
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.
getExclusiveExecution
in interface IJob
public final void setExclusiveExecution(boolean value)
IJob
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.
setExclusiveExecution
in interface IJob
public final int getTaskExecutionTimeout()
IJob
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.
getTaskExecutionTimeout
in interface IJob
public final void setTaskExecutionTimeout(int value)
IJob
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.
setTaskExecutionTimeout
in interface IJob
value
- Timeout (in milliseconds)public final JobPriority getPriority()
public final void setPriority(JobPriority value)
public final AgentSelectionType getAgentSelectionPreference()
IJob
getAgentSelectionPreference
in interface IJob
public final void setAgentSelectionPreference(AgentSelectionType value)
IJob
setAgentSelectionPreference
in interface IJob
value
- The agent selection preference.public final java.lang.String getName()
IJob
public final void setName(java.lang.String value)
IJob
public final java.lang.String getDescription()
IJob
getDescription
in interface IJob
public final void setDescription(java.lang.String value)
IJob
setDescription
in interface IJob
value
- The description.public final boolean getIsCanceled()
IJob
getIsCanceled
in interface IJob
true
if the job is canceled; otherwise,
false
.public final void addTask(Task task) throws java.lang.IllegalArgumentException
IJob
public final void submit() throws JobSchedulerException
IJob
submit
in interface IJob
JobSchedulerException
- If error occurs with job scheduler.public final boolean waitUntilDone() throws JobSchedulerException
IJob
waitUntilDone
in interface IJob
True
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
IJob
waitUntilDone
in interface IJob
millisecondsTimeout
- 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
IJob
millisecondsHeartbeat
argument.waitUntilDone
in interface IJob
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.public final void cancel() throws JobSchedulerException
IJob
cancel
in interface IJob
JobSchedulerException
public final void cancel(boolean listenForCancellationEvent) throws JobSchedulerException
IJob
cancel
in interface IJob
listenForCancellationEvent
- if set to true
, client will listen for the
cancellation event. Otherwise, cancellation events can be ignored.JobSchedulerException