Class JPPFPriorityQueue

java.lang.Object
org.jppf.queue.AbstractJPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>
org.jppf.server.queue.JPPFPriorityQueue
All Implemented Interfaces:
Iterable<ServerJob>, org.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>, JobManager

public class JPPFPriorityQueue extends org.jppf.queue.AbstractJPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode> implements JobManager
A JPPF queue whose elements are ordered by decreasing priority.
Author:
Laurent Cohen, Martin JANDA
  • Constructor Details

    • JPPFPriorityQueue

      public JPPFPriorityQueue(JPPFDriver driver, JPPFJobManager jobManager)
      Initialize this queue.
      Parameters:
      driver - reference to the driver.
      jobManager - the job manager.
  • Method Details

    • addBundle

      public ServerJob addBundle(ServerTaskBundleClient clientBundle)
      Specified by:
      addBundle in interface org.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>
    • nextBundle

      public ServerTaskBundleNode nextBundle(ServerJob serverJob, int nbTasks, org.jppf.execute.ExecutorChannel<ServerTaskBundleNode> channel)
      Specified by:
      nextBundle in interface org.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>
    • removeBundle

      public ServerJob removeBundle(ServerJob serverJob)
      Specified by:
      removeBundle in interface org.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>
    • removeBundle

      public ServerJob removeBundle(ServerJob serverJob, boolean removeFromJobMap)
      Remove the specified bundle from the queue.
      Parameters:
      serverJob - the bundle to remove.
      removeFromJobMap - flag whether bundle should be removed from job map.
      Returns:
      the removed bundle.
    • updatePriority

      public void updatePriority(String jobUuid, int newPriority)
      Description copied from interface: JobManager
      Update the priority of the job with the specified uuid.
      Specified by:
      updatePriority in interface JobManager
      Parameters:
      jobUuid - the uuid of the job to re-prioritize.
      newPriority - the new priority of the job.
    • cancelJob

      public boolean cancelJob(String jobId)
      Description copied from interface: JobManager
      Cancel the job with the specified UUID
      Specified by:
      cancelJob in interface JobManager
      Parameters:
      jobId - the uuid of the job to cancel.
      Returns:
      whether cancellation was successful.
    • close

      public void close()
      Close this queue and all the resources it uses.
    • getJob

      public ServerJob getJob(String jobId)
      Get the job for the jobId.
      Parameters:
      jobId - the uuid of the job.
      Returns:
      a ServerJob instance.
    • getJobFromPriorityMap

      public ServerJob getJobFromPriorityMap(String jobId)
      Get the job for the jobId.
      Parameters:
      jobId - the uuid of the job.
      Returns:
      a ServerJob instance.
    • getAllJobIds

      public Set<String> getAllJobIds()
      Get the set of ids for all the jobs currently queued or executing.
      Specified by:
      getAllJobIds in interface JobManager
      Returns:
      a set of ids as strings.
    • getAllJobs

      public List<ServerJob> getAllJobs()
      Get the set of all the jobs currently queued or executing.
      Returns:
      a list of ServerJob instances.
    • getAllJobIdsFromPriorityMap

      public Set<String> getAllJobIdsFromPriorityMap()
      Get the set of ids for all the jobs currently queued or executing.
      Returns:
      a set of ids as strings.
    • getAllJobsFromPriorityMap

      public List<ServerJob> getAllJobsFromPriorityMap()
      Get all the jobs in the queue, ordered by priority.
      Returns:
      a list of server-side jobs. The returned list is completely independant from this queue and can be modified without affecting this queue.
    • addJobListener

      public void addJobListener(org.jppf.job.JobManagerListener listener)
      Description copied from interface: JobManager
      Add a listener to the list of listeners.
      Specified by:
      addJobListener in interface JobManager
      Parameters:
      listener - the listener to add to the list.
    • removeJobListener

      public void removeJobListener(org.jppf.job.JobManagerListener listener)
      Description copied from interface: JobManager
      Remove a listener from the list of listeners.
      Specified by:
      removeJobListener in interface JobManager
      Parameters:
      listener - the listener to remove from the list.
    • getBundleForJob

      public ServerJob getBundleForJob(String jobUuid)
      Description copied from interface: JobManager
      Get the job for the job unique identifier.
      Specified by:
      getBundleForJob in interface JobManager
      Parameters:
      jobUuid - the uuid of the job.
      Returns:
      a ServerJob instance.
    • getSize

      protected int getSize(ServerJob job)
      Specified by:
      getSize in class org.jppf.queue.AbstractJPPFQueue<ServerJob,ServerTaskBundleClient,ServerTaskBundleNode>
    • setCallableAllConnections

      public void setCallableAllConnections(Callable<List<BaseNodeContext>> callableAllConnections)
      Set the callable source for all available connections.
      Parameters:
      callableAllConnections - a Callable instance.
    • updateWorkingConnections

      public void updateWorkingConnections(org.jppf.execute.ExecutorStatus oldStatus, org.jppf.execute.ExecutorStatus newStatus)
      Update count of working connections base on status change.
      Parameters:
      oldStatus - the connection status before the change.
      newStatus - the connection status after the change.
    • selectJobs

      public List<ServerJob> selectJobs(org.jppf.job.JobSelector selector)
      Select the jobs specified by a given job selector.
      Parameters:
      selector - determines for which jobs to return.
      Returns:
      a list of ServerJob obejcts, possibly empty.
    • updateSchedules

      public void updateSchedules(ServerJob job)
      Update the start and expiration schedules of an existing job. Normally called when a job's SLA is updated.
      Parameters:
      job - the job to update.
    • getBroadcastManager

      public BroadcastManager getBroadcastManager()
      Get the objects wich manages operations on broadcast jobs.
      Returns:
      a BroadcastManager instance.
    • getPersistenceHandler

      public PersistenceHandler getPersistenceHandler()
      Returns:
      the persistence handler.
    • getDependenciesHandler

      public JobDependenciesHandler getDependenciesHandler()
      Returns:
      the job dependency graph handler.