Class BaseCPMImpl
- java.lang.Object
-
- org.apache.uima.collection.impl.cpm.BaseCPMImpl
-
- All Implemented Interfaces:
java.lang.Runnable,BaseCPM
- Direct Known Subclasses:
CPMImpl
public class BaseCPMImpl extends java.lang.Object implements BaseCPM, java.lang.Runnable
Main thread that launches CPE and manages it. An application interacts with the running CPE via this object. Through an API, an application may start, pause, resume, and stop a CPE.
-
-
Field Summary
Fields Modifier and Type Field Description CPMThreadGroupcpmThreadGroup-
Fields inherited from interface org.apache.uima.collection.base_cpm.BaseCPM
DOCUMENT_TEXT_FEATURE, DOCUMENT_TEXT_TYPE
-
-
Constructor Summary
Constructors Constructor Description BaseCPMImpl(java.lang.Boolean mode, java.lang.String aDescriptor, ResourceManager aResourceManager)Parses CPE descriptorBaseCPMImpl(CpeDescription aDescriptor)Instantiates and initializes CPE Factory with a given CPE Descriptor and defaults.BaseCPMImpl(CpeDescription aDescriptor, ResourceManager aResourceManager, boolean aDefaultProcessTrace, java.util.Properties aProps)Instantiates and initializes CPE Factory responsible for creating individual components that are part of the processing pipeline.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCasProcessor(CasProcessor aCasProcessor)Adds aCasProcessorto this CPM's list of consumers.voidaddCasProcessor(CasProcessor aCasProcessor, int aIndex)Adds aCasProcessorto this CPM's list of consumers.voidaddStatusCallbackListener(BaseStatusCallbackListener aListener)Registers a listsner to receive status callbacks.voidasynchStop()voidbuildEventTree(ProcessTraceEvent aEvent, int aTotalTime)Helper method to help build the CPM reportvoiddisableCasProcessor(java.lang.String aCasProcessorName)Disables aCasProcessorin this CPM's list of CasProcessors.voiddisplayStats(ProcessTrace aProcessTrace, int aNumDocsProcessed)Helper method to display stats and totalsvoidenableCasProcessor(java.lang.String aCasProcessorName)voidfinalizeIt()Called to cleanup CPE on shutdownCasProcessor[]getCasProcessors()Gets theCasProcessorss assigned to this CPM, in the order in which they will be called by the CPM.BaseCollectionReadergetCollectionReader()Returns a Collection Reader for this CPE.CpeConfigurationgetCPEConfig()ReturnsCPEConfigobject holding current CPE configurationjava.lang.StringgetDescriptor(java.util.List aList)Returns a CPE descriptor as a StringProcessTracegetPerformanceReport()Returns PerformanceReport for the CPM.Progress[]getProgress()Returns current CPE progress.SynchPointgetSynchPoint()Returns aSynchPointobject initialized by the Collection Reader if the Collection Reader implementsRecoverableCollectionReader.voidinit(boolean aDummyCasProcessor, java.util.Properties aProps)Instantiates and initializes a CPE.booleanisPaused()Determines whether this CPM's processing is currently paused.booleanisPauseOnException()Gets whether this CPM will automatically pause processing if an exception occurs.booleanisProcessing()Determines whether this CPM is currently processing.booleanisSerialProcessingRequired()Gets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization).voidkill()Kills the CPM hard.voidpause()Pauses processing.voidprocess()Initiates processing of a collection.voidprocess(BaseCollectionReader aCollectionReader)Deprecated.voidprocess(BaseCollectionReader aCollectionReader, int aBatchSize)Deprecated.voidremoveCasProcessor(CasProcessor aCasProcessor)Removes aCasProcessorto this CPM's list of consumers.voidremoveStatusCallbackListener(BaseStatusCallbackListener aListener)Unregisters a status callback listener.voidresume()Resumes processing that has been paused.voidresume(boolean aRetryFailed)Resumes processing that has been paused.voidrun()voidsetCollectionReader(BaseCollectionReader aCollectionReader)Sets the Collection Reader for this CPE.voidsetJediiReport(boolean aUseJediiReport)Sets Jedii-style reporting resources and sets the global flag to indicate what report-style to use at the end of processing.voidsetPauseOnException(boolean aPause)Sets whether this CPM will automatically pause processing if an exception occurs.voidsetPerformanceTuningSettings(java.util.Properties aPerformanceTuningSettings)Plugs in custom perfomance tunning parametersvoidsetProcessControllerAdapter(ProcessControllerAdapter aPca)Plugs in a givenProcessControllerAdapter.voidsetSerialProcessingRequired(boolean aRequired)Sets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization).voidstop()Stops processing.
-
-
-
Field Detail
-
cpmThreadGroup
public CPMThreadGroup cpmThreadGroup
-
-
Constructor Detail
-
BaseCPMImpl
public BaseCPMImpl(CpeDescription aDescriptor) throws java.lang.Exception
Instantiates and initializes CPE Factory with a given CPE Descriptor and defaults.- Parameters:
aDescriptor- - parsed CPE descriptor- Throws:
java.lang.Exception- -
-
BaseCPMImpl
public BaseCPMImpl(CpeDescription aDescriptor, ResourceManager aResourceManager, boolean aDefaultProcessTrace, java.util.Properties aProps) throws java.lang.Exception
Instantiates and initializes CPE Factory responsible for creating individual components that are part of the processing pipeline.- Parameters:
aDescriptor- - parsed CPE descriptoraResourceManager- - ResourceManager instance to be used by the CPEaDefaultProcessTrace- - ProcessTrace instance to capture events and stats- Throws:
java.lang.Exception- -
-
BaseCPMImpl
public BaseCPMImpl(java.lang.Boolean mode, java.lang.String aDescriptor, ResourceManager aResourceManager) throws java.lang.ExceptionParses CPE descriptor- Parameters:
mode- - indicates if the CPM should use a static descriptor or one providedaDescriptor- - provided descriptor pathaResourceManager- ResourceManager to be used by CPM- Throws:
java.lang.Exception- -
-
-
Method Detail
-
setPerformanceTuningSettings
public void setPerformanceTuningSettings(java.util.Properties aPerformanceTuningSettings)
Plugs in custom perfomance tunning parameters- Parameters:
aPerformanceTuningSettings-
-
setProcessControllerAdapter
public void setProcessControllerAdapter(ProcessControllerAdapter aPca)
Plugs in a givenProcessControllerAdapter. The CPM uses this adapter to request Cas Processor restarts and shutdown.- Parameters:
aPca- - instance of the ProcessControllerAdapter
-
setJediiReport
public void setJediiReport(boolean aUseJediiReport)
Sets Jedii-style reporting resources and sets the global flag to indicate what report-style to use at the end of processing. Jedii-style reporting shows a summary for this run. The CPM default report shows more detail information.- Parameters:
aUseJediiReport-
-
init
public void init(boolean aDummyCasProcessor, java.util.Properties aProps) throws java.lang.ExceptionInstantiates and initializes a CPE.- Parameters:
aDummyCasProcessor- -- Throws:
java.lang.Exception- -
-
getCPEConfig
public CpeConfiguration getCPEConfig() throws java.lang.Exception
ReturnsCPEConfigobject holding current CPE configuration- Returns:
- CPEConfig instance
- Throws:
java.lang.Exception- -
-
getCasProcessors
public CasProcessor[] getCasProcessors()
Description copied from interface:BaseCPMGets theCasProcessorss assigned to this CPM, in the order in which they will be called by the CPM.- Specified by:
getCasProcessorsin interfaceBaseCPM- Returns:
- an array of
CasProcessors
-
addCasProcessor
public void addCasProcessor(CasProcessor aCasProcessor) throws ResourceConfigurationException
Description copied from interface:BaseCPMAdds aCasProcessorto this CPM's list of consumers. The new CasProcessor will be added to the end of the list of CAS Processors.- Specified by:
addCasProcessorin interfaceBaseCPM- Parameters:
aCasProcessor- aCasProcessorto add- Throws:
ResourceConfigurationException- if this CPM is currently processing
-
addCasProcessor
public void addCasProcessor(CasProcessor aCasProcessor, int aIndex) throws ResourceConfigurationException
Description copied from interface:BaseCPMAdds aCasProcessorto this CPM's list of consumers. The new CasProcessor will be added at the specified index.- Specified by:
addCasProcessorin interfaceBaseCPM- Parameters:
aCasProcessor- the CasProcessor to addaIndex- the index at which to add the CasProcessor- Throws:
ResourceConfigurationException- if this CPM is currently processing
-
removeCasProcessor
public void removeCasProcessor(CasProcessor aCasProcessor)
Description copied from interface:BaseCPMRemoves aCasProcessorto this CPM's list of consumers.- Specified by:
removeCasProcessorin interfaceBaseCPM- Parameters:
aCasProcessor- theCasProcessorto remove
-
disableCasProcessor
public void disableCasProcessor(java.lang.String aCasProcessorName)
Description copied from interface:BaseCPMDisables aCasProcessorin this CPM's list of CasProcessors.- Specified by:
disableCasProcessorin interfaceBaseCPM- Parameters:
aCasProcessorName- the name of theCasProcessorto disable
-
enableCasProcessor
public void enableCasProcessor(java.lang.String aCasProcessorName)
-
isSerialProcessingRequired
public boolean isSerialProcessingRequired()
Description copied from interface:BaseCPMGets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization). Note that a value offalsedoes not guarantee that parallelization is performed; this is left up to the CPM implementation.- Specified by:
isSerialProcessingRequiredin interfaceBaseCPM- Returns:
- true if and only if serial processing is required
-
setSerialProcessingRequired
public void setSerialProcessingRequired(boolean aRequired)
Description copied from interface:BaseCPMSets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization). If this method is not called, the default isfalse. Note that a value offalsedoes not guarantee that parallelization is performed; this is left up to the CPM implementation.- Specified by:
setSerialProcessingRequiredin interfaceBaseCPM- Parameters:
aRequired- true if and only if serial processing is required
-
isPauseOnException
public boolean isPauseOnException()
Description copied from interface:BaseCPMGets whether this CPM will automatically pause processing if an exception occurs. If processing is paused it can be resumed by calling theBaseCPM.resume(boolean)method.- Specified by:
isPauseOnExceptionin interfaceBaseCPM- Returns:
- true if and only if this CPM will pause on exception
-
setPauseOnException
public void setPauseOnException(boolean aPause)
Description copied from interface:BaseCPMSets whether this CPM will automatically pause processing if an exception occurs. If processing is paused it can be resumed by calling theBaseCPM.resume(boolean)method.- Specified by:
setPauseOnExceptionin interfaceBaseCPM- Parameters:
aPause- true if and only if this CPM should pause on exception
-
addStatusCallbackListener
public void addStatusCallbackListener(BaseStatusCallbackListener aListener)
Description copied from interface:BaseCPMRegisters a listsner to receive status callbacks.- Specified by:
addStatusCallbackListenerin interfaceBaseCPM- Parameters:
aListener- the listener to add
-
removeStatusCallbackListener
public void removeStatusCallbackListener(BaseStatusCallbackListener aListener)
Description copied from interface:BaseCPMUnregisters a status callback listener.- Specified by:
removeStatusCallbackListenerin interfaceBaseCPM- Parameters:
aListener- the listener to remove
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
finalizeIt
public void finalizeIt()
Called to cleanup CPE on shutdown
-
process
@Deprecated public void process(BaseCollectionReader aCollectionReader) throws ResourceInitializationException
Deprecated.This method is called by an applications to begin CPM processing with a given Collection. It just creates a new thread and starts it.- Throws:
ResourceInitializationException- See Also:
BaseCPM.process()
-
process
public void process() throws ResourceInitializationExceptionDescription copied from interface:BaseCPMInitiates processing of a collection. This method starts the processing in another thread and returns immediately. Status of the processing can be obtained by registering a listener with theBaseCPM.addStatusCallbackListener(BaseStatusCallbackListener)method.A CPM can only process one collection at a time. If this method is called while a previous processing request has not yet completed, a
UIMA_IllegalStateExceptionwill result. To find out whether a CPM is free to begin another processing request, call theBaseCPM.isProcessing()method.- Specified by:
processin interfaceBaseCPM- Throws:
ResourceInitializationException- if an error occurs during initialization
-
process
@Deprecated public void process(BaseCollectionReader aCollectionReader, int aBatchSize) throws ResourceInitializationException
Deprecated.This method is called by an applications to begin CPM processing with a given Collection. It just creates a new thread and starts it.- Throws:
ResourceInitializationException- See Also:
BaseCPM.process()
-
setCollectionReader
public void setCollectionReader(BaseCollectionReader aCollectionReader)
Sets the Collection Reader for this CPE.- Specified by:
setCollectionReaderin interfaceBaseCPM- Parameters:
aCollectionReader- the collection reader
-
getCollectionReader
public BaseCollectionReader getCollectionReader()
Returns a Collection Reader for this CPE.- Specified by:
getCollectionReaderin interfaceBaseCPM- Returns:
- the collection reader
-
isProcessing
public boolean isProcessing()
Description copied from interface:BaseCPMDetermines whether this CPM is currently processing. This means that a processing request has been submitted and has not yet completed or beenBaseCPM.stop()ped. If processing is paused, this method will still returntrue.- Specified by:
isProcessingin interfaceBaseCPM- Returns:
- true if and only if this CPM is currently processing.
-
pause
public void pause()
Description copied from interface:BaseCPMPauses processing. Processing can later be resumed by calling theBaseCPM.resume(boolean)method.
-
isPaused
public boolean isPaused()
Description copied from interface:BaseCPMDetermines whether this CPM's processing is currently paused.
-
resume
public void resume(boolean aRetryFailed)
Description copied from interface:BaseCPMResumes processing that has been paused.- Specified by:
resumein interfaceBaseCPM- Parameters:
aRetryFailed- if processing was paused because an exception occurred (seeBaseCPM.setPauseOnException(boolean)), setting a value oftruefor this parameter will cause the failed entity to be retried. A value offalse(the default) will cause processing to continue with the next entity after the failure.
-
resume
public void resume()
Description copied from interface:BaseCPMResumes processing that has been paused.
-
kill
public void kill()
Kills the CPM hard. CASes in transit are not processed.
-
stop
public void stop()
Description copied from interface:BaseCPMStops processing.
-
asynchStop
public void asynchStop()
-
displayStats
public void displayStats(ProcessTrace aProcessTrace, int aNumDocsProcessed)
Helper method to display stats and totals- Parameters:
aProcessTrace- - trace containing statsaNumDocsProcessed- - number of entities processed so far
-
buildEventTree
public void buildEventTree(ProcessTraceEvent aEvent, int aTotalTime)
Helper method to help build the CPM report- Parameters:
aEvent-aTotalTime-
-
getPerformanceReport
public ProcessTrace getPerformanceReport()
Returns PerformanceReport for the CPM. This report contains a snapshot of the CPM state.- Specified by:
getPerformanceReportin interfaceBaseCPM- Returns:
- an object containing performance statistics
-
getProgress
public Progress[] getProgress()
Returns current CPE progress. How many entities processed and bytes processed.- Specified by:
getProgressin interfaceBaseCPM- Returns:
- an array of
Progressobjects, each of which represents the progress in a different set of units (for example number of entities or bytes)
-
getDescriptor
public java.lang.String getDescriptor(java.util.List aList) throws ResourceConfigurationExceptionReturns a CPE descriptor as a String- Parameters:
aList- - list of components- Returns:
- - descriptor populated with a given components
- Throws:
ResourceConfigurationException
-
getSynchPoint
public SynchPoint getSynchPoint()
Returns aSynchPointobject initialized by the Collection Reader if the Collection Reader implementsRecoverableCollectionReader. The synchpoint object contains the current snapshot that includes the last document processed.- Returns:
- - instance of SynchPoint if the Collection Reader is recoverable, null otherwise
-
-