Package org.jppf.client.balancer.queue
Class JPPFPriorityQueue
java.lang.Object
org.jppf.queue.AbstractJPPFQueue<ClientJob,ClientJob,ClientTaskBundle>
org.jppf.client.balancer.queue.JPPFPriorityQueue
- All Implemented Interfaces:
Iterable<ClientJob>,org.jppf.queue.JPPFQueue<ClientJob,ClientJob, ClientTaskBundle>
public class JPPFPriorityQueue
extends org.jppf.queue.AbstractJPPFQueue<ClientJob,ClientJob,ClientTaskBundle>
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an object to the queue, and notify all listeners about it.voidcancelBroadcastJobs(String connectionUUID) Cancels queued broadcast jobs for connection.booleanCancel the job with the specified UUID.voidclose()Close this queue and all resources it uses.Get all theJPPFJobs currently in the queue.protected intGet the bundle size to use for bundle size tuning.booleanisEmpty()nextBundle(ClientJob job, int nbTasks, org.jppf.execute.ExecutorChannel<ClientTaskBundle> channel) voidProcess the jobs in the pending broadcast queue.removeBundle(ClientJob job) protected voidHandle requeue of the specified job.voidupdatePriority(String jobUuid, int newPriority) Update the priority of the job with the specified uuid.Methods inherited from class org.jppf.queue.AbstractJPPFQueue
addQueueListener, decrementSizeCount, fireBundleAdded, fireBundleRemoved, getLock, getMaxBundleSize, getQueueSize, incrementSizeCount, 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:
jobManager- reference to job manager.
-
-
Method Details
-
addBundle
Add an object to the queue, and notify all listeners about it.- Parameters:
clientJob- the object to add to the queue.
-
requeue
Handle requeue of the specified job.- Parameters:
job- the job to requeue.
-
nextBundle
public ClientTaskBundle nextBundle(ClientJob job, int nbTasks, org.jppf.execute.ExecutorChannel<ClientTaskBundle> channel) -
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceorg.jppf.queue.JPPFQueue<ClientJob,ClientJob, ClientTaskBundle> - Overrides:
isEmptyin classorg.jppf.queue.AbstractJPPFQueue<ClientJob,ClientJob, ClientTaskBundle>
-
getSize
Get the bundle size to use for bundle size tuning.- Specified by:
getSizein classorg.jppf.queue.AbstractJPPFQueue<ClientJob,ClientJob, ClientTaskBundle> - Parameters:
job- the bundle to get the size from.- Returns:
- the bundle size as an int.
-
removeBundle
-
updatePriority
Update the priority of the job with the specified uuid.- Parameters:
jobUuid- the uuid of the job to re-prioritize.newPriority- the new priority of the job.
-
cancelJob
Cancel the job with the specified UUID.- Parameters:
jobId- the uuid of the job to cancel.- Returns:
- whether cancellation was successful.
-
close
public void close()Close this queue and all resources it uses. -
cancelBroadcastJobs
Cancels queued broadcast jobs for connection.- Parameters:
connectionUUID- The connection UUID that failed or was disconnected.
-
processPendingBroadcasts
public void processPendingBroadcasts()Process the jobs in the pending broadcast queue. This method is normally called fromTaskQueueChecker.dispatch(). -
getJPPFJobs
Get all theJPPFJobs currently in the queue.This method should be used with caution, as its cost is in O(n), with n being the number of jobs in the queue.
- Returns:
- a list of
JPPFJobinstances ordered by their priority. - Since:
- 4.1
-