nl.knowledgeplaza.util.pool
Class FastestFirstObjectPool

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

public class FastestFirstObjectPool
extends PriorityObjectPool
implements ObjectPool

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.2 $
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  java.util.Map iAverageData
           
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class nl.knowledgeplaza.util.pool.PriorityObjectPool
iListOfPooledObjects
 
Fields inherited from class nl.knowledgeplaza.util.pool.BaseObjectPool
iClose, iListOfHandedOutObjects, iListOfHandedOutObjectsSync, iShuttingDown, iSynchronized, itestOnBorrow, MAINTENANCE_PERIOD, WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL
 
Constructor Summary
FastestFirstObjectPool()
          Initialize Assume that the pooled objects are Comparable
FastestFirstObjectPool(java.util.Collection collection, java.util.Comparator comparator)
          Initialize
FastestFirstObjectPool(PoolableObjectFactory poolableObjectFactory)
          Initialize
 
Method Summary
 void factoryDestroyObject(java.lang.Object object)
          Clean up the statistical data
 int getMinimumNumberOfMeasurements()
          MinimumNumberOfMeasurements
protected  java.lang.Object obtainPooledObjectImpl()
          this method obtains a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)
protected  void returnPooledObjectImpl(java.lang.Object 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 java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iAverageData

protected java.util.Map iAverageData
Constructor Detail

FastestFirstObjectPool

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


FastestFirstObjectPool

public FastestFirstObjectPool(PoolableObjectFactory poolableObjectFactory)
Initialize


FastestFirstObjectPool

public FastestFirstObjectPool(java.util.Collection collection,
                              java.util.Comparator comparator)
Initialize

Method Detail

getMinimumNumberOfMeasurements

public int getMinimumNumberOfMeasurements()
MinimumNumberOfMeasurements


setMinimumNumberOfMeasurements

public void setMinimumNumberOfMeasurements(int value)

obtainPooledObjectImpl

protected java.lang.Object 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

returnPooledObjectImpl

protected void returnPooledObjectImpl(java.lang.Object 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

factoryDestroyObject

public void factoryDestroyObject(java.lang.Object object)
Clean up the statistical data

Overrides:
factoryDestroyObject in class BaseObjectPool


Copyright © 2010 KnowledgePlaza. All Rights Reserved.