nl.knowledgeplaza.util.pool
Class FastestFirstObjectPool<T>

java.lang.Object
  extended by nl.knowledgeplaza.util.pool.BaseObjectPool<T>
      extended by nl.knowledgeplaza.util.pool.PriorityObjectPool<T>
          extended by nl.knowledgeplaza.util.pool.FastestFirstObjectPool<T>
All Implemented Interfaces:
ObjectPool<T>

public class FastestFirstObjectPool<T>
extends PriorityObjectPool<T>
implements ObjectPool<T>

This class implements a priority pool based on the assumption that all pooled objects are the same but not identical. This means they can all do the same work, but maybe not equally fast. It is assumed that all pooled objects on average get to process identical tasks, or workload. Because of this unequality, some pooled objects will perform the workload faster than others. This object pool will hand out the faster pooled objects before the slower. Faster is determine by keeping statistical data on how long it takes to perform the workload. Over time this should flatten out into a correct representation. The implementation tries to do its work with as less objects as possible (stack alike), unused objects have a very high average which puts them at the end of the priority queue.

Version:
$Revision: 1.3 $
Author:
$Author: toeukpap $
See Also:

Nested Class Summary
 
Nested classes/interfaces inherited from class nl.knowledgeplaza.util.pool.BaseObjectPool
BaseObjectPool.NotFromThisPoolException, BaseObjectPool.TimeOutException
 
Field Summary
protected  Map<T,nl.knowledgeplaza.util.pool.FastestFirstObjectPool.AverageData> iAverageData
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class nl.knowledgeplaza.util.pool.PriorityObjectPool
iListOfPooledObjects, iSortedListOfPooledObjects
 
Fields inherited from class nl.knowledgeplaza.util.pool.BaseObjectPool
iClose, iListOfHandedOutObjects, iListOfHandedOutObjectsSync, iShuttingDown, iSynchronized, itestOnBorrow, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL
 
Constructor Summary
FastestFirstObjectPool()
          Initialize Assume that the pooled objects are Comparable
FastestFirstObjectPool(Collection<T> collection, Comparator<T> comparator)
          Initialize
FastestFirstObjectPool(PoolableObjectFactory<T> poolableObjectFactory)
          Initialize
 
Method Summary
 void factoryDestroyObject(T object)
          Clean up the statistical data
 int getMinimumNumberOfMeasurements()
          MinimumNumberOfMeasurements
protected  T obtainPooledObjectImpl()
          this method obtains a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)
protected  void returnPooledObjectImpl(T o)
          this method returns a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)
 void setMinimumNumberOfMeasurements(int value)
           
 
Methods inherited from class nl.knowledgeplaza.util.pool.PriorityObjectPool
getPooledObjectsImpl
 
Methods inherited from class nl.knowledgeplaza.util.pool.BaseObjectPool
addObject, borrowObject, clear, close, factoryActivateObject, factoryMakeObject, factoryPassivateObject, factoryValidateObject, fill, getFactory, getMaxActive, getMaxIdle, getMaxWait, getName, getNameDescription, getNumActive, getNumberOfObjectsScheduledForDestruction, getNumIdle, getPooledObjects, getTestOnBorrow, getWhenExhaustedAction, invalidateObject, isClosed, isShuttingDown, isSynchronized, maintenance, obtainPooledObject, returnObject, returnPooledObject, setFactory, setMaxActive, setMaxIdle, setMaxWait, setName, setSynchronized, setTestOnBorrow, setWhenExhaustedAction, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.knowledgeplaza.util.pool.ObjectPool
addObject, borrowObject, clear, close, getNumActive, getNumIdle, invalidateObject, isSynchronized, returnObject, setFactory, setSynchronized, shutdown
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iAverageData

protected Map<T,nl.knowledgeplaza.util.pool.FastestFirstObjectPool.AverageData> iAverageData
Constructor Detail

FastestFirstObjectPool

public FastestFirstObjectPool()
Initialize Assume that the pooled objects are Comparable


FastestFirstObjectPool

public FastestFirstObjectPool(PoolableObjectFactory<T> poolableObjectFactory)
Initialize


FastestFirstObjectPool

public FastestFirstObjectPool(Collection<T> collection,
                              Comparator<T> comparator)
Initialize

Method Detail

getMinimumNumberOfMeasurements

public int getMinimumNumberOfMeasurements()
MinimumNumberOfMeasurements


setMinimumNumberOfMeasurements

public void setMinimumNumberOfMeasurements(int value)

obtainPooledObjectImpl

protected T obtainPooledObjectImpl()
Description copied from class: BaseObjectPool
this method obtains a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)

Overrides:
obtainPooledObjectImpl in class PriorityObjectPool<T>

returnPooledObjectImpl

protected void returnPooledObjectImpl(T o)
Description copied from class: BaseObjectPool
this method returns a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)

Overrides:
returnPooledObjectImpl in class PriorityObjectPool<T>

factoryDestroyObject

public void factoryDestroyObject(T object)
Clean up the statistical data

Overrides:
factoryDestroyObject in class BaseObjectPool<T>


Copyright © 2012 KnowledgePlaza. All Rights Reserved.