Package org.jppf.server.queue
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
-
Field Summary
Fields inherited from class org.jppf.queue.AbstractJPPFQueue
jobMap, latestMaxSize, lock, priorityMap, queueListeners, sizeMap -
Constructor Summary
ConstructorsConstructorDescriptionJPPFPriorityQueue(JPPFDriver driver, JPPFJobManager jobManager) Initialize this queue. -
Method Summary
Modifier and TypeMethodDescriptionaddBundle(ServerTaskBundleClient clientBundle) voidaddJobListener(org.jppf.job.JobManagerListener listener) Add a listener to the list of listeners.booleanCancel the job with the specified UUIDvoidclose()Close this queue and all the resources it uses.Get the set of ids for all the jobs currently queued or executing.Get the set of ids for all the jobs currently queued or executing.Get the set of all the jobs currently queued or executing.Get all the jobs in the queue, ordered by priority.Get the objects wich manages operations on broadcast jobs.getBundleForJob(String jobUuid) Get the job for the job unique identifier.Get the job for the jobId.getJobFromPriorityMap(String jobId) Get the job for the jobId.protected intnextBundle(ServerJob serverJob, int nbTasks, org.jppf.execute.ExecutorChannel<ServerTaskBundleNode> channel) removeBundle(ServerJob serverJob) removeBundle(ServerJob serverJob, boolean removeFromJobMap) Remove the specified bundle from the queue.voidremoveJobListener(org.jppf.job.JobManagerListener listener) Remove a listener from the list of listeners.selectJobs(org.jppf.job.JobSelector selector) Select the jobs specified by a given job selector.voidsetCallableAllConnections(Callable<List<BaseNodeContext>> callableAllConnections) Set the callable source for all available connections.voidupdatePriority(String jobUuid, int newPriority) Update the priority of the job with the specified uuid.voidupdateSchedules(ServerJob job) Update the start and expiration schedules of an existing job.voidupdateWorkingConnections(org.jppf.execute.ExecutorStatus oldStatus, org.jppf.execute.ExecutorStatus newStatus) Update count of working connections base on status change.Methods inherited from class org.jppf.queue.AbstractJPPFQueue
addQueueListener, decrementSizeCount, fireBundleAdded, fireBundleRemoved, getLock, getMaxBundleSize, getQueueSize, incrementSizeCount, isEmpty, iterator, removeQueueListener, updateLatestMaxSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
JPPFPriorityQueue
Initialize this queue.- Parameters:
driver- reference to the driver.jobManager- the job manager.
-
-
Method Details
-
addBundle
- Specified by:
addBundlein interfaceorg.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient, ServerTaskBundleNode>
-
nextBundle
public ServerTaskBundleNode nextBundle(ServerJob serverJob, int nbTasks, org.jppf.execute.ExecutorChannel<ServerTaskBundleNode> channel) - Specified by:
nextBundlein interfaceorg.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient, ServerTaskBundleNode>
-
removeBundle
- Specified by:
removeBundlein interfaceorg.jppf.queue.JPPFQueue<ServerJob,ServerTaskBundleClient, ServerTaskBundleNode>
-
removeBundle
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
Description copied from interface:JobManagerUpdate the priority of the job with the specified uuid.- Specified by:
updatePriorityin interfaceJobManager- Parameters:
jobUuid- the uuid of the job to re-prioritize.newPriority- the new priority of the job.
-
cancelJob
Description copied from interface:JobManagerCancel the job with the specified UUID- Specified by:
cancelJobin interfaceJobManager- 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
Get the job for the jobId.- Parameters:
jobId- the uuid of the job.- Returns:
- a
ServerJobinstance.
-
getJobFromPriorityMap
Get the job for the jobId.- Parameters:
jobId- the uuid of the job.- Returns:
- a
ServerJobinstance.
-
getAllJobIds
Get the set of ids for all the jobs currently queued or executing.- Specified by:
getAllJobIdsin interfaceJobManager- Returns:
- a set of ids as strings.
-
getAllJobs
Get the set of all the jobs currently queued or executing.- Returns:
- a list of
ServerJobinstances.
-
getAllJobIdsFromPriorityMap
Get the set of ids for all the jobs currently queued or executing.- Returns:
- a set of ids as strings.
-
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:JobManagerAdd a listener to the list of listeners.- Specified by:
addJobListenerin interfaceJobManager- Parameters:
listener- the listener to add to the list.
-
removeJobListener
public void removeJobListener(org.jppf.job.JobManagerListener listener) Description copied from interface:JobManagerRemove a listener from the list of listeners.- Specified by:
removeJobListenerin interfaceJobManager- Parameters:
listener- the listener to remove from the list.
-
getBundleForJob
Description copied from interface:JobManagerGet the job for the job unique identifier.- Specified by:
getBundleForJobin interfaceJobManager- Parameters:
jobUuid- the uuid of the job.- Returns:
- a
ServerJobinstance.
-
getSize
- Specified by:
getSizein classorg.jppf.queue.AbstractJPPFQueue<ServerJob,ServerTaskBundleClient, ServerTaskBundleNode>
-
setCallableAllConnections
Set the callable source for all available connections.- Parameters:
callableAllConnections- aCallableinstance.
-
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
Select the jobs specified by a given job selector.- Parameters:
selector- determines for which jobs to return.- Returns:
- a list of
ServerJobobejcts, possibly empty.
-
updateSchedules
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
Get the objects wich manages operations on broadcast jobs.- Returns:
- a
BroadcastManagerinstance.
-
getPersistenceHandler
- Returns:
- the persistence handler.
-
getDependenciesHandler
- Returns:
- the job dependency graph handler.
-