org.jppf.server.queue
Class AbstractJPPFQueue

java.lang.Object
  extended by org.jppf.server.queue.AbstractJPPFQueue
All Implemented Interfaces:
Iterable<BundleWrapper>, JPPFQueue
Direct Known Subclasses:
JPPFPriorityQueue

public abstract class AbstractJPPFQueue
extends Object
implements JPPFQueue

Abstract superclass for all JPPFQueue implementations.

Author:
Laurent Cohen

Field Summary
protected  int latestMaxSize
           
protected  ReentrantLock lock
          Used for synchronized access to the queue.
protected  List<QueueListener> queueListeners
          The list of registered listeners.
protected  TreeMap<Integer,List<BundleWrapper>> sizeMap
          An ordered map of bundle sizes, mapping to a list of bundles of this size.
 
Constructor Summary
AbstractJPPFQueue()
           
 
Method Summary
 void addQueueListener(QueueListener listener)
          Add a listener to the list of listeners.
protected  void fireQueueEvent(QueueEvent event)
          Notify all queue listeners of an event.
 ReentrantLock getLock()
          Get the lock used for synchronized access to the queue.
 List<QueueListener> getQueueListeners()
          return a list of all the registered listee ners.
protected  int getSize(BundleWrapper bundleWrapper)
          Get the bundle size to use for bundle size tuning.
 void removeQueueListener(QueueListener listener)
          Remove a listener from the list of listeners.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jppf.server.queue.JPPFQueue
addBundle, getMaxBundleSize, isEmpty, nextBundle, nextBundle, removeBundle
 
Methods inherited from interface java.lang.Iterable
iterator
 

Field Detail

lock

protected ReentrantLock lock
Used for synchronized access to the queue.


sizeMap

protected TreeMap<Integer,List<BundleWrapper>> sizeMap
An ordered map of bundle sizes, mapping to a list of bundles of this size.


latestMaxSize

protected int latestMaxSize

queueListeners

protected List<QueueListener> queueListeners
The list of registered listeners.

Constructor Detail

AbstractJPPFQueue

public AbstractJPPFQueue()
Method Detail

addQueueListener

public void addQueueListener(QueueListener listener)
Add a listener to the list of listeners.

Parameters:
listener - the listener to add to the list.

removeQueueListener

public void removeQueueListener(QueueListener listener)
Remove a listener from the list of listeners.

Parameters:
listener - the listener to rmeove from the list.

getQueueListeners

public List<QueueListener> getQueueListeners()
return a list of all the registered listee ners. This list is not thread safe and must bmanually synchronized against concurrent modifications.

Returns:
a list of listener instances.

getSize

protected int getSize(BundleWrapper 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.

fireQueueEvent

protected void fireQueueEvent(QueueEvent event)
Notify all queue listeners of an event.

Parameters:
event - - the event to notify of.

getLock

public ReentrantLock getLock()
Get the lock used for synchronized access to the queue.

Returns:
a ReentrantLock instance.


Copyright © 2005-2010 JPPF Team.