Class NonThreadedProcessingUnit
- java.lang.Object
-
- org.apache.uima.collection.impl.cpm.engine.NonThreadedProcessingUnit
-
public class NonThreadedProcessingUnit extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]artifactprotected CAS[]casListprotected CPECasPoolcasPoolprotected CASconversionCasprotected CAS[]conversionCasArrayprotected CpeConfigurationcpeConfigurationprotected CPMEnginecpmprotected CasConvertermConverterprotected booleannotifyListenersprotected longnumToProcessprotected BoundedWorkQueueoutputQueueprotected java.util.LinkedListprocessContainersprotected ProcessTraceprocessingUnitProcessTraceprotected booleanrelaseCASprotected java.util.ArrayListstatusCbLprotected java.lang.StringthreadIdintthreadStateprotected UimaTimertimerprotected BoundedWorkQueueworkQueue
-
Constructor Summary
Constructors Constructor Description NonThreadedProcessingUnit(CPMEngine acpm)NonThreadedProcessingUnit(CPMEngine acpm, BoundedWorkQueue aInputQueue, BoundedWorkQueue aOutputQueue)Initialize the PU
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStatusCallbackListener(BaseStatusCallbackListener aListener)Plugs in Listener object used for notifications.protected booleananalyze(java.lang.Object[] aCasObjectList, ProcessTrace pTrTemp)voidcleanup()Null out fields of this object.voiddisableCasProcessor(int aCasProcessorIndex)Disable a CASProcessor in the processing pipeline.voiddisableCasProcessor(java.lang.String aCasProcessorName)Alternative method to disable Cas Processor.protected voiddoNotifyListeners(java.lang.Object aCas, boolean isCasObject, EntityProcessStatus aEntityProcStatus)Notifies all configured listeners.voidenableCasProcessor(java.lang.String aCasProcessorName)Enables Cas Processor with a given name.protected longgetBytes(java.lang.Object aCas)Returns the size of the CAS object.java.util.ArrayListgetCallbackListeners()Returns list of listeners used by this PU for callbacks.protected booleanisProcessorReady(int aStatus)Check if the CASProcessor status is available for processingprotected voidnotifyListeners(java.lang.Object aCas, boolean isCasObject, EntityProcessStatus aEntityProcStatus)Notifies Listeners of the fact that the pipeline has finished processing the current set Cas'esvoidremoveStatusCallbackListener(BaseStatusCallbackListener aListener)Removes given listener from the list of listenersvoidsetCasPool(CPECasPool aPool)voidsetContainers(java.util.LinkedList processorList)Plugs in a list of Cas Processor containers.voidsetCPMEngine(CPMEngine acpm)Alternative method of providing the reference to the component managing the lifecycle of the CPEvoidsetInputQueue(BoundedWorkQueue aInputQueue)Alternative method of providing a queue from which this PU will read bundle of CasvoidsetNotifyListeners(boolean aDoNotify)Set a flag indicating if notifications should be made via configured ListenersvoidsetOutputQueue(BoundedWorkQueue aOutputQueue)Alternative method of providing a queue where this PU will deposit results of analysisvoidsetProcessingUnitProcessTrace(ProcessTrace aProcessingUnitProcessTrace)Plugs in ProcessTrace object used to collect statisticsvoidsetReleaseCASFlag(boolean aFlag)voidsetUimaTimer(UimaTimer aTimer)Plugs in custom timer used by the PU for getting timevoidstopCasProcessors(boolean kill)Stops all Cas Processors that are part of this PU.
-
-
-
Field Detail
-
threadState
public int threadState
-
casPool
protected CPECasPool casPool
-
relaseCAS
protected boolean relaseCAS
-
cpm
protected CPMEngine cpm
-
workQueue
protected BoundedWorkQueue workQueue
-
outputQueue
protected BoundedWorkQueue outputQueue
-
mConverter
protected CasConverter mConverter
-
processingUnitProcessTrace
protected ProcessTrace processingUnitProcessTrace
-
processContainers
protected java.util.LinkedList processContainers
-
numToProcess
protected long numToProcess
-
casList
protected CAS[] casList
-
statusCbL
protected java.util.ArrayList statusCbL
-
notifyListeners
protected boolean notifyListeners
-
conversionCas
protected CAS conversionCas
-
artifact
protected java.lang.Object[] artifact
-
conversionCasArray
protected CAS[] conversionCasArray
-
timer
protected UimaTimer timer
-
threadId
protected java.lang.String threadId
-
cpeConfiguration
protected CpeConfiguration cpeConfiguration
-
-
Constructor Detail
-
NonThreadedProcessingUnit
public NonThreadedProcessingUnit(CPMEngine acpm, BoundedWorkQueue aInputQueue, BoundedWorkQueue aOutputQueue)
Initialize the PU- Parameters:
acpm- - component managing life cycle of the CPEaInputQueue- - queue to read fromaOutputQueue- - queue to write to
-
NonThreadedProcessingUnit
public NonThreadedProcessingUnit(CPMEngine acpm)
-
-
Method Detail
-
setInputQueue
public void setInputQueue(BoundedWorkQueue aInputQueue)
Alternative method of providing a queue from which this PU will read bundle of Cas- Parameters:
aInputQueue- - read queue
-
setOutputQueue
public void setOutputQueue(BoundedWorkQueue aOutputQueue)
Alternative method of providing a queue where this PU will deposit results of analysis- Parameters:
aOutputQueue- - queue to write to
-
setCPMEngine
public void setCPMEngine(CPMEngine acpm)
Alternative method of providing the reference to the component managing the lifecycle of the CPE- Parameters:
acpm- - reference to the contrlling engine
-
cleanup
public void cleanup()
Null out fields of this object. Call this only when this object is no longer needed.
-
setNotifyListeners
public void setNotifyListeners(boolean aDoNotify)
Set a flag indicating if notifications should be made via configured Listeners- Parameters:
aDoNotify- - true if notification is required, false otherwise
-
addStatusCallbackListener
public void addStatusCallbackListener(BaseStatusCallbackListener aListener)
Plugs in Listener object used for notifications.- Parameters:
aListener- -BaseStatusCallbackListenerinstance
-
getCallbackListeners
public java.util.ArrayList getCallbackListeners()
Returns list of listeners used by this PU for callbacks.- Returns:
- - lif of
BaseStatusCallbackListenerinstances
-
removeStatusCallbackListener
public void removeStatusCallbackListener(BaseStatusCallbackListener aListener)
Removes given listener from the list of listeners- Parameters:
aListener- - object to remove from the list
-
setProcessingUnitProcessTrace
public void setProcessingUnitProcessTrace(ProcessTrace aProcessingUnitProcessTrace)
Plugs in ProcessTrace object used to collect statistics- Parameters:
aProcessingUnitProcessTrace- - object to compile stats
-
setUimaTimer
public void setUimaTimer(UimaTimer aTimer)
Plugs in custom timer used by the PU for getting time- Parameters:
aTimer- - custom timer to use
-
setContainers
public void setContainers(java.util.LinkedList processorList)
Plugs in a list of Cas Processor containers. During processing Cas Processors in this list are called sequentially. Each Cas Processor is contained in the container that is managing errors, counts and totals, and restarts.- Parameters:
processorList- CASProcessor to be added to the processing pipeline
-
disableCasProcessor
public void disableCasProcessor(int aCasProcessorIndex)
Disable a CASProcessor in the processing pipeline. Locate it by provided index. The disabled Cas Processor remains in the Processing Pipeline, however it is not used furing processing.- Parameters:
aCasProcessorIndex- - location in the pipeline of the Cas Processor to delete
-
disableCasProcessor
public void disableCasProcessor(java.lang.String aCasProcessorName)
Alternative method to disable Cas Processor. Uses a name to locate it.- Parameters:
aCasProcessorName- - a name of the Cas Processor to disable
-
enableCasProcessor
public void enableCasProcessor(java.lang.String aCasProcessorName)
Enables Cas Processor with a given name. Enabled Cas Processor will immediately begin to receive bundles of Cas.- Parameters:
aCasProcessorName- - name of the Cas Processor to enable
-
analyze
protected boolean analyze(java.lang.Object[] aCasObjectList, ProcessTrace pTrTemp) throws java.lang.Exception- Throws:
java.lang.Exception
-
setReleaseCASFlag
public void setReleaseCASFlag(boolean aFlag)
- Parameters:
aFlag-
-
setCasPool
public void setCasPool(CPECasPool aPool)
- Parameters:
aPool-
-
isProcessorReady
protected boolean isProcessorReady(int aStatus)
Check if the CASProcessor status is available for processing
-
notifyListeners
protected void notifyListeners(java.lang.Object aCas, boolean isCasObject, EntityProcessStatus aEntityProcStatus)Notifies Listeners of the fact that the pipeline has finished processing the current set Cas'es- Parameters:
aCas- - object containing an array of OR a single instance of CasisCasObject- - true if instance of Cas is of type Cas, false otherwiseaEntityProcStatus- - status object that may contain exceptions and trace
-
doNotifyListeners
protected void doNotifyListeners(java.lang.Object aCas, boolean isCasObject, EntityProcessStatus aEntityProcStatus)Notifies all configured listeners. Makes sure that appropriate type of Cas is sent to the listener. Convertions take place to ensure compatibility.- Parameters:
aCas- - Cas to pass to listenerisCasObject- - true is Cas is of type CASaEntityProcStatus- - status object containing exceptions and trace info
-
getBytes
protected long getBytes(java.lang.Object aCas)
Returns the size of the CAS object. Currently only CASData is supported.- Parameters:
aCas- - Cas to get the size for- Returns:
- the size of the CAS object. Currently only CASData is supported.
-
stopCasProcessors
public void stopCasProcessors(boolean kill)
Stops all Cas Processors that are part of this PU.- Parameters:
kill- - true if CPE has been stopped before finishing processing during external stop
-
-