Class NodeTaskWrapper

java.lang.Object
org.jppf.execute.NodeTaskWrapper
All Implemented Interfaces:
Runnable

public class NodeTaskWrapper extends Object implements 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 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 implements Future interface.
      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.
      Specified by:
      run in interface Runnable
    • getTask

      public Task<?> getTask()
      Get the task this wrapper executes within a try/catch block.
      Returns:
      the task as a Task instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFuture

      public Future<?> getFuture()
      Get the future created by the executor service.
      Returns:
      an instance of Future.
    • setFuture

      public void setFuture(Future<?> future)
      Set the future created by the executor service.
      Parameters:
      future - an instance of Future.
    • cancelTimeoutAction

      public void cancelTimeoutAction()
      Remove the specified future from the pending set and notify all threads waiting for the end of the execution.
    • getExecutionInfo

      public ExecutionInfo getExecutionInfo()
      Get trhe object that holds the used cpu time for this task.
      Returns:
      a ExecutionInfo instance.
    • getElapsedTime

      public long getElapsedTime()
      Get the elapsed time for this task's execution.
      Returns:
      the elapsed time in nanoseconds.
    • getJobEntry

      public JobProcessingEntry 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.