Package org.jppf.execute
Class NodeTaskWrapper
java.lang.Object
org.jppf.execute.NodeTaskWrapper
- All Implemented Interfaces:
Runnable
Wrapper around a JPPF task used to catch exceptions caused by the task execution.
- Author:
- Domingos Creado, Laurent Cohen, Martin JANDA, Paul Woodward
-
Constructor Summary
ConstructorsConstructorDescriptionNodeTaskWrapper(JobProcessingEntry jobEntry, Task<?> task, ClassLoader taskClassLoader, JPPFScheduleHandler timeoutHandler) Initialize this task wrapper with a specified JPPF task.NodeTaskWrapper(Task<?> task, ClassLoader taskClassLoader, JPPFScheduleHandler timeoutHandler) Initialize this task wrapper with a specified JPPF task. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel(boolean callOnCancel) Set cancel indicator and cancel task when it implementsFutureinterface.voidRemove the specified future from the pending set and notify all threads waiting for the end of the execution.longGet the elapsed time for this task's execution.Get trhe object that holds the used cpu time for this task.Future<?>Get the future created by the executor service.Task<?>getTask()Get the task this wrapper executes within a try/catch block.booleanvoidrun()Execute the task within a try/catch block.voidSet the future created by the executor service.voidcalled when a task terminates.toString()
-
Constructor Details
-
NodeTaskWrapper
public NodeTaskWrapper(Task<?> task, ClassLoader taskClassLoader, JPPFScheduleHandler timeoutHandler) Initialize this task wrapper with a specified JPPF task.- Parameters:
task- the task to execute within a try/catch block.taskClassLoader- the class loader that was used to load the task class.timeoutHandler- handles the timeout for this task.
-
NodeTaskWrapper
public NodeTaskWrapper(JobProcessingEntry jobEntry, Task<?> task, ClassLoader taskClassLoader, JPPFScheduleHandler timeoutHandler) Initialize this task wrapper with a specified JPPF task.- Parameters:
jobEntry- encapsulates information about the job the task is a part of.task- the task to execute within a try/catch block.taskClassLoader- the class loader that was used to load the task class.timeoutHandler- handles the timeout for this task.
-
-
Method Details
-
cancel
public void cancel(boolean callOnCancel) Set cancel indicator and cancel task when it implementsFutureinterface.- Parameters:
callOnCancel- determines whether the onCancel() callback method of each task should be invoked.
-
run
public void run()Execute the task within a try/catch block. -
getTask
Get the task this wrapper executes within a try/catch block.- Returns:
- the task as a
Taskinstance.
-
toString
-
getFuture
Get the future created by the executor service.- Returns:
- an instance of
Future.
-
setFuture
Set the future created by the executor service.- Parameters:
future- an instance ofFuture.
-
cancelTimeoutAction
public void cancelTimeoutAction()Remove the specified future from the pending set and notify all threads waiting for the end of the execution. -
getExecutionInfo
Get trhe object that holds the used cpu time for this task.- Returns:
- a
ExecutionInfoinstance.
-
getElapsedTime
public long getElapsedTime()Get the elapsed time for this task's execution.- Returns:
- the elapsed time in nanoseconds.
-
getJobEntry
- Returns:
- the object which encapsulates information about the job the task is a part of.
-
taskEnded
public void taskEnded()called when a task terminates. -
hasStarted
public boolean hasStarted()- Returns:
- whether the task has started.
-