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.
All Implemented Interfaces:
Iterable<T>, JPPFQueue<T,U,V>

public abstract class AbstractJPPFQueue<T,U,V> extends Object implements JPPFQueue<T,U,V>
Abstract superclass for all JPPFQueue implementations.
Author:
Laurent Cohen, Martin JANDA
  • Field Details

    • lock

      protected final Lock lock
      Used for synchronized access to the queue.
    • sizeMap

      protected final SortedMap<Integer,AtomicInteger> sizeMap
      An ordered map of bundle sizes, mapping to a count of bundles of this size.
    • latestMaxSize

      protected final AtomicInteger latestMaxSize
    • queueListeners

      protected final List<QueueListener<T,U,V>> queueListeners
      The list of registered listeners.
    • priorityMap

      protected final LinkedListSortedMap<Integer,T> priorityMap
      A map of task bundles, ordered by descending priority.
    • jobMap

      protected final Map<String,T> jobMap
      Contains the ids of all queued jobs.
  • Constructor Details

    • AbstractJPPFQueue

      public AbstractJPPFQueue()
  • Method Details

    • addQueueListener

      public void addQueueListener(QueueListener<T,U,V> listener)
      Add a listener to the list of listeners.
      Parameters:
      listener - the listener to add to the list.
    • removeQueueListener

      public void removeQueueListener(QueueListener<T,U,V> listener)
      Remove a listener from the list of listeners.
      Parameters:
      listener - the listener to remove from the list.
    • getSize

      protected abstract int getSize(T bundleWrapper)
      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

      public void fireBundleAdded(QueueEvent<T,U,V> event)
      Notify all queue listeners that a bundle was added tot he queue.
      Parameters:
      event - the event to notify of.
    • fireBundleRemoved

      public void fireBundleRemoved(QueueEvent<T,U,V> event)
      Notify all queue listeners of that a bundle was removed form the queue.
      Parameters:
      event - the event to notify of.
      Since:
      4.1
    • getLock

      public Lock getLock()
      Get the lock used for synchronized access to the queue.
      Returns:
      a Lock instance.
    • getMaxBundleSize

      public int getMaxBundleSize()
      Description copied from interface: JPPFQueue
      Get the maximum bundle size for the bundles present in the queue.
      Specified by:
      getMaxBundleSize in interface JPPFQueue<T,U,V>
      Returns:
      the bundle size as an int.
    • updateLatestMaxSize

      public void updateLatestMaxSize()
      Update the value of the max bundle size.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: JPPFQueue
      Determine whether the queue is empty or not.
      Specified by:
      isEmpty in interface JPPFQueue<T,U,V>
      Returns:
      true if the queue is empty, false otherwise.
    • 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.