T
- the type of results produced by the task.public interface Task<T> extends Runnable, Serializable, Interruptibility
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 . |
Task<T> |
fireNotification(Object userObject,
boolean sendViaJmx)
Causes the task to send a notification to all listeners.
|
DataProvider |
getDataProvider()
Get the provider of shared data for this task.
|
String |
getId()
Get the user-assigned id for this task.
|
int |
getMaxResubmits()
Get the maximum number of times a task can resubmit itself.
|
Node |
getNode()
Get the node this task is executing in, if any.
|
T |
getResult()
Get the result of the task execution.
|
Object |
getTaskObject()
Get the
JPPFRunnable -annotated object or POJO wrapped by this task. |
Throwable |
getThrowable()
Get the Throwable that was raised by this task's execution.
|
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.
|
boolean |
isResubmit()
Determine whether this task should be resubmitted by the server.
|
void |
onCancel()
Callback invoked when this task is cancelled.
|
void |
onTimeout()
Callback invoked when this task times out.
|
Task<T> |
setId(String id)
Set the user-assigned id for this task.
|
Task<T> |
setMaxResubmits(int maxResubmits)
Set the maximum number of times a task can resubmit itself.
|
Task<T> |
setResubmit(boolean resubmit)
Specify whether this task should be resubmitted by the server.
|
Task<T> |
setResult(T result)
Set the result of the task execution.
|
Task<T> |
setThrowable(Throwable throwable)
Sets the Throwable that was raised by this task's execution in the
run() method. |
Task<T> |
setTimeoutSchedule(JPPFSchedule timeoutSchedule)
Get the task timeout schedule configuration.
|
isInterruptible
Task<T> setResult(T result)
result
- the result of this task's execution.Throwable getThrowable()
Throwable
instance, or null
if no exception was raised.Task<T> setThrowable(Throwable throwable)
run()
method.
The Throwable is normally set by the JPPF framework.throwable
- a Throwable
instance.DataProvider getDataProvider()
DataProvider
instance.Task<T> setId(String id)
id
- the id as a string.void onCancel()
void onTimeout()
Object getTaskObject()
JPPFRunnable
-annotated object or POJO wrapped by this task.JPPFSchedule getTimeoutSchedule()
JPPFSchedule
instance.Task<T> setTimeoutSchedule(JPPFSchedule timeoutSchedule)
timeoutSchedule
- a JPPFSchedule
instance.boolean isInNode()
true
if this task is executing in a node, false
if it is on the client side.<V> V compute(JPPFCallable<V> callable) throws Exception
JPPFCallable
.
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
.
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.Task<T> fireNotification(Object userObject, boolean sendViaJmx)
Runnable.run()
, Task.onTimeout()
or Task.onCancel()
methods.
If the parameter sendViaJmx
is true
, then a notfication will also be sent
by the JPPFNodeTaskMonitorMBean
mbean, otherwise only local listeners will be notified.
userObject
- a user-defined object to send as part of the notification.sendViaJmx
- if true
then also send the notification via the JMX MBean, otherwise only send to local listeners.
If the task is executing within a client local executor, this parameter has no effect.boolean isResubmit()
true
to indicate this task will be resubmitted, false
otherwise.Task<T> setResubmit(boolean resubmit)
resubmit
- true
to indicate this task will be resubmitted, false
otherwise.int getMaxResubmits()
Task<T> setMaxResubmits(int maxResubmits)
JobSLA.getMaxTaskResubmits()
.maxResubmits
- the maximum number of resubmits.Copyright © 2005-2018 JPPF Team.