public class JPPFJob extends AbstractJPPFJob<JPPFJob> implements Iterable<org.jppf.node.protocol.Task<?>>, Future<List<org.jppf.node.protocol.Task<?>>>
This class also provides the API for handling JPPF-annotated tasks and POJO tasks.
All jobs have a name. It can be specified by calling setName(String name).
If left unspecified, JPPF will automatically assign a uuid as its value.
| Constructor and Description |
|---|
JPPFJob()
Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0.
|
JPPFJob(String jobUuid)
Default constructor, creates a blocking job with no data provider, default SLA values and a priority of 0.
|
| Modifier and Type | Method and Description |
|---|---|
org.jppf.node.protocol.Task<?> |
add(Callable<?> callable)
Add a
Callable task to this job. |
org.jppf.node.protocol.Task<?> |
add(org.jppf.utils.JPPFCallable<?> callable)
Add a
Callable task to this job. |
org.jppf.node.protocol.Task<?> |
add(org.jppf.utils.JPPFRunnableTask runnable)
Add a
JPPFRunnableTask task to this job. |
org.jppf.node.protocol.Task<?> |
add(Object taskObject,
Object... args)
Add a task to this job.
|
org.jppf.node.protocol.Task<?> |
add(Runnable runnable)
Add a
Runnable task to this job. |
org.jppf.node.protocol.Task<?> |
add(String method,
Object taskObject,
Object... args)
Add a POJO task to this job.
|
org.jppf.node.protocol.Task<?> |
add(org.jppf.node.protocol.Task<?> task)
Add a
Task to this job. |
void |
addAll(List<org.jppf.node.protocol.Task<?>> tasks)
Add the specified tasks to this job in a bulk operation.
|
JPPFJob |
addDependencies(Collection<JPPFJob> dependencies)
Add the specified jobs as dependencies to this job.
|
JPPFJob |
addDependencies(JPPFJob... dependencies)
Add the specified jobs as dependencies to this job.
|
void |
addJobListener(JobListener listener)
Add a listener to the list of job listeners.
|
List<org.jppf.node.protocol.Task<?>> |
awaitResults()
Wait until all execution results of the tasks in this job have been collected.
|
List<org.jppf.node.protocol.Task<?>> |
awaitResults(long timeout)
Wait until all execution results of the tasks in this job have been collected, or the timeout expires, whichever happens first.
|
boolean |
cancel()
Cancel this job unconditionally.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
List<org.jppf.node.protocol.Task<?>> |
get() |
List<org.jppf.node.protocol.Task<?>> |
get(long timeout,
TimeUnit unit) |
List<org.jppf.node.protocol.Task<?>> |
getAllResults()
Get the list of currently available task execution results.
|
List<org.jppf.node.protocol.Task<?>> |
getJobTasks()
Get the list of tasks to execute.
|
<T> JobPersistence<T> |
getPersistenceManager()
Get the persistence manager that enables saving and restoring the state of this job.
|
boolean |
hasTaskGraph()
Determine whether the tasks in this job form a dependencies graph.
|
boolean |
isCancelled() |
boolean |
isDone() |
Iterator<org.jppf.node.protocol.Task<?>> |
iterator() |
void |
removeJobListener(JobListener listener)
Remove a listener from the list of job listeners.
|
JPPFJob |
setCascadeCancellation(boolean cascadeCancellation)
Set whether cancellation of this job should trigger the cancellation of the jobs that depend on it.
|
JPPFJob |
setDependencyId(JobDependencyIdSupplier idSupplier)
Set this job's dependency id from a dependency id supplier.
|
JPPFJob |
setDependencyId(String id)
Set this job's dependency id.
|
JPPFJob |
setDependencyId(Supplier<String> idSupplier)
Set this job's dependency id from the specified id supplier.
|
JPPFJob |
setGraphRoot(boolean graphRoot)
Set whether this job is a root in a job dependency graph.
|
JPPFJob |
setNameAsDependencyId()
Convenience method to set this job's name as dpeendency id.
|
<T> JPPFJob |
setPersistenceManager(JobPersistence<T> persistenceManager)
Set the persistence manager that enables saving and restoring the state of this job.
|
JPPFJob |
setUuidAsDependencyId()
Convenience method to set this job's uuid as dependency id.
|
equals, executedTaskCount, getClientSLA, getDataProvider, getMetadata, getName, getResults, getSLA, getStatus, getTaskCount, getUuid, hashCode, isBlocking, setBlocking, setDataProvider, setName, setStatus, toString, unexecutedTaskCountclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic JPPFJob()
public JPPFJob(String jobUuid)
jobUuid - the uuid to assign to this job.public List<org.jppf.node.protocol.Task<?>> getJobTasks()
public void addAll(List<org.jppf.node.protocol.Task<?>> tasks) throws org.jppf.JPPFException
tasks - the list of tasks to add.org.jppf.JPPFException - if any error occurs.public org.jppf.node.protocol.Task<?> add(Object taskObject, Object... args) throws org.jppf.JPPFException
Task,
annotated with JPPFRunnable, or an instance of Runnable or Callable.taskObject - the task to add to this job.args - arguments to use with a JPPF-annotated class.Task that is either the same as the input if the input is a subclass of AbstractTask,
or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(String method, Object taskObject, Object... args) throws org.jppf.JPPFException
method - the name of the method to execute. For a constructor, this should be identical to the simple name of the class as per Class.getSimpleName().taskObject - the task to add to this job.args - arguments to use with a JPPF-annotated class.Task that is a wrapper around the input task object.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(org.jppf.node.protocol.Task<?> task)
throws org.jppf.JPPFException
Task to this job. When the task is an instance of TaskNode, the entire dependency graph rooted at this task is added as well.task - the task to add to this job.Task that is either the same as the input if the input is a subclass of AbstractTask,
or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(Runnable runnable) throws org.jppf.JPPFException
Runnable task to this job.
Note: it is recommended to use JPPFJob.add(JPPFRunnableTask) whenever possible instead. This ensures that the provided Runnable is serializable.
runnable - the runnable task to add to this job.Task that is either the same as the input if the input is a subclass of AbstractTask, or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(org.jppf.utils.JPPFRunnableTask runnable)
throws org.jppf.JPPFException
JPPFRunnableTask task to this job.runnable - the runnable task to add to this job.Task that is either the same as the input if the input is a subclass of AbstractTask, or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(Callable<?> callable) throws org.jppf.JPPFException
Callable task to this job.
Note: it is recommended to use JPPFJob.add(JPPFCallable) whenever possible instead. This ensures that the provided Callable is serializable.
callable - the callable task to add to this job.Task that is either the same as the input if the input is a subclass of AbstractTask, or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public org.jppf.node.protocol.Task<?> add(org.jppf.utils.JPPFCallable<?> callable)
throws org.jppf.JPPFException
Callable task to this job.callable - the callable task to add to this job.Task that is either the same as the input if the input is a subclass of AbstractTask, or a wrapper around the input object in the other cases.org.jppf.JPPFException - if one of the tasks is neither a Task or a JPPF-annotated class.public void addJobListener(JobListener listener)
listener - a JobListener instance.public void removeJobListener(JobListener listener)
listener - a JobListener instance.public <T> JobPersistence<T> getPersistenceManager()
T - the type of the keys used by the persistence manager.JobPersistence instance.public <T> JPPFJob setPersistenceManager(JobPersistence<T> persistenceManager)
T - the type of the keys used by the persistence manager.persistenceManager - a JobPersistence instance.public Iterator<org.jppf.node.protocol.Task<?>> iterator()
public List<org.jppf.node.protocol.Task<?>> awaitResults()
get(), except that it doesn't raise an exception.public List<org.jppf.node.protocol.Task<?>> awaitResults(long timeout)
get(timeout, TimeUnit.MILLISECONDS), except that it doesn't raise an exception.timeout - the maximum time to wait in milliseconds, zero or less meaning an infinite wait.null if the timeout expired before all results were received.public List<org.jppf.node.protocol.Task<?>> getAllResults()
getResults().getResultsList().Task instances, possibly empty.public boolean cancel()
cancel(true).false if the job could not be cancelled, typically because it has already completed normally; true otherwise.public boolean cancel(boolean mayInterruptIfRunning)
public boolean isCancelled()
isCancelled in interface Future<List<org.jppf.node.protocol.Task<?>>>public boolean isDone()
public List<org.jppf.node.protocol.Task<?>> get() throws InterruptedException, ExecutionException
get in interface Future<List<org.jppf.node.protocol.Task<?>>>InterruptedExceptionExecutionExceptionpublic List<org.jppf.node.protocol.Task<?>> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<List<org.jppf.node.protocol.Task<?>>>InterruptedExceptionExecutionExceptionTimeoutExceptionpublic boolean hasTaskGraph()
true if the tasks form a graph, false if all the tasks are independant from each other.public JPPFJob setDependencyId(Supplier<String> idSupplier)
getSLA().getDependencySpec().setId(idSupplier.get()).idSupplier - a dependency id supplier which computes a dependency id from this job's state.JobDependencySpec.setId(String)public JPPFJob setDependencyId(JobDependencyIdSupplier idSupplier)
getSLA().getDependencySpec().setId(idSupplier.getId(this)).idSupplier - a dependency id supplier which computes a dependency id from this job's state.JobDependencySpec.setId(String)public JPPFJob setDependencyId(String id)
getSLA().getDependencySpec().setId(id).id - the id of this job in the job dependency graph.JobDependencySpec.setId(String)public JPPFJob setUuidAsDependencyId()
setDependencyId(getUuid()).JobDependencySpec.setId(String)public JPPFJob setNameAsDependencyId()
setDependencyId(getName()).JobDependencySpec.setId(String)public JPPFJob addDependencies(JPPFJob... dependencies)
dependencies - the job to add as dependencies to this job.JobDependencySpec.addDependencies(String[])public JPPFJob addDependencies(Collection<JPPFJob> dependencies)
dependencies - the job to add as dependencies to this job.JobDependencySpec.addDependencies(Collection)public JPPFJob setGraphRoot(boolean graphRoot)
getSLA().getDependencySpec().setGraphRoot(graphRoot).graphRoot - true if the job is a root in the dependency graph and should be removed from the graph after completion, false otherwise.JobDependencySpec.setGraphRoot(boolean)public JPPFJob setCascadeCancellation(boolean cascadeCancellation)
getSLA().getDependencySpec().setCascadeCancellation(cascadeCancellation).cascadeCancellation - true (the default) if cancellation of this job should trigger the cancellation of its dependents, false otherwise.JobDependencySpec.setCascadeCancellation(boolean)Copyright © 2005-2019 JPPF Team.