public abstract class JPPFTask extends Object implements Task<Object>
JPPF clients have to extend this class and must implement the run method. In the
run method the task calculations are performed, and the result of the calculations
is set with the JPPFTask.setResult(Object) method:
class MyTask extends JPPFTask {
public void run() {
// do the calculation ...
setResult(myResult);
}
}
| Constructor and Description |
|---|
JPPFTask()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
<V> V |
compute(JPPFCallable<V> callable)
Compute a value on the client-side, as the result of the execution of a
JPPFCallable. |
DataProvider |
getDataProvider()
Get the provider of shared data for this task.
|
Exception |
getException()
Get the exception that was raised by this task's execution.
|
String |
getId()
Get the user-assigned id for this task.
|
int |
getPosition()
Returns the position of this task in the job in which it was submitted.
|
Object |
getResult()
Get the result of the task execution.
|
Object |
getTaskObject()
Get the
JPPFRunnable-annotated object or POJO wrapped by this task. |
JPPFSchedule |
getTimeoutSchedule()
Get the task timeout schedule configuration.
|
boolean |
isInNode()
Determine whether this task is executing within a node, or locally on the client side.
|
void |
onCancel()
Callback invoked when this task is cancelled.
|
void |
onTimeout()
Callback invoked when this task times out.
|
void |
setDataProvider(DataProvider dataProvider)
Set the provider of shared data for this task.
|
void |
setException(Exception exception)
Sets the exception that was raised by this task's execution in the
run method. |
void |
setId(String id)
Set the user-assigned id for this task.
|
void |
setPosition(int position)
Set the position of this task in the job in which it was submitted.
|
void |
setResult(Object result)
Set the result of the task execution.
|
void |
setTimeoutSchedule(JPPFSchedule timeoutSchedule)
Get the task timeout schedule configuration.
|
public Object getResult()
Taskpublic void setResult(Object result)
Taskpublic Exception getException()
TaskThrowable, the exception is embedded into a JPPFException.getException in interface Task<Object>Exception instance, or null if no exception was raised.public void setException(Exception exception)
Taskrun method.
The exception is set by the JPPF framework.setException in interface Task<Object>exception - a ClientApplicationException instance.public DataProvider getDataProvider()
TaskgetDataProvider in interface Task<Object>DataProvider instance.public void setDataProvider(DataProvider dataProvider)
TasksetDataProvider in interface Task<Object>dataProvider - a DataProvider instance.public final int getPosition()
TaskgetPosition in interface Task<Object>int.public final void setPosition(int position)
TasksetPosition in interface Task<Object>position - the position of this task as an int.public String getId()
Taskpublic void setId(String id)
Taskpublic void onCancel()
Taskpublic void onTimeout()
Taskpublic Object getTaskObject()
TaskJPPFRunnable-annotated object or POJO wrapped by this task.getTaskObject in interface Task<Object>public JPPFSchedule getTimeoutSchedule()
TaskgetTimeoutSchedule in interface Task<Object>JPPFSchedule instance.public void setTimeoutSchedule(JPPFSchedule timeoutSchedule)
TasksetTimeoutSchedule in interface Task<Object>timeoutSchedule - a JPPFSchedule instance.public boolean isInNode()
Taskpublic <V> V compute(JPPFCallable<V> callable) throws Exception
TaskJPPFCallable.
Any Throwable raised in the callable's call() method will be thrown as the result of this method.
If the Throwable is an instance of Exception or one of its subclasses, it is thrown as such, otherwise it is wrapped
into a JPPFException.
compute in interface Task<Object>V - the type of results returned by the callable.callable - the callable to execute on the client side.Exception - if the execution of the callable in the client resulted in a Throwable being raised.JPPFCallableCopyright © 2005-2012 JPPF Team.