Class BaseCPMImpl
java.lang.Object
org.apache.uima.collection.impl.cpm.BaseCPMImpl
- Direct Known Subclasses:
CPMImpl
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 inherited from interface org.apache.uima.collection.base_cpm.BaseCPM
DOCUMENT_TEXT_FEATURE, DOCUMENT_TEXT_TYPE
-
Constructor Summary
ConstructorDescriptionBaseCPMImpl
(Boolean mode, String aDescriptor, ResourceManager aResourceManager) Parses CPE descriptor.BaseCPMImpl
(CpeDescription aDescriptor) Instantiates and initializes CPE Factory with a given CPE Descriptor and defaults.BaseCPMImpl
(CpeDescription aDescriptor, ResourceManager aResourceManager, boolean aDefaultProcessTrace, Properties aProps) Instantiates and initializes CPE Factory responsible for creating individual components that are part of the processing pipeline. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCasProcessor
(CasProcessor aCasProcessor) Adds aCasProcessor
to this CPM's list of consumers.void
addCasProcessor
(CasProcessor aCasProcessor, int aIndex) Adds aCasProcessor
to this CPM's list of consumers.void
Registers a listsner to receive status callbacks.void
Asynch stop.void
buildEventTree
(ProcessTraceEvent aEvent, int aTotalTime) Helper method to help build the CPM report.void
disableCasProcessor
(String aCasProcessorName) Disables aCasProcessor
in this CPM's list of CasProcessors.void
displayStats
(ProcessTrace aProcessTrace, int aNumDocsProcessed) Helper method to display stats and totals.void
enableCasProcessor
(String aCasProcessorName) Enable cas processor.void
Called to cleanup CPE on shutdown.Gets theCasProcessors
s assigned to this CPM, in the order in which they will be called by the CPM.Returns a Collection Reader for this CPE.ReturnsCPEConfig
object holding current CPE configuration.getDescriptor
(List aList) Returns a CPE descriptor as a String.Returns PerformanceReport for the CPM.Progress[]
Returns current CPE progress.Returns aSynchPoint
object initialized by the Collection Reader if the Collection Reader implementsRecoverableCollectionReader
.void
init
(boolean aDummyCasProcessor, Properties aProps) Instantiates and initializes a CPE.boolean
isPaused()
Determines whether this CPM's processing is currently paused.boolean
Gets whether this CPM will automatically pause processing if an exception occurs.boolean
Determines whether this CPM is currently processing.boolean
Gets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization).void
kill()
Kills the CPM hard.void
pause()
Pauses processing.void
process()
This method is called by an application to begin processing given Collection.void
process
(BaseCollectionReader aCollectionReader) Deprecated.void
process
(BaseCollectionReader aCollectionReader, int aBatchSize) Deprecated.void
removeCasProcessor
(CasProcessor aCasProcessor) Removes aCasProcessor
to this CPM's list of consumers.void
Unregisters a status callback listener.void
resume()
Resumes processing that has been paused.void
resume
(boolean aRetryFailed) Resumes processing that has been paused.void
run()
void
setCollectionReader
(BaseCollectionReader aCollectionReader) Sets the Collection Reader for this CPE.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.void
setPauseOnException
(boolean aPause) Sets whether this CPM will automatically pause processing if an exception occurs.void
setPerformanceTuningSettings
(Properties aPerformanceTuningSettings) Plugs in custom perfomance tunning parameters.void
Plugs in a givenProcessControllerAdapter
.void
setSerialProcessingRequired
(boolean aRequired) Sets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization).void
stop()
Stops processing.
-
Field Details
-
cpmExecutorService
The CPE executor service.
-
-
Constructor Details
-
BaseCPMImpl
Instantiates and initializes CPE Factory with a given CPE Descriptor and defaults.- Parameters:
aDescriptor
- - parsed CPE descriptor- Throws:
Exception
- -
-
BaseCPMImpl
public BaseCPMImpl(CpeDescription aDescriptor, ResourceManager aResourceManager, boolean aDefaultProcessTrace, Properties aProps) throws 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 statsaProps
- the a props- Throws:
Exception
- -
-
BaseCPMImpl
public BaseCPMImpl(Boolean mode, String aDescriptor, ResourceManager aResourceManager) throws Exception Parses 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:
Exception
- -
-
-
Method Details
-
setPerformanceTuningSettings
Plugs in custom perfomance tunning parameters.- Parameters:
aPerformanceTuningSettings
- the new performance tuning settings
-
setProcessControllerAdapter
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
- the new jedii report
-
init
Instantiates and initializes a CPE.- Parameters:
aDummyCasProcessor
- -aProps
- the a props- Throws:
Exception
- -
-
getCPEConfig
ReturnsCPEConfig
object holding current CPE configuration.- Returns:
- CPEConfig instance
- Throws:
Exception
- -
-
getCasProcessors
Description copied from interface:BaseCPM
Gets theCasProcessors
s assigned to this CPM, in the order in which they will be called by the CPM.- Specified by:
getCasProcessors
in interfaceBaseCPM
- Returns:
- an array of
CasProcessor
s
-
addCasProcessor
Description copied from interface:BaseCPM
Adds aCasProcessor
to this CPM's list of consumers. The new CasProcessor will be added to the end of the list of CAS Processors.- Specified by:
addCasProcessor
in interfaceBaseCPM
- Parameters:
aCasProcessor
- aCasProcessor
to add- Throws:
ResourceConfigurationException
- if this CPM is currently processing
-
addCasProcessor
public void addCasProcessor(CasProcessor aCasProcessor, int aIndex) throws ResourceConfigurationException Description copied from interface:BaseCPM
Adds aCasProcessor
to this CPM's list of consumers. The new CasProcessor will be added at the specified index.- Specified by:
addCasProcessor
in interfaceBaseCPM
- Parameters:
aCasProcessor
- the CasProcessor to addaIndex
- the index at which to add the CasProcessor- Throws:
ResourceConfigurationException
- if this CPM is currently processing
-
removeCasProcessor
Description copied from interface:BaseCPM
Removes aCasProcessor
to this CPM's list of consumers.- Specified by:
removeCasProcessor
in interfaceBaseCPM
- Parameters:
aCasProcessor
- theCasProcessor
to remove
-
disableCasProcessor
Description copied from interface:BaseCPM
Disables aCasProcessor
in this CPM's list of CasProcessors.- Specified by:
disableCasProcessor
in interfaceBaseCPM
- Parameters:
aCasProcessorName
- the name of theCasProcessor
to disable
-
enableCasProcessor
Enable cas processor.- Parameters:
aCasProcessorName
- the a cas processor name
-
isSerialProcessingRequired
public boolean isSerialProcessingRequired()Description copied from interface:BaseCPM
Gets whether this CPM is required to process the collection's elements serially (as opposed to performing parallelization). Note that a value offalse
does not guarantee that parallelization is performed; this is left up to the CPM implementation.- Specified by:
isSerialProcessingRequired
in interfaceBaseCPM
- Returns:
- true if and only if serial processing is required
-
setSerialProcessingRequired
public void setSerialProcessingRequired(boolean aRequired) Description copied from interface:BaseCPM
Sets 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 offalse
does not guarantee that parallelization is performed; this is left up to the CPM implementation.- Specified by:
setSerialProcessingRequired
in interfaceBaseCPM
- Parameters:
aRequired
- true if and only if serial processing is required
-
isPauseOnException
public boolean isPauseOnException()Description copied from interface:BaseCPM
Gets 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:
isPauseOnException
in interfaceBaseCPM
- Returns:
- true if and only if this CPM will pause on exception
-
setPauseOnException
public void setPauseOnException(boolean aPause) Description copied from interface:BaseCPM
Sets 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:
setPauseOnException
in interfaceBaseCPM
- Parameters:
aPause
- true if and only if this CPM should pause on exception
-
addStatusCallbackListener
Description copied from interface:BaseCPM
Registers a listsner to receive status callbacks.- Specified by:
addStatusCallbackListener
in interfaceBaseCPM
- Parameters:
aListener
- the listener to add
-
removeStatusCallbackListener
Description copied from interface:BaseCPM
Unregisters a status callback listener.- Specified by:
removeStatusCallbackListener
in interfaceBaseCPM
- Parameters:
aListener
- the listener to remove
-
run
public void run() -
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.- Parameters:
aCollectionReader
- the a collection reader- Throws:
ResourceInitializationException
- the resource initialization exception- See Also:
-
process
This method is called by an application to begin processing given Collection. It creates a new thread, adds it to a ThreadGroup and starts it.- Specified by:
process
in interfaceBaseCPM
- Throws:
ResourceInitializationException
- if an error occurs during initialization- See Also:
-
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.- Parameters:
aCollectionReader
- the a collection readeraBatchSize
- the a batch size- Throws:
ResourceInitializationException
- the resource initialization exception- See Also:
-
setCollectionReader
Sets the Collection Reader for this CPE.- Specified by:
setCollectionReader
in interfaceBaseCPM
- Parameters:
aCollectionReader
- the collection reader
-
getCollectionReader
Returns a Collection Reader for this CPE.- Specified by:
getCollectionReader
in interfaceBaseCPM
- Returns:
- the collection reader
-
isProcessing
public boolean isProcessing()Description copied from interface:BaseCPM
Determines 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:
isProcessing
in interfaceBaseCPM
- Returns:
- true if and only if this CPM is currently processing.
-
pause
public void pause()Description copied from interface:BaseCPM
Pauses processing. Processing can later be resumed by calling theBaseCPM.resume(boolean)
method. -
isPaused
public boolean isPaused()Description copied from interface:BaseCPM
Determines whether this CPM's processing is currently paused. -
resume
public void resume(boolean aRetryFailed) Description copied from interface:BaseCPM
Resumes processing that has been paused.- Specified by:
resume
in interfaceBaseCPM
- Parameters:
aRetryFailed
- if processing was paused because an exception occurred (seeBaseCPM.setPauseOnException(boolean)
), setting a value oftrue
for 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:BaseCPM
Resumes 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:BaseCPM
Stops processing. -
asynchStop
public void asynchStop()Asynch stop. -
displayStats
Helper method to display stats and totals.- Parameters:
aProcessTrace
- - trace containing statsaNumDocsProcessed
- - number of entities processed so far
-
buildEventTree
Helper method to help build the CPM report.- Parameters:
aEvent
- the a eventaTotalTime
- the a total time
-
getPerformanceReport
Returns PerformanceReport for the CPM. This report contains a snapshot of the CPM state.- Specified by:
getPerformanceReport
in interfaceBaseCPM
- Returns:
- the performance report
-
getProgress
Returns current CPE progress. How many entities processed and bytes processed.- Specified by:
getProgress
in interfaceBaseCPM
- Returns:
- the progress
-
getDescriptor
Returns a CPE descriptor as a String.- Parameters:
aList
- - list of components- Returns:
- - descriptor populated with a given components
- Throws:
ResourceConfigurationException
- the resource configuration exception
-
getSynchPoint
Returns aSynchPoint
object 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
-