org.apache.uima.collection.impl.cpm.engine
Class CPECasPool

java.lang.Object
  extended by org.apache.uima.collection.impl.cpm.engine.CPECasPool

public class CPECasPool
extends java.lang.Object

Implements object pooling mechanism to limit number of CAS instances. Cas'es are checked out, used and checked back in when done.


Constructor Summary
CPECasPool(int aNumInstances, CasManager aCasManager)
          Initialize the pool.
CPECasPool(int aNumInstances, CasManager aCasManager, java.util.Properties aPerformanceTuningSettings)
          Initialize the pool
 
Method Summary
protected  void fillPool(CasManager aCasManager, java.util.Properties aPerformanceTuningSettings)
          Fills the pool with initialized instances of CAS.
 CAS getCas()
          Checks out a CAS from the pool.
 CAS getCas(long aTimeout)
          Returns a Cas instance from the pool.
 CAS getCheckedOutCas(int aIndex)
          Returns a CAS found in a given position in the list.
 int getCheckedOutCasCount()
          Returns number of CAS'es that have been checked out from pool
 int getSize()
          Gets the size of this pool (the total number of CAS instances that it can hold).
 void releaseCas(CAS aCas)
          Checks in a CAS to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CPECasPool

public CPECasPool(int aNumInstances,
                  CasManager aCasManager)
           throws ResourceInitializationException
Initialize the pool.

Parameters:
aNumInstances - - max size of the pool
aCasManager - - CAS Manager to use to create the CASes
Throws:
ResourceInitializationException

CPECasPool

public CPECasPool(int aNumInstances,
                  CasManager aCasManager,
                  java.util.Properties aPerformanceTuningSettings)
           throws ResourceInitializationException
Initialize the pool

Parameters:
aNumInstances - - max size of the pool
aCasManager - - CAS Manager to use to create the CASes
aPerformanceTuningSettings -
Throws:
ResourceInitializationException
Method Detail

fillPool

protected void fillPool(CasManager aCasManager,
                        java.util.Properties aPerformanceTuningSettings)
                 throws ResourceInitializationException
Fills the pool with initialized instances of CAS.

Parameters:
aCasDef - - definition (type system, indexes, etc.) of CASes to create
aPerformanceTuningSettings -
Throws:
ResourceInitializationException

getCas

public CAS getCas(long aTimeout)
Returns a Cas instance from the pool. This routine waits for a free instance of Cas a given amount of time. If free instance is not available this routine returns null.

Parameters:
aTimeout - - max amount of time in millis to wait for CAS instance
Returns:
- CAS instance, or null on timeout

getCas

public CAS getCas()
Checks out a CAS from the pool.

Returns:
a CAS instance. Returns null if none are available (in which case the client may Object.wait() on this object in order to be notified when an instance becomes available).

releaseCas

public void releaseCas(CAS aCas)
Checks in a CAS to the pool. This automatically calls the CAS.reset() method, to ensure that when the CAS is later retrieved from the pool it will be ready to use. Also notifies other Threads that may be waiting for an instance to become available.

Parameters:
aCas - the CAS to release

getCheckedOutCasCount

public int getCheckedOutCasCount()
Returns number of CAS'es that have been checked out from pool

Returns:
- number of CAS'es being processed

getCheckedOutCas

public CAS getCheckedOutCas(int aIndex)
Returns a CAS found in a given position in the list.

Parameters:
aIndex - - position of the CAS in the list
Returns:
CAS - reference to a CAS

getSize

public int getSize()
Gets the size of this pool (the total number of CAS instances that it can hold).

Returns:
the size of this pool


Copyright © 2011. All Rights Reserved.