org.apache.uima.analysis_engine.impl

## Class MultiprocessingAnalysisEngine_impl

- java.lang.Object
- - org.apache.uima.resource.Resource_ImplBase
  - - org.apache.uima.resource.ConfigurableResource_ImplBase
    - - org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase
      - - org.apache.uima.analysis_engine.impl.MultiprocessingAnalysisEngine_impl

- All Implemented Interfaces:
    AnalysisEngine, TextAnalysisEngine, CasObjectProcessor, CasProcessor, ConfigurableResource, Resource

      public class MultiprocessingAnalysisEngine_impl
      extends AnalysisEngineImplBase
      implements TextAnalysisEngine

  An `AnalysisEngine` implementation that can process multiple `CAS` objects simultaneously. This is accomplished by maintaining a pool of `AnalysisEngine` instances. When initialized, this class checks for the parameter `AnalysisEngine.PARAM_NUM_SIMULTANEOUS_REQUESTS` to determine how many `AnalysisEngine` instances to put in the pool.

- - ### Field Summary

    - ### Fields inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase

      `LOG_RESOURCE_BUNDLE, PARAM_VERIFICATION_MODE`

    - ### Fields inherited from interface org.apache.uima.analysis_engine.AnalysisEngine

      `PARAM_CONFIG_PARAM_SETTINGS, PARAM_MBEAN_NAME_PREFIX, PARAM_MBEAN_SERVER, PARAM_NUM_SIMULTANEOUS_REQUESTS, PARAM_RESOURCE_MANAGER, PARAM_TIMEOUT_PERIOD`

    - ### Fields inherited from interface org.apache.uima.resource.Resource

      `PARAM_AGGREGATE_SOFA_MAPPINGS, PARAM_CONFIG_MANAGER, PARAM_EXTERNAL_OVERRIDE_SETTINGS, PARAM_PERFORMANCE_TUNING_SETTINGS, PARAM_UIMA_CONTEXT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MultiprocessingAnalysisEngine_impl()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `batchProcessComplete()` Notifies this AnalysisEngine that processing of a batch has completed.
    `void` | `collectionProcessComplete()` Notifies this AnalysisEngine that processing of an entire collection has completed.
    `void` | `destroy()` Releases all resources held by this `Resource`.
    `protected org.apache.uima.internal.util.AnalysisEnginePool` | `getPool()` Gets the AnalysisEngine pool used to serve process requests.
    `protected int` | `getTimeout()` Gets the timeout period, after which an exception will be thrown if no AnalysisEngine is available in the pool.
    `boolean` | `initialize(ResourceSpecifier aSpecifier, Map<String,Object> aAdditionalParams)` Initializes this `Resource` from a `ResourceSpecifier`.
    `ProcessTrace` | `process(CAS aCAS)` Invokes this AnalysisEngine's analysis logic.
    `ProcessTrace` | `process(CAS aCAS, ResultSpecification aResultSpec)` Invokes this AnalysisEngine's analysis logic.
    `void` | `process(CAS aCAS, ResultSpecification aResultSpec, ProcessTrace aTrace)` Invokes this AnalysisEngine's analysis logic.
    `ProcessTrace` | `process(JCas aJCas)` Similar to `AnalysisEngine.process(CAS)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.
    `ProcessTrace` | `process(JCas aJCas, ResultSpecification aResultSpec)` Similar to `AnalysisEngine.process(CAS,ResultSpecification)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.
    `void` | `process(JCas aJCas, ResultSpecification aResultSpec, ProcessTrace aTrace)` Similar to `AnalysisEngine.process(CAS, ResultSpecification, ProcessTrace)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.
    `CasIterator` | `processAndOutputNewCASes(CAS aCAS)` Processes a CAS, possibly producing multiple CASes as a result.
    `JCasIterator` | `processAndOutputNewCASes(JCas aJCas)` Default implementation of processAndOutputNewCASes(JCas) method.
    `void` | `reconfigure()` Instructs this Resource to re-read its configuration parameter settings.
    `void` | `setLogger(Logger aLogger)` Set the logger in the current UimaContext for use by user annotators.
    `void` | `setResultSpecification(ResultSpecification aResultSpec)` Sets the list of output types and features that the application wants this AnalysisEngine to produce.

    - ### Methods inherited from class org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase

      `batchProcessComplete, buildProcessTraceFromMBeanStats, buildProcessTraceFromMBeanStats, collectionProcessComplete, createResultSpecification, createResultSpecification, enterBatchProcessComplete, enterCollectionProcessComplete, enterProcess, exitBatchProcessComplete, exitCollectionProcessComplete, exitProcess, finalize, getAnalysisEngineMetaData, getCurrentConfigParameterSettings, getFeatureNamesForType, getManagementInterface, getMBean, getMBeanNamePrefix, getMBeanServer, getPerformanceTuningSettings, getProcessingResourceMetaData, isProcessTraceEnabled, isReadOnly, isStateless, newCAS, newJCas, normalizeIsoLangCodes, process, processCas, processCas, resetResultSpecificationToDefault, setMetaData, setPerformanceTuningSettings, typeSystemInit`

    - ### Methods inherited from class org.apache.uima.resource.ConfigurableResource_ImplBase

      `getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue`

    - ### Methods inherited from class org.apache.uima.resource.Resource_ImplBase

      `getCasManager, getLogger, getMetaData, getRelativePathResolver, getResourceManager, getUimaContext, getUimaContextAdmin`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.uima.analysis_engine.AnalysisEngine

      `createResultSpecification, createResultSpecification, getAnalysisEngineMetaData, getFeatureNamesForType, getLogger, getManagementInterface, getPerformanceTuningSettings, getResourceManager, newCAS, newJCas, process`

    - ### Methods inherited from interface org.apache.uima.resource.ConfigurableResource

      `getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue`

    - ### Methods inherited from interface org.apache.uima.resource.Resource

      `getMetaData, getUimaContext, getUimaContextAdmin`

    - ### Methods inherited from interface org.apache.uima.collection.base_cpm.CasObjectProcessor

      `processCas, processCas, typeSystemInit`

    - ### Methods inherited from interface org.apache.uima.collection.base_cpm.CasProcessor

      `batchProcessComplete, collectionProcessComplete, getProcessingResourceMetaData, isReadOnly, isStateless`

- - ### Constructor Detail

    - #### MultiprocessingAnalysisEngine_impl

          public MultiprocessingAnalysisEngine_impl()

  - ### Method Detail

    - #### initialize

          public boolean initialize(ResourceSpecifier aSpecifier,
                                    Map<String,Object> aAdditionalParams)
                             throws ResourceInitializationException

      Description copied from interface: `Resource`
      Initializes this `Resource` from a `ResourceSpecifier`. Applications do not need to call this method. It is called automatically by the `ResourceFactory` and cannot be called a second time.
      Specified by:
        `initialize` in interface `AnalysisEngine`
      Specified by:
        `initialize` in interface `Resource`
      Overrides:
        `initialize` in class `AnalysisEngineImplBase`
      Parameters:
        `aSpecifier` - specifies how to create a resource or locate an existing resource service.
        `aAdditionalParams` - a Map containing additional parameters. May be `null` if there are no parameters. Each class that implements this interface can decide what additional parameters it supports.
      Returns:
        true if and only if initialization completed successfully. Reutrns false if the given `ResourceSpecifier` is not of an appropriate type for this Resource. If the `ResourceSpecifier` is of an appropriate type but is invalid or if some other failure occurs, an exception should be thrown.
      Throws:
        `ResourceInitializationException` - if a failure occurs during initialization.
      See Also:
        `Resource.initialize(org.apache.uima.resource.ResourceSpecifier, java.util.Map)`

    - #### process

          public ProcessTrace process(CAS aCAS,
                                      ResultSpecification aResultSpec)
                               throws ResultNotSupportedException,
                                      AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's `Capability` specification.)

      This version of the `process` method takes a `ResultSpecification` as an argument. The `ResultSpecification` is alist of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same `ResultSpecification` for multiple calls to `process`, it is not recommended to use this method. Instead call `AnalysisEngine.setResultSpecification(ResultSpecification)` once and then call `AnalysisEngine.process(CAS)` for each CAS that you want to process.

      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aCAS` - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
        `aResultSpec` - a list of outputs that this AnalysisEngine should produce.
      Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
      Throws:
        `ResultNotSupportedException` - if this AnalysisEngine is not capable of producing the results requested in `aResultSpec`.
        `AnalysisEngineProcessException` - if a failure occurs during processing.
      See Also:
        `AnalysisEngine.process(org.apache.uima.cas.CAS, org.apache.uima.analysis_engine.ResultSpecification)`

    - #### process

          public void process(CAS aCAS,
                              ResultSpecification aResultSpec,
                              ProcessTrace aTrace)
                       throws ResultNotSupportedException,
                              AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's `Capability` specification.)

      This version of the `process` method takes a `ResultSpecification` as an argument. The `ResultSpecification` is a list of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same `ResultSpecification` for multiple calls to `process`, it is not recommended to use this method. Instead call `AnalysisEngine.setResultSpecification(ResultSpecification)` once and then call `AnalysisEngine.process(CAS)` for each CAS that you want to process.

      This version of this method also takes a `ProcessTrace` object as a parameter. This allows trace events to be written to an existing `ProcessTrace` rather than a new one.

      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aCAS` - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
        `aResultSpec` - a list of outputs that this AnalysisEngine should produce.
        `aTrace` - the object to which trace events will be recorded
      Throws:
        `ResultNotSupportedException` - if this AnalysisEngine is not capable of producing the results requested in `aResultSpec`.
        `AnalysisEngineProcessException` - if a failure occurs during processing.
      See Also:
        `AnalysisEngine.process(org.apache.uima.cas.CAS, org.apache.uima.analysis_engine.ResultSpecification, org.apache.uima.util.ProcessTrace)`

    - #### processAndOutputNewCASes

          public CasIterator processAndOutputNewCASes(CAS aCAS)
                                               throws AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Processes a CAS, possibly producing multiple CASes as a result. The application uses the `CasIterator` interface to step through the output CASes.

      If this Analysis Engine does not produce output CASes, then the `CasIterator` will return no elements. You can check if an AnalysisEngine is capable of producing output CASes by checking the `OperationalProperties.getOutputsNewCASes()` operational property (`getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes()`).

      Once this method is called, the AnalysisEngine "owns" `aCAS` until such time as the `CasIterator.hasNext()` method returns false. That is, the caller should not attempt to modify or access the input CAS until it has read all of the elements from the CasIterator. If the caller wants to abort the processing before having read all of the output CASes, it may call `CasIterator.release()`, which will stop further processing from occurring, and ownership of `aCAS` will revert to the caller.

      Specified by:
        `processAndOutputNewCASes` in interface `AnalysisEngine`
      Overrides:
        `processAndOutputNewCASes` in class `AnalysisEngineImplBase`
      Parameters:
        `aCAS` - the CAS to be processed
      Returns:
        an object for iterating through any output CASes
      Throws:
        `AnalysisEngineProcessException` - if a failure occurs during processing

    - #### process

          public ProcessTrace process(CAS aCAS)
                               throws AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Invokes this AnalysisEngine's analysis logic. Prior to calling this method, the caller must ensure that the CAS has been populated with the artifact to be analyzed as well as any inputs required by this AnalysisEngine (as defined by this AnalysisEngine's `Capability` specification.)

      This version of `process` does not take a `ResultSpecification` parameter. You may specify a `ResultSpecification` by calling `AnalysisEngine.setResultSpecification(ResultSpecification)` prior to calling this method.

      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aCAS` - the CAS containing the inputs to the processing. Analysis results will also be written to this CAS.
      Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
      Throws:
        `AnalysisEngineProcessException` - if a failure occurs during processing.

    - #### process

          public ProcessTrace process(JCas aJCas)
                               throws AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Similar to `AnalysisEngine.process(CAS)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.
      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aJCas` - the JCas containing the inputs to the processing. Analysis results will also be written to this JCas.
      Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
      Throws:
        `AnalysisEngineProcessException` - if a failure occurs during processing.
      See Also:
        `AnalysisEngine.process(org.apache.uima.jcas.JCas)`

    - #### process

          public ProcessTrace process(JCas aJCas,
                                      ResultSpecification aResultSpec)
                               throws ResultNotSupportedException,
                                      AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Similar to `AnalysisEngine.process(CAS,ResultSpecification)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.

      This version of the `process` method takes a `ResultSpecification` as an argument. The `ResultSpecification` is a list of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same `ResultSpecification` for multiple calls to `process`, it is not recommended to use this method. Instead call `AnalysisEngine.setResultSpecification(ResultSpecification)` once and then call `AnalysisEngine.process(JCas)` for each CAS that you want to process.

      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aJCas` - the JCas containing the inputs to the processing. Analysis results will also be written to this JCas.
        `aResultSpec` - a list of outputs that this AnalysisEngine should produce.
      Returns:
        an object containing information about which AnalysisEngine components have executed and information, such as timing, about that execution.
      Throws:
        `ResultNotSupportedException` - if this AnalysisEngine is not capable of producing the results requested in `aResultSpec`.
        `AnalysisEngineProcessException` - if a failure occurs during processing.
      See Also:
        `AnalysisEngine.process(org.apache.uima.jcas.JCas, org.apache.uima.analysis_engine.ResultSpecification)`

    - #### process

          public void process(JCas aJCas,
                              ResultSpecification aResultSpec,
                              ProcessTrace aTrace)
                       throws ResultNotSupportedException,
                              AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Similar to `AnalysisEngine.process(CAS, ResultSpecification, ProcessTrace)` but uses the Java-object-based `JCas` interface instead of the general `CAS` interface.

      This version of the `process` method takes a `ResultSpecification` as an argument. The `ResultSpecification` is a list of output types and features that the application wants this AnalysisEngine to produce. If you are going to use the same `ResultSpecification` for multiple calls to `process`, it is not recommended to use this method. Instead call `AnalysisEngine.setResultSpecification(ResultSpecification)` once and then call `AnalysisEngine.process(JCas)` for each CAS that you want to process.

      This version of this method also takes a `ProcessTrace` object as a parameter. This allows trace events to be written to an existing `ProcessTrace` rather than a new one.

      Specified by:
        `process` in interface `AnalysisEngine`
      Overrides:
        `process` in class `AnalysisEngineImplBase`
      Parameters:
        `aJCas` - the JCas containing the inputs to the processing. Analysis results will also be written to this JCas.
        `aResultSpec` - a list of outputs that this AnalysisEngine should produce.
        `aTrace` - the object to which trace events will be recorded
      Throws:
        `ResultNotSupportedException` - if this AnalysisEngine is not capable of producing the results requested in `aResultSpec`.
        `AnalysisEngineProcessException` - if a failure occurs during processing.
      See Also:
        `AnalysisEngine.process(org.apache.uima.jcas.JCas, org.apache.uima.analysis_engine.ResultSpecification, org.apache.uima.util.ProcessTrace)`

    - #### processAndOutputNewCASes

          public JCasIterator processAndOutputNewCASes(JCas aJCas)
                                                throws AnalysisEngineProcessException

      Description copied from class: `AnalysisEngineImplBase`
      Default implementation of processAndOutputNewCASes(JCas) method. Calls the version of this method that takes a CAS, then wraps the resulting CasIterator in a JCasIterator.
      Specified by:
        `processAndOutputNewCASes` in interface `AnalysisEngine`
      Overrides:
        `processAndOutputNewCASes` in class `AnalysisEngineImplBase`
      Parameters:
        `aJCas` - the JCAS to be processed
      Returns:
        an object for iterating through any output JCASes
      Throws:
        `AnalysisEngineProcessException` - if a failure occurs during processing

    - #### setResultSpecification

          public void setResultSpecification(ResultSpecification aResultSpec)

      Description copied from interface: `AnalysisEngine`
      Sets the list of output types and features that the application wants this AnalysisEngine to produce. This is only a guideline. Annotators may use this information to avoid doing unnecessary work, but they are not required to do so.
      Specified by:
        `setResultSpecification` in interface `AnalysisEngine`
      Overrides:
        `setResultSpecification` in class `AnalysisEngineImplBase`
      Parameters:
        `aResultSpec` - specifies the list of output types and features that the application is interested in.

    - #### reconfigure

          public void reconfigure()
                           throws ResourceConfigurationException

      Description copied from interface: `ConfigurableResource`
      Instructs this Resource to re-read its configuration parameter settings.
      Specified by:
        `reconfigure` in interface `AnalysisEngine`
      Specified by:
        `reconfigure` in interface `ConfigurableResource`
      Overrides:
        `reconfigure` in class `ConfigurableResource_ImplBase`
      Throws:
        `ResourceConfigurationException` - if the configuration is not valid
      See Also:
        `ConfigurableResource.reconfigure()`

    - #### destroy

          public void destroy()

      Description copied from interface: `Resource`
      Releases all resources held by this `Resource`.
      Specified by:
        `destroy` in interface `Resource`
      Overrides:
        `destroy` in class `Resource_ImplBase`
      See Also:
        `Resource.destroy()`

    - #### setLogger

          public void setLogger(Logger aLogger)

      Description copied from class: `Resource_ImplBase`
      Set the logger in the current UimaContext for use by user annotators.
      Specified by:
        `setLogger` in interface `AnalysisEngine`
      Specified by:
        `setLogger` in interface `Resource`
      Overrides:
        `setLogger` in class `Resource_ImplBase`
      Parameters:
        `aLogger` - the logger for this Resource to use
      See Also:
        `AnalysisEngine.setLogger(org.apache.uima.util.Logger)`

    - #### batchProcessComplete

          public void batchProcessComplete()
                                    throws AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Notifies this AnalysisEngine that processing of a batch has completed. It is up to the caller to determine the size of a batch. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.
      Specified by:
        `batchProcessComplete` in interface `AnalysisEngine`
      Overrides:
        `batchProcessComplete` in class `AnalysisEngineImplBase`
      Throws:
        `AnalysisEngineProcessException` - if an exception occurs during processing

    - #### collectionProcessComplete

          public void collectionProcessComplete()
                                         throws AnalysisEngineProcessException

      Description copied from interface: `AnalysisEngine`
      Notifies this AnalysisEngine that processing of an entire collection has completed. It is up to the caller to determine when this has occurred. Components (particularly CAS Consumers) inside this Analysis Engine may respond to this event, for example by writing data to the disk.

      If this AnalysisEngine is an aggregate, this method will call the collectionProcessComplete method of all components of that aggregate. If the aggregate descriptor declares a `fixedFlow` or `capabilityLanguageFlow`, then the components' collectionProcessComplete methods will be called in the order specified by that flow element. Once all components in the flow have been called, any components not declared in the flow will be called, in arbitrary order. If there is no `fixedFlow` or `capabilityLanguageFlow`, then all components in the aggregate will be called in arbitrary order.

      Specified by:
        `collectionProcessComplete` in interface `AnalysisEngine`
      Overrides:
        `collectionProcessComplete` in class `AnalysisEngineImplBase`
      Throws:
        `AnalysisEngineProcessException` - if an exception occurs during processing

    - #### getPool

          protected org.apache.uima.internal.util.AnalysisEnginePool getPool()

      Gets the AnalysisEngine pool used to serve process requests.
      Returns:
        the AnalysisEngine pool

    - #### getTimeout

          protected int getTimeout()

      Gets the timeout period, after which an exception will be thrown if no AnalysisEngine is available in the pool.
      Returns:
        the timeout period in milliseconds

Copyright © 2006–2021 The Apache Software Foundation. All rights reserved.