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 |
protected CAS[] |
casList |
protected CPECasPool |
casPool |
protected CAS |
conversionCas |
protected CAS[] |
conversionCasArray |
protected CpeConfiguration |
cpeConfiguration |
protected CPMEngine |
cpm |
protected CasConverter |
mConverter |
protected boolean |
notifyListeners |
protected long |
numToProcess |
protected BoundedWorkQueue |
outputQueue |
protected LinkedList |
processContainers |
protected ProcessTrace |
processingUnitProcessTrace |
protected boolean |
releaseCAS |
protected ArrayList |
statusCbL |
protected String |
threadId |
int |
threadState |
protected UimaTimer |
timer |
long |
timer01 |
long |
timer02 |
long |
timer03 |
long |
timer04 |
long |
timer05 |
long |
timer06 |
protected BoundedWorkQueue |
workQueue |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
ProcessingUnit() |
ProcessingUnit(CPMEngine acpm) |
ProcessingUnit(CPMEngine acpm,
BoundedWorkQueue aInputQueue,
BoundedWorkQueue aOutputQueue)
Initialize the PU
|
Modifier and Type | Method and Description |
---|---|
void |
addStatusCallbackListener(BaseStatusCallbackListener aListener)
Plugs in Listener object used for notifications.
|
protected boolean |
analyze(Object[] aCasObjectList,
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,
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() |
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,
EntityProcessStatus aEntityProcStatus)
Notifies Listeners of the fact that the pipeline has finished processing the current set Cas'es
|
protected void |
process(Object anArtifact) |
protected boolean |
processNext(Object[] aCasObjectList,
ProcessTrace pTrTemp)
Executes the processing pipeline.
|
void |
removeStatusCallbackListener(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) |
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(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(UimaTimer aTimer)
Plugs in custom timer used by the PU for getting time
|
protected void |
showMetadata(Object[] aCasList) |
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, yield
public int threadState
protected CPECasPool casPool
protected boolean releaseCAS
protected CPMEngine cpm
protected BoundedWorkQueue workQueue
protected BoundedWorkQueue outputQueue
protected CasConverter mConverter
protected ProcessTrace processingUnitProcessTrace
protected LinkedList processContainers
protected long numToProcess
protected CAS[] casList
protected ArrayList statusCbL
protected boolean notifyListeners
protected CAS conversionCas
protected Object[] artifact
protected CAS[] conversionCasArray
protected UimaTimer timer
protected String threadId
protected 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)
public 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(BaseStatusCallbackListener aListener)
aListener
- -
BaseStatusCallbackListener
instancepublic ArrayList getCallbackListeners()
BaseStatusCallbackListener
instancespublic void removeStatusCallbackListener(BaseStatusCallbackListener aListener)
aListener
- -
object to remove from the listpublic void setProcessingUnitProcessTrace(ProcessTrace aProcessingUnitProcessTrace)
aProcessingUnitProcessTrace
- -
object to compile statspublic void setUimaTimer(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, ProcessTrace pTrTemp) throws ResourceProcessException, IOException, CollectionException, AbortCPMException, KillPipelineException
aCasObjectList
- - bundle of Cas to analyzepTrTemp
- - object used to aggregate statsResourceProcessException
IOException
CollectionException
AbortCPMException
KillPipelineException
protected void notifyListeners(Object aCas, boolean isCasObject, 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, 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
- protected void showMetadata(Object[] aCasList)
aCasList
- protected boolean isProcessorReady(int aStatus)
protected long getBytes(Object aCas)
aCas
- -
Cas to get the size forpublic void setCasPool(CPECasPool aPool)
aPool
- protected boolean analyze(Object[] aCasObjectList, ProcessTrace pTrTemp) throws Exception
aCasObjectList
- -
a list of CASes to analyzepTrTemp
- -
process trace where statistics are added during analysisException
Copyright © 2019. All rights reserved.