Class CPECasPool
java.lang.Object
org.apache.uima.collection.impl.cpm.engine.CPECasPool
Implements object pooling mechanism to limit number of CAS instances. Cas'es are checked out,
used and checked back in when done.
-
Constructor Summary
ConstructorDescriptionCPECasPool
(int aNumInstances, CasManager aCasManager) Initialize the pool.CPECasPool
(int aNumInstances, CasManager aCasManager, Properties aPerformanceTuningSettings) Initialize the pool. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
fillPool
(CasManager aCasManager, Properties aPerformanceTuningSettings) Fills the pool with initialized instances of CAS.getCas()
Checks out a CAS from the pool.getCas
(long aTimeout) Returns a Cas instance from the pool.getCheckedOutCas
(int aIndex) Returns a CAS found in a given position in the list.int
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.
-
Constructor Details
-
CPECasPool
Initialize the pool.- Parameters:
aNumInstances
- - max size of the poolaCasManager
- - CAS Manager to use to create the CASes- Throws:
ResourceInitializationException
- -
-
CPECasPool
public CPECasPool(int aNumInstances, CasManager aCasManager, Properties aPerformanceTuningSettings) throws ResourceInitializationException Initialize the pool.- Parameters:
aNumInstances
- - max size of the poolaCasManager
- - CAS Manager to use to create the CASesaPerformanceTuningSettings
- the a performance tuning settings- Throws:
ResourceInitializationException
- -
-
-
Method Details
-
fillPool
protected void fillPool(CasManager aCasManager, Properties aPerformanceTuningSettings) throws ResourceInitializationException Fills the pool with initialized instances of CAS.- Parameters:
aCasManager
- - definition (type system, indexes, etc.) of CASes to createaPerformanceTuningSettings
- the a performance tuning settings- Throws:
ResourceInitializationException
- -
-
getCas
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
Checks out a CAS from the pool.- Returns:
- a CAS instance. Returns
null
if none are available (in which case the client mayObject.wait()
on this object in order to be notified when an instance becomes available).
-
releaseCas
Checks in a CAS to the pool. This automatically calls theCAS.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
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
-