public class ProcessingUnit extends Thread
ArtifactProducer and sends it through
configured CasProcessors. The sequence in which CasProcessors are invoked is defined by the order
of Cas Processor listing in the cpe descriptor. The results of analysis produced be Cas
Processors is enqueued onto an output queue that is shared with Cas Consumers.Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
protected Object[] |
artifact
The artifact.
|
protected org.apache.uima.cas.CAS[] |
casList
The cas list.
|
protected CPECasPool |
casPool
The cas pool.
|
protected org.apache.uima.cas.CAS |
conversionCas
The conversion cas.
|
protected org.apache.uima.cas.CAS[] |
conversionCasArray
The conversion cas array.
|
protected org.apache.uima.collection.metadata.CpeConfiguration |
cpeConfiguration
The cpe configuration.
|
protected CPMEngine |
cpm
The cpm.
|
protected CasConverter |
mConverter
The m converter.
|
protected boolean |
notifyListeners
The notify listeners.
|
protected long |
numToProcess
The num to process.
|
protected BoundedWorkQueue |
outputQueue
The output queue.
|
protected LinkedList |
processContainers
The process containers.
|
protected org.apache.uima.util.ProcessTrace |
processingUnitProcessTrace
The processing unit process trace.
|
protected boolean |
releaseCAS
The release CAS.
|
protected ArrayList |
statusCbL
The status cb L.
|
protected String |
threadId
The thread id.
|
int |
threadState
The thread state.
|
protected org.apache.uima.util.UimaTimer |
timer
The timer.
|
long |
timer01
The timer 01.
|
long |
timer02
The timer 02.
|
long |
timer03
The timer 03.
|
long |
timer04
The timer 04.
|
long |
timer05
The timer 05.
|
long |
timer06
The timer 06.
|
protected BoundedWorkQueue |
workQueue
The work queue.
|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
ProcessingUnit()
Instantiates a new processing unit.
|
ProcessingUnit(CPMEngine acpm)
Instantiates a new processing unit.
|
ProcessingUnit(CPMEngine acpm,
BoundedWorkQueue aInputQueue,
BoundedWorkQueue aOutputQueue)
Initialize the PU.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addStatusCallbackListener(org.apache.uima.collection.base_cpm.BaseStatusCallbackListener aListener)
Plugs in Listener object used for notifications.
|
protected boolean |
analyze(Object[] aCasObjectList,
org.apache.uima.util.ProcessTrace pTrTemp)
An alternate processing loop designed for the single-threaded CPM.
|
void |
cleanup()
Null out fields of this object.
|
boolean |
consumeQueue()
Consumes the input queue to make sure all bundles still there get processede before CPE
terminates.
|
void |
disableCasProcessor(int aCasProcessorIndex)
Disable a CASProcessor in the processing pipeline.
|
void |
disableCasProcessor(String aCasProcessorName)
Alternative method to disable Cas Processor.
|
protected void |
doNotifyListeners(Object aCas,
boolean isCasObject,
org.apache.uima.collection.EntityProcessStatus aEntityProcStatus)
Notifies all configured listeners.
|
void |
enableCasProcessor(String aCasProcessorName)
Enables Cas Processor with a given name.
|
protected boolean |
endOfProcessingReached(long aCount)
Returns true if the CPM has finished analyzing the collection.
|
protected long |
getBytes(Object aCas)
Returns the size of the CAS object.
|
ArrayList |
getCallbackListeners()
Returns list of listeners used by this PU for callbacks.
|
boolean |
isCasConsumerPipeline()
Checks if is cas consumer pipeline.
|
protected boolean |
isProcessorReady(int aStatus)
Check if the CASProcessor status is available for processing.
|
boolean |
isRunning()
Returns true if this component is in running state.
|
protected void |
notifyListeners(Object aCas,
boolean isCasObject,
org.apache.uima.collection.EntityProcessStatus aEntityProcStatus)
Notifies Listeners of the fact that the pipeline has finished processing the current set Cas'es.
|
protected void |
process(Object anArtifact)
Process.
|
protected boolean |
processNext(Object[] aCasObjectList,
org.apache.uima.util.ProcessTrace pTrTemp)
Executes the processing pipeline.
|
void |
removeStatusCallbackListener(org.apache.uima.collection.base_cpm.BaseStatusCallbackListener aListener)
Removes given listener from the list of listeners.
|
void |
run()
Starts the Processing Pipeline thread.
|
void |
setCasConsumerPipelineIdentity()
Define a CasConsumer Pipeline identity for this instance.
|
void |
setCasPool(CPECasPool aPool)
Sets the cas pool.
|
void |
setContainers(LinkedList processorList)
Plugs in a list of Cas Processor containers.
|
void |
setCPMEngine(CPMEngine acpm)
Alternative method of providing the reference to the component managing the lifecycle of the
CPE.
|
void |
setInputQueue(BoundedWorkQueue aInputQueue)
Alternative method of providing a queue from which this PU will read bundle of Cas.
|
void |
setNotifyListeners(boolean aDoNotify)
Set a flag indicating if notifications should be made via configured Listeners.
|
void |
setOutputQueue(BoundedWorkQueue aOutputQueue)
Alternative method of providing a queue where this PU will deposit results of analysis.
|
void |
setProcessingUnitProcessTrace(org.apache.uima.util.ProcessTrace aProcessingUnitProcessTrace)
Plugs in ProcessTrace object used to collect statistics.
|
void |
setReleaseCASFlag(boolean aFlag)
Called by the CPMEngine during setup to indicate that this thread is supposed to release a CAS
at the end of processing.
|
void |
setUimaTimer(org.apache.uima.util.UimaTimer aTimer)
Plugs in custom timer used by the PU for getting time.
|
protected void |
showMetadata(Object[] aCasList)
Show metadata.
|
void |
stopCasProcessors(boolean kill)
Stops all Cas Processors that are part of this PU.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic int threadState
protected CPECasPool casPool
protected boolean releaseCAS
protected CPMEngine cpm
protected BoundedWorkQueue workQueue
protected BoundedWorkQueue outputQueue
protected CasConverter mConverter
protected org.apache.uima.util.ProcessTrace processingUnitProcessTrace
protected LinkedList processContainers
protected long numToProcess
protected org.apache.uima.cas.CAS[] casList
protected ArrayList statusCbL
protected boolean notifyListeners
protected org.apache.uima.cas.CAS conversionCas
protected Object[] artifact
protected org.apache.uima.cas.CAS[] conversionCasArray
protected org.apache.uima.util.UimaTimer timer
protected String threadId
protected org.apache.uima.collection.metadata.CpeConfiguration cpeConfiguration
public long timer01
public long timer02
public long timer03
public long timer04
public long timer05
public long timer06
public ProcessingUnit()
public ProcessingUnit(CPMEngine acpm, BoundedWorkQueue aInputQueue, BoundedWorkQueue aOutputQueue)
acpm - -
component managing life cycle of the CPEaInputQueue - -
queue to read fromaOutputQueue - -
queue to write topublic ProcessingUnit(CPMEngine acpm)
acpm - the acpmpublic boolean isRunning()
public void setCasConsumerPipelineIdentity()
public boolean isCasConsumerPipeline()
public void setInputQueue(BoundedWorkQueue aInputQueue)
aInputQueue - -
read queuepublic void setOutputQueue(BoundedWorkQueue aOutputQueue)
aOutputQueue - -
queue to write topublic void setCPMEngine(CPMEngine acpm)
acpm - -
reference to the contrlling enginepublic void cleanup()
public void setNotifyListeners(boolean aDoNotify)
aDoNotify - -
true if notification is required, false otherwisepublic void addStatusCallbackListener(org.apache.uima.collection.base_cpm.BaseStatusCallbackListener aListener)
aListener - -
BaseStatusCallbackListener instancepublic ArrayList getCallbackListeners()
BaseStatusCallbackListener
instancespublic void removeStatusCallbackListener(org.apache.uima.collection.base_cpm.BaseStatusCallbackListener aListener)
aListener - -
object to remove from the listpublic void setProcessingUnitProcessTrace(org.apache.uima.util.ProcessTrace aProcessingUnitProcessTrace)
aProcessingUnitProcessTrace - -
object to compile statspublic void setUimaTimer(org.apache.uima.util.UimaTimer aTimer)
aTimer - -
custom timer to usepublic void setContainers(LinkedList processorList)
processorList - CASProcessor to be added to the processing pipelinepublic void disableCasProcessor(int aCasProcessorIndex)
aCasProcessorIndex - -
location in the pipeline of the Cas Processor to deletepublic void disableCasProcessor(String aCasProcessorName)
aCasProcessorName - -
a name of the Cas Processor to disablepublic void enableCasProcessor(String aCasProcessorName)
aCasProcessorName - -
name of the Cas Processor to enablepublic void run()
public boolean consumeQueue()
protected boolean processNext(Object[] aCasObjectList, org.apache.uima.util.ProcessTrace pTrTemp) throws org.apache.uima.resource.ResourceProcessException, IOException, org.apache.uima.collection.CollectionException, org.apache.uima.collection.base_cpm.AbortCPMException, KillPipelineException
aCasObjectList - - bundle of Cas to analyzepTrTemp - - object used to aggregate statsorg.apache.uima.resource.ResourceProcessException - the resource process exceptionIOException - Signals that an I/O exception has occurred.org.apache.uima.collection.CollectionException - the collection exceptionorg.apache.uima.collection.base_cpm.AbortCPMException - the abort CPM exceptionKillPipelineException - the kill pipeline exceptionprotected void notifyListeners(Object aCas, boolean isCasObject, org.apache.uima.collection.EntityProcessStatus aEntityProcStatus)
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 traceprotected void doNotifyListeners(Object aCas, boolean isCasObject, org.apache.uima.collection.EntityProcessStatus aEntityProcStatus)
aCas - -
Cas to pass to listenerisCasObject - -
true is Cas is of type CASaEntityProcStatus - -
status object containing exceptions and trace infopublic void setReleaseCASFlag(boolean aFlag)
aFlag - -
true if this thread should release a CAS when analysis is completepublic void stopCasProcessors(boolean kill)
kill - -
true if CPE has been stopped before finishing processing during external stopprotected boolean endOfProcessingReached(long aCount)
aCount - -
running total of documents processed so farprotected void process(Object anArtifact)
anArtifact - the an artifactprotected void showMetadata(Object[] aCasList)
aCasList - the a cas listprotected boolean isProcessorReady(int aStatus)
aStatus - the a statusprotected long getBytes(Object aCas)
aCas - -
Cas to get the size forpublic void setCasPool(CPECasPool aPool)
aPool - the new cas poolprotected boolean analyze(Object[] aCasObjectList, org.apache.uima.util.ProcessTrace pTrTemp) throws Exception
aCasObjectList - -
a list of CASes to analyzepTrTemp - -
process trace where statistics are added during analysisException - the exceptionCopyright © 2006–2017 The Apache Software Foundation. All rights reserved.