Class ServerTask

java.lang.Object
org.jppf.server.protocol.ServerTask
All Implemented Interfaces:
Serializable, org.jppf.node.protocol.PositionalElement<ServerTask>

public class ServerTask extends Object implements Serializable, org.jppf.node.protocol.PositionalElement<ServerTask>
Representation of an individual task on the server side.
Author:
Martin JANDA
See Also:
  • Constructor Details

    • ServerTask

      public ServerTask(ServerTaskBundleClient bundle, org.jppf.io.DataLocation initialTask, int jobPosition, int maxResubmits)
      Parameters:
      bundle - client bundle that owns this task.
      initialTask - the initial serialized task.
      jobPosition - the maximum number of times a task can be resubmitted.
      maxResubmits - the position of this task within the job submitted by the client.
  • Method Details

    • getBundle

      public ServerTaskBundleClient getBundle()
      Get the client bundle that owns this task.
      Returns:
      ServerTaskBundleClient instance.
    • setBundle

      public void setBundle(ServerTaskBundleClient bundle)
      Get the client bundle that owns this task.
      Parameters:
      bundle - a ServerTaskBundleClient instance.
    • getInitialTask

      public org.jppf.io.DataLocation getInitialTask()
      Get the initial serialized task.
      Returns:
      a DataLocation instance.
    • getState

      public org.jppf.node.protocol.TaskState getState()
      Get the state of this task.
      Returns:
      a TaskState enumerated value.
    • setState

      public void setState(org.jppf.node.protocol.TaskState state)
      Set the state of this task.
      Parameters:
      state - a TaskState enumerated value.
    • getResult

      public org.jppf.io.DataLocation getResult()
      Get the result of the task execution.
      Returns:
      the result as a DataLocation.
    • setResult

      public void setResult(org.jppf.io.DataLocation result)
      Set the result of the task execution.
      Parameters:
      result - the result as a DataLocation.
    • getThrowable

      public Throwable getThrowable()
      Get the eventual throwable raised during the processing of this task in the driver.
      Returns:
      a Throwable instance, or null if no exception was raised.
    • cancel

      public void cancel()
      Mark this task as cancelled.
    • resubmit

      public void resubmit()
      Mark this task as to be resubmitted followxing expiration of a node dispatch.
    • resultReceived

      public void resultReceived(org.jppf.io.DataLocation result)
      Called to notify that the task received result.
      Parameters:
      result - the result.
    • broadcastResultReceived

      public void broadcastResultReceived()
      Called to notify that the task broadcast was completed.
    • resultReceived

      public void resultReceived(Throwable exception)
      Called to notify that the task received exception during execution.
      Parameters:
      exception - the exception.
    • toString

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

      public int getPosition()
      Specified by:
      getPosition in interface org.jppf.node.protocol.PositionalElement<ServerTask>
    • incExpirationCount

      public int incExpirationCount()
      Increment and get the number of times a dispatch of this task has expired.
      Returns:
      the new number of expirations as an int.
    • getExpirationCount

      public int getExpirationCount()
      Get the number of times a dispatch of this task has expired.
      Returns:
      the new number of expirations as an int.
    • isDone

      public boolean isDone()
      Determine whether this task has completed. This encompasses the cases where it received a result, was cancelled or terminated with an exception.
      Returns:
      true if this task is done, false otherwise.
    • getTaskResubmitCount

      public int getTaskResubmitCount()
      Get the number of times a task resubmitted itself.
      Returns:
      the number of resubmits as an int.
    • incResubmitCount

      public int incResubmitCount()
      Increment and get the number of times a task resubmitted itself.
      Returns:
      the new number of resubmits as an int.
    • getMaxResubmits

      public int getMaxResubmits()
      Get the maximum number of times a task can be resubmitted.
      Returns:
      the maximum number of reesubmits as an int.
    • isReturnedFromNode

      public boolean isReturnedFromNode()
      Returns:
      whether this task has returned from the node
    • setReturnedFromNode

      public void setReturnedFromNode(boolean returnedFromNode)
      Set whether this task has returned from the node
      Parameters:
      returnedFromNode - true if this task has returned from a node, false otherwise.