Package org.jppf.queue
Class AbstractJPPFQueue<T,U,V>
java.lang.Object
org.jppf.queue.AbstractJPPFQueue<T,U,V>
- Type Parameters:
T- the type of jobs that are queued.U- the type of bundles the jobs are split into.V- the type of resulting bundles the jobs are split into.
Abstract superclass for all JPPFQueue implementations.
- Author:
- Laurent Cohen, Martin JANDA
-
Field Summary
FieldsModifier and TypeFieldDescriptionContains the ids of all queued jobs.protected final AtomicIntegerprotected final LockUsed for synchronized access to the queue.protected final LinkedListSortedMap<Integer,T> A map of task bundles, ordered by descending priority.protected final List<QueueListener<T,U, V>> The list of registered listeners.protected final SortedMap<Integer,AtomicInteger> An ordered map of bundle sizes, mapping to a count of bundles of this size. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQueueListener(QueueListener<T, U, V> listener) Add a listener to the list of listeners.voiddecrementSizeCount(int size) Decrement the count of jobs that have the specified size.voidfireBundleAdded(QueueEvent<T, U, V> event) Notify all queue listeners that a bundle was added tot he queue.voidfireBundleRemoved(QueueEvent<T, U, V> event) Notify all queue listeners of that a bundle was removed form the queue.getLock()Get the lock used for synchronized access to the queue.intGet the maximum bundle size for the bundles present in the queue.intGet the size of this job queue.protected abstract intGet the bundle size to use for bundle size tuning.voidincrementSizeCount(int size) Increment the count of jobs that have the specified size.booleanisEmpty()Determine whether the queue is empty or not.iterator()voidremoveQueueListener(QueueListener<T, U, V> listener) Remove a listener from the list of listeners.voidUpdate the value of the max bundle size.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jppf.queue.JPPFQueue
addBundle, nextBundle, removeBundle
-
Field Details
-
lock
Used for synchronized access to the queue. -
sizeMap
An ordered map of bundle sizes, mapping to a count of bundles of this size. -
latestMaxSize
-
queueListeners
The list of registered listeners. -
priorityMap
A map of task bundles, ordered by descending priority. -
jobMap
Contains the ids of all queued jobs.
-
-
Constructor Details
-
AbstractJPPFQueue
public AbstractJPPFQueue()
-
-
Method Details
-
addQueueListener
Add a listener to the list of listeners.- Parameters:
listener- the listener to add to the list.
-
removeQueueListener
Remove a listener from the list of listeners.- Parameters:
listener- the listener to remove from the list.
-
getSize
Get the bundle size to use for bundle size tuning.- Parameters:
bundleWrapper- the bundle to get the size from.- Returns:
- the bundle size as an int.
-
fireBundleAdded
Notify all queue listeners that a bundle was added tot he queue.- Parameters:
event- the event to notify of.
-
fireBundleRemoved
Notify all queue listeners of that a bundle was removed form the queue.- Parameters:
event- the event to notify of.- Since:
- 4.1
-
getLock
Get the lock used for synchronized access to the queue.- Returns:
- a
Lockinstance.
-
getMaxBundleSize
public int getMaxBundleSize()Description copied from interface:JPPFQueueGet the maximum bundle size for the bundles present in the queue.- Specified by:
getMaxBundleSizein interfaceJPPFQueue<T,U, V> - Returns:
- the bundle size as an int.
-
updateLatestMaxSize
public void updateLatestMaxSize()Update the value of the max bundle size. -
iterator
-
isEmpty
public boolean isEmpty()Description copied from interface:JPPFQueueDetermine whether the queue is empty or not. -
getQueueSize
public int getQueueSize()Get the size of this job 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:
- the number of jobs currently in the queue.
- Since:
- 4.1
-
incrementSizeCount
public void incrementSizeCount(int size) Increment the count of jobs that have the specified size.- Parameters:
size- the size for which to increment the count.
-
decrementSizeCount
public void decrementSizeCount(int size) Decrement the count of jobs that have the specified size.- Parameters:
size- the size for which to decrement the count.
-