public UimaResource(AnalysisEngine analysisEngine) throws ResourceInitializationException { this.analysisEngine = analysisEngine; this.casPool = new CasPool(Runtime.getRuntime().availableProcessors() * 10,analysisEngine); }
protected void populateCasToCasPoolAndUimaContextMaps(CasPool aCasPool, UimaContext aUimaContext) { CAS[] casArray = new CAS[aCasPool.getSize()]; for (int i = 0; i < casArray.length; i++) { casArray[i] = ((CASImpl) aCasPool.getCas()).getBaseCAS(); mCasToCasPoolMap.put(casArray[i], aCasPool); if (aUimaContext != null) { mCasToUimaContextMap.put(casArray[i], aUimaContext); } } for (int i = 0; i < casArray.length; i++) { aCasPool.releaseCas(casArray[i]); } }
/** * Creates a new CasPool * * @param aNumInstances * the number of CAS instances in the pool * @param aCasManager * CAS Manager that will be used to create the CAS. The CAS Manager * holds the CAS Definition. Also all CASes created from the same * CAS Manager will share identical TypeSystem objects. * @param aPerformanceTuningSettings * Properties object containing framework performance tuning settings using key names * defined on {@link UIMAFramework} interface * @throws ResourceInitializationException - */ public CasPool(int aNumInstances, CasManager aCasManager, Properties aPerformanceTuningSettings) throws ResourceInitializationException { this(aNumInstances, fillPool(aNumInstances, aCasManager, aPerformanceTuningSettings)); }
mCasPool = new CasPool(descriptor.getInstanceCount(), mAE.getProcessingResourceMetaData()); CAS cas = mCasPool.getCas(); try { mAE.typeSystemInit(cas.getTypeSystem()); } finally { mCasPool.releaseCas(cas);
public void cleanup() { if (myCas != null && myCasPool != null) { myCasPool.releaseCas(myCas); myCas = null; } }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
try { cas = mCasPool.getCas(0); mCasPool.releaseCas(cas);
/** * Checks out a CAS from the pool. * * @return a CAS instance. Returns <code>null</code> if none are available (in which case the * client may {@link Object#wait()} on this object in order to be notified when an * instance becomes available). */ public CAS getCas() { boolean gotPermit; gotPermit = permits.tryAcquire(); if (!gotPermit) { return null; } return getCasAfterPermitAcquired(); }
public int getAvailableInstances() { CasPool casPool = mCasPoolRef.get(); if (casPool != null) { return casPool.getNumAvailable(); } else { return -1; } }
public void release(CAS cas) { casPool.releaseCas(cas); }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
/** * Checks out a CAS from the pool. If none is currently available, wait for the specified amount * of time for one to be checked in. * * @param aTimeout * the time to wait in milliseconds. A value of <=0 will wait forever. * * @return a CAS instance. Returns <code>null</code> if none are available within the specified * timeout period. */ public CAS getCas(long aTimeout) { if (aTimeout == 0) { permits.acquireUninterruptibly(); return getCasAfterPermitAcquired(); } boolean gotIt; try { gotIt = permits.tryAcquire(aTimeout, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { return null; } if (!gotIt) { return null; } return getCasAfterPermitAcquired(); }
public void release(CAS cas) { casPool.releaseCas(cas); }
public CAS retrieve() { CAS ret = casPool.getCas(); try { return ret == null ? analysisEngine.newCAS() : ret; } catch (ResourceInitializationException e) { throw new RuntimeException(e); } }
public UimaResource(AnalysisEngine analysisEngine) throws ResourceInitializationException { this.analysisEngine = analysisEngine; this.casPool = new CasPool(Runtime.getRuntime().availableProcessors() * 10, analysisEngine); }
/** * Creates a new CasPool. * TODO: do we need this method AND the one that takes a CasManager? * * @param aNumInstances * the number of CAS instances in the pool * @param aCasDefinition * the Cas definition, which includes the type system, type priorities, and indexes for * the CASes in the pool. * @param aPerformanceTuningSettings * Properties object containing framework performance tuning settings using key names * defined on {@link UIMAFramework} interface * @throws ResourceInitializationException - */ public CasPool(int aNumInstances, CasDefinition aCasDefinition, Properties aPerformanceTuningSettings) throws ResourceInitializationException { this(aNumInstances, fillPool(aNumInstances, aCasDefinition, aPerformanceTuningSettings)); }
public void release(CAS cas) { casPool.releaseCas(cas); }
public CAS getCas(String aRequestorContextName) { CasPool pool = mRequestorToCasPoolMap.get(aRequestorContextName); if (pool == null) { throw new UIMARuntimeException(UIMARuntimeException.REQUESTED_TOO_MANY_CAS_INSTANCES, new Object[] { aRequestorContextName, "1", "0" }); } return pool.getCas(0); // 0 means wait forever }
public UimaResource(AnalysisEngine analysisEngine) throws ResourceInitializationException { this.analysisEngine = analysisEngine; this.casPool = new CasPool(Runtime.getRuntime().availableProcessors() * 10,analysisEngine); }
/** * Creates a new CasPool * * @param aNumInstances * the number of CAS instances in the pool * @param aCollectionOfProcessingResourceMetaData * a collection of * {@link ProcessingResourceMetaData} objects. * @param aPerformanceTuningSettings * Properties object containing framework performance tuning settings using key names * defined on {@link UIMAFramework} interface * @param aResourceManager * the resource manager to use to resolve import declarations within the metadata * * @throws ResourceInitializationException * if the CAS instances could not be created */ public CasPool(int aNumInstances, Collection<? extends ProcessingResourceMetaData> aCollectionOfProcessingResourceMetaData, Properties aPerformanceTuningSettings, ResourceManager aResourceManager) throws ResourceInitializationException { this(aNumInstances, fillPool(aNumInstances, aCollectionOfProcessingResourceMetaData, aPerformanceTuningSettings, aResourceManager)); }