Class ClientJob


public class ClientJob extends AbstractClientJob
Author:
Martin JANDA, Laurent Cohen
  • Field Details

    • initialTaskCount

      protected final int initialTaskCount
      The original number of tasks in the job.
  • Constructor Details

    • ClientJob

      public ClientJob(JPPFJob job, Collection<org.jppf.node.protocol.Task<?>> tasks)
      Initialized client job with task bundle and list of tasks to execute.
      Parameters:
      job - underlying task bundle.
      tasks - list of tasks to execute.
    • ClientJob

      protected ClientJob(JPPFJob job, Collection<org.jppf.node.protocol.Task<?>> tasks, ClientJob parentJob, String broadcastUUID)
      Initialized client job with task bundle and list of tasks to execute.
      Parameters:
      job - underlying task bundle.
      tasks - list of tasks to execute.
      parentJob - instance of parent broadcast job.
      broadcastUUID - the broadcast UUID, i.e. the uuid of the connection the job is broadcast to.
  • Method Details

    • getTaskCount

      public int getTaskCount()
      Get the current number of tasks in the job.
      Returns:
      the number of tasks as an int.
    • createBroadcastJob

      public ClientJob createBroadcastJob(String broadcastUUID)
      Make a copy of this client job wrapper.
      Parameters:
      broadcastUUID - the broadcast UUID, i.e. the uuid of the connection the job is broadcast to.
      Returns:
      a new ClientJob instance.
    • copy

      public ClientTaskBundle copy(int nbTasks)
      Make a copy of this client job wrapper containing only the first nbTasks tasks it contains.
      Parameters:
      nbTasks - the number of tasks to include in the copy.
      Returns:
      a new ClientJob instance.
    • merge

      protected boolean merge(List<org.jppf.node.protocol.Task<?>> taskList)
      Merge this client job wrapper with another.
      Parameters:
      taskList - list of tasks to merge.
      Returns:
      true when this client job needs to be requeued.
    • getBroadcastUUID

      public String getBroadcastUUID()
      Get the broadcast UUID.
      Returns:
      an String instance.
    • jobDispatched

      public void jobDispatched(ClientTaskBundle bundle, ChannelWrapper channel)
      Called when all or part of a job is dispatched to a node.
      Parameters:
      bundle - the dispatched job.
      channel - the node to which the job is dispatched.
    • jobRequeued

      public void jobRequeued()
      Notify that this job was requeued.
    • resultsReceived

      public void resultsReceived(ClientTaskBundle bundle, List<org.jppf.node.protocol.Task<?>> results)
      Called to notify that the results of a number of tasks have been received from the server.
      Parameters:
      bundle - the executing job.
      results - the list of tasks whose results have been received from the server.
    • resultsReceived

      public void resultsReceived(ClientTaskBundle bundle, Throwable throwable)
      Called to notify that throwable eventually raised while receiving the results.
      Parameters:
      bundle - the finished job.
      throwable - the throwable that was raised while receiving the results.
    • taskCompleted

      public void taskCompleted(ClientTaskBundle bundle, Exception exception)
      Called to notify that the execution of a task has completed.
      Parameters:
      bundle - the completed task.
      exception - the Exception thrown during job execution or null.
    • hasPending

      protected boolean hasPending()
      Get indicator whether job has pending tasks.
      Returns:
      true when job has some pending tasks.
    • getJobStatus

      public JobStatus getJobStatus()
      Get the status of this job.
      Returns:
      a JobStatus enumerated value.
    • setJobStatus

      public void setJobStatus(JobStatus jobStatus)
      Set the status of this job.
      Parameters:
      jobStatus - a JobStatus enumerated value.
    • cancel

      public boolean cancel(boolean mayInterruptIfRunning)
      Description copied from class: AbstractClientJob
      Cancels this job.
      Overrides:
      cancel in class AbstractClientJob
      Parameters:
      mayInterruptIfRunning - true if the thread executing this task should be interrupted.
      Returns:
      whether cancellation was successful.
    • broadcastDispatched

      protected void broadcastDispatched(ClientJob broadcastJob)
      Called when all or part of broadcast job is dispatched to a driver.
      Parameters:
      broadcastJob - the dispatched job.
    • broadcastCompleted

      protected void broadcastCompleted(ClientJob broadcastJob)
      Called to notify that the execution of broadcast job has completed.
      Parameters:
      broadcastJob - the completed job.
    • setOnRequeue

      public void setOnRequeue(Runnable onRequeue)
      Set the requeue handler.
      Parameters:
      onRequeue - Runnable executed on requeue.
    • getNbChannels

      public int getNbChannels()
      Get count of channels on which this job is executed.
      Returns:
      the number used for job execution.
    • toString

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

      public org.jppf.node.protocol.graph.TaskGraph getTaskGraph()
      Returns:
      the graph of tasks in the job, if any.
    • hasAvvailableGraphNode

      public boolean hasAvvailableGraphNode()
      Returns:
      true if there is a graph and an available node in the graph, false otherwise.
    • getAvailableGraphNodeCount

      public int getAvailableGraphNodeCount()
      Returns:
      the number of nodes int he graph that can be executed.