Class AbstractServerJob

java.lang.Object
org.jppf.server.protocol.AbstractServerJob
All Implemented Interfaces:
org.jppf.node.protocol.JPPFDistributedJob
Direct Known Subclasses:
AbstractServerJobBase

public abstract class AbstractServerJob extends Object implements org.jppf.node.protocol.JPPFDistributedJob
Abstract class that support job state management.
Author:
Martin JANDA
  • Field Details

    • id

      protected final long id
      A unique id for this client bundle.
    • status

      protected AtomicReference<ServerJobStatus> status
      The job status.
    • onDoneList

      protected final List<Runnable> onDoneList
      List of all runnables called on job completion.
    • jobReceivedTime

      protected long jobReceivedTime
      Time at which the job is received on the server side. In milliseconds since January 1, 1970 UTC.
    • queueEntryTime

      protected transient long queueEntryTime
      The time at which this wrapper was added to the queue.
    • job

      protected final org.jppf.node.protocol.TaskBundle job
      The underlying task bundle.
    • uuid

      protected String uuid
      The universal unique id for this job.
    • name

      protected String name
      The user-defined display name for this job.
    • jobExpired

      protected boolean jobExpired
      Job expired indicator, determines whether the job is should be cancelled.
    • pending

      protected boolean pending
      Job pending indicator, determines whether the job is waiting for its scheduled time to start.
    • lock

      protected final Lock lock
      Used for synchronized access to job.
    • removalCondition

      protected final org.jppf.utils.concurrent.ThreadSynchronization removalCondition
      Condition signalled when this job is removed from the queue.
    • submissionStatus

      protected final org.jppf.utils.concurrent.SynchronizedReference<SubmissionStatus> submissionStatus
      The status of this submission.
    • notificationEmitter

      protected ServerJobChangeListener notificationEmitter
      Handler for job state notifications.
    • completionBundles

      protected List<ServerTaskBundleClient> completionBundles
      List of bundles added after submission status set to COMPLETE.
  • Constructor Details

    • AbstractServerJob

      protected AbstractServerJob(Lock lock, org.jppf.node.protocol.TaskBundle job)
      Initialized abstract client job with task bundle and list of tasks to execute.
      Parameters:
      lock - used to synchronized access to job.
      job - underlying task bundle.
  • Method Details

    • getJob

      public org.jppf.node.protocol.TaskBundle getJob()
      Get the underlying task bundle.
      Returns:
      a ClientTaskBundle instance.
    • getUuid

      public String getUuid()
      Get the universal unique id for this job.
      Specified by:
      getUuid in interface org.jppf.node.protocol.JPPFDistributedJob
      Returns:
      the uuid as a string.
    • setUuid

      public void setUuid(String uuid)
      Set the universal unique id for this job.
      Parameters:
      uuid - the universal unique id.
    • getName

      public String getName()
      Get the user-defined display name for this job. This is the name displayed in the administration console.
      Specified by:
      getName in interface org.jppf.node.protocol.JPPFDistributedJob
      Returns:
      the name as a string.
    • setName

      public void setName(String name)
      Set the user-defined display name for this job.
      Parameters:
      name - the display name as a string.
    • getSLA

      public org.jppf.node.protocol.JobSLA getSLA()
      Get the service level agreement between the job and the server.
      Specified by:
      getSLA in interface org.jppf.node.protocol.JPPFDistributedJob
      Returns:
      an instance of JobSLA.
    • getMetadata

      public org.jppf.node.protocol.JobMetadata getMetadata()
      Get the job metadata.
      Specified by:
      getMetadata in interface org.jppf.node.protocol.JPPFDistributedJob
      Returns:
      an instance of JobMetadata.
    • setMetadata

      public void setMetadata(org.jppf.node.protocol.JobMetadata metadata)
      Set the job metadata.
      Parameters:
      metadata - an instance of JobMetadata.
    • setSLA

      public void setSLA(org.jppf.node.protocol.JobSLA sla)
      Get the service level agreement between the job and the server.
      Parameters:
      sla - an instance of JobSLA.
    • isJobExpired

      public boolean isJobExpired()
      Get the job expired indicator.
      Returns:
      true if job has expired, false otherwise.
    • jobExpired

      public void jobExpired()
      Sets and notifies that job has expired.
    • isPending

      public boolean isPending()
      Get the job pending indicator.
      Returns:
      true if job is pending, false otherwise.
    • setPending

      public void setPending(boolean pending)
      Set the job pending indicator.
      Parameters:
      pending - true to indicate that job is pending, false otherwise
    • isSuspended

      public boolean isSuspended()
      Get the job suspended indicator.
      Returns:
      true if job is suspended, false otherwise.
    • setSuspended

      public void setSuspended(boolean suspended, boolean requeue)
      Set the job suspended indicator.
      Parameters:
      suspended - true to indicate that job is suspended, false otherwise.
      requeue - true to indicate that job should be requeued, false otherwise.
    • setMaxNodes

      public void setMaxNodes(int maxNodes)
      Set the maximum number of nodes this job can run on.
      Parameters:
      maxNodes - the number of nodes as an int value. A value <= 0 means no limit on the number of nodes.
    • updateStatus

      protected final boolean updateStatus(ServerJobStatus expect, ServerJobStatus newStatus)
      Updates status to new value if old value is equal to expect.
      Parameters:
      expect - the expected value.
      newStatus - the new value.
      Returns:
      true if new status was set.
    • isCancelled

      public boolean isCancelled()
      Returns:
      true when job was cancelled.
    • setCancelled

      public boolean setCancelled(boolean mayInterruptIfRunning)
      Cancels this job.
      Parameters:
      mayInterruptIfRunning - true if the thread executing this task should be interrupted.
      Returns:
      whether cancellation was successful.
    • done

      protected void done()
      Called when task was cancelled or finished.
    • addOnDone

      public void addOnDone(Runnable runnable)
      Registers instance to be called on job finish.
      Parameters:
      runnable - Runnable to be called on job finish.
    • removeOnDone

      public void removeOnDone(Runnable runnable)
      Deregisters instance to be called on job finish.
      Parameters:
      runnable - Runnable to be called on job finish.
    • getJobReceivedTime

      public long getJobReceivedTime()
      Get the job received time.
      Returns:
      the time in milliseconds as a long value.
    • setJobReceivedTime

      public void setJobReceivedTime(long jobReceivedTime)
      Set the job received time.
      Parameters:
      jobReceivedTime - the time in milliseconds as a long value.
    • getQueueEntryTime

      public long getQueueEntryTime()
      Get the time at which this wrapper was added to the queue.
      Returns:
      the time in milliseconds as a long value.
    • setQueueEntryTime

      public void setQueueEntryTime(long queueEntryTime)
      Set the time at which this wrapper was added to the queue.
      Parameters:
      queueEntryTime - the time in milliseconds as a long value.
    • getTaskCount

      public abstract int getTaskCount()
      Specified by:
      getTaskCount in interface org.jppf.node.protocol.JPPFDistributedJob
    • getInitialTaskCount

      public int getInitialTaskCount()
      Get the initial task count.
      Returns:
      the count as an int.
    • getSubmissionStatus

      public SubmissionStatus getSubmissionStatus()
      Get the status of this submission.
      Returns:
      a SubmissionStatus enumerated value.
    • setSubmissionStatus

      public void setSubmissionStatus(SubmissionStatus newStatus)
      Set the status of this submission.
      Parameters:
      newStatus - a SubmissionStatus enumerated value.
    • getBroadcastUUID

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

      public List<ServerTaskBundleClient> getCompletionBundles()
      Get list of bundles added after job completion.
      Returns:
      list of bundles added after job completion.
    • fireJobUpdated

      public void fireJobUpdated(boolean headerUpdated)
      The current number of tasks in a job was updated.
      Parameters:
      headerUpdated - whether the job header(a TaskBundle instance) has been updated.
    • fireJobDispatched

      protected void fireJobDispatched(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode)
      A sub-job was dispatched to a node.
      Parameters:
      channel - the node to which the job is dispatched.
      bundleNode - the bundle for job event.
    • fireJobReturned

      protected void fireJobReturned(org.jppf.execute.ExecutorChannel<?> channel, ServerTaskBundleNode bundleNode)
      A sub-job returned from a node.
      Parameters:
      channel - the node from which the job is returned.
      bundleNode - the bundle for job event.
    • getLock

      public Lock getLock()
      Get the lock used for synchronized access to job.
      Returns:
      a Lock object.
    • updateJobDataLocation

      public void updateJobDataLocation()
      Serialize the updated job header and cache the resulting serialized representation.
    • isPersistent

      public boolean isPersistent()
      Returns:
      whether this job is persisted in the driver.
    • getRemovalCondition

      public org.jppf.utils.concurrent.ThreadSynchronization getRemovalCondition()
      Returns:
      a Condition that is signalled when this job is removed from the queue