Class BaseAnalysisEngineController

    • Field Detail

      • statsMap

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.Long> statsMap
      • monitor

        protected Monitor monitor
      • clientEndpoint

        protected Endpoint clientEndpoint
      • resourceSpecifier

        protected org.apache.uima.resource.ResourceSpecifier resourceSpecifier
      • paramsMap

        protected java.util.HashMap paramsMap
      • errorCount

        protected long errorCount
      • inputChannelList

        protected java.util.List inputChannelList
      • inputChannelMap

        protected java.util.concurrent.ConcurrentHashMap inputChannelMap
      • componentCasPoolSize

        protected int componentCasPoolSize
      • replyTime

        protected long replyTime
      • idleTime

        protected long idleTime
      • serviceErrorMap

        protected java.util.concurrent.ConcurrentHashMap serviceErrorMap
      • jmxContext

        protected java.lang.String jmxContext
      • stopped

        protected volatile boolean stopped
      • delegateKey

        protected java.lang.String delegateKey
      • unregisteredDelegateList

        protected java.util.List unregisteredDelegateList
      • allDelegatesAreRemote

        protected volatile boolean allDelegatesAreRemote
      • controllerListeners

        protected java.util.List controllerListeners
      • serviceInitialized

        protected volatile boolean serviceInitialized
      • perCasStatistics

        protected java.util.concurrent.ConcurrentHashMap perCasStatistics
      • syncObject

        protected java.lang.Object syncObject
      • cmOutstandingCASes

        protected java.util.concurrent.ConcurrentHashMap cmOutstandingCASes
      • finalStepMux

        protected final java.lang.Object finalStepMux
      • transports

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​UimaTransport> transports
      • messageListeners

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​UimaMessageListener> messageListeners
      • aeDescriptor

        protected java.lang.String aeDescriptor
      • delegates

        protected java.util.List<Delegate> delegates
      • callbackReceived

        protected volatile boolean callbackReceived
      • callbackMonitor

        protected java.lang.Object callbackMonitor
      • awaitingCacheCallbackNotification

        protected volatile boolean awaitingCacheCallbackNotification
      • abortedCasesMap

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.String> abortedCasesMap
      • processPid

        protected java.lang.String processPid
      • deadClientDestinationMap

        protected java.util.concurrent.ConcurrentHashMap<java.lang.String,​java.lang.String> deadClientDestinationMap
    • Constructor Detail

      • BaseAnalysisEngineController

        public BaseAnalysisEngineController()
      • BaseAnalysisEngineController

        public BaseAnalysisEngineController​(AnalysisEngineController aParentController,
                                            int aComponentCasPoolSize,
                                            java.lang.String anEndpointName,
                                            java.lang.String aDescriptor,
                                            AsynchAECasManager aCasManager,
                                            InProcessCache anInProcessCache)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • BaseAnalysisEngineController

        public BaseAnalysisEngineController​(AnalysisEngineController aParentController,
                                            int aComponentCasPoolSize,
                                            java.lang.String anEndpointName,
                                            java.lang.String aDescriptor,
                                            AsynchAECasManager aCasManager,
                                            InProcessCache anInProcessCache,
                                            java.util.Map aDestinationMap)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • BaseAnalysisEngineController

        public BaseAnalysisEngineController​(AnalysisEngineController aParentController,
                                            int aComponentCasPoolSize,
                                            java.lang.String anEndpointName,
                                            java.lang.String aDescriptor,
                                            AsynchAECasManager aCasManager,
                                            InProcessCache anInProcessCache,
                                            java.util.Map aDestinationMap,
                                            JmxManagement aJmxManagement)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • BaseAnalysisEngineController

        public BaseAnalysisEngineController​(AnalysisEngineController aParentController,
                                            int aComponentCasPoolSize,
                                            long anInitialCasHeapSize,
                                            java.lang.String anEndpointName,
                                            java.lang.String aDescriptor,
                                            AsynchAECasManager aCasManager,
                                            InProcessCache anInProcessCache,
                                            java.util.Map aDestinationMap,
                                            JmxManagement aJmxManagement)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • dumpState

        public abstract void dumpState​(java.lang.StringBuffer buffer,
                                       java.lang.String lbl1)
        Specified by:
        dumpState in interface AnalysisEngineController
      • getTransport

        public UimaTransport getTransport​(UimaAsContext asContext)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • initializeVMTransport

        public void initializeVMTransport​(int parentControllerReplyConsumerCount)
                                   throws java.lang.Exception
        Initializes transport used for internal messaging between collocated Uima AS services.
        Specified by:
        initializeVMTransport in interface AnalysisEngineController
        Throws:
        java.lang.Exception
      • getJMXDomain

        public java.lang.String getJMXDomain()
        Get the domain for Uima JMX. The domain includes a fixed string plus the name of the top level component. All uima ee objects are rooted at this domain.
        Specified by:
        getJMXDomain in interface AnalysisEngineController
      • getIndex

        public int getIndex()
        Returns a unique id for each component in the service hierarchy. The top level component's id is always = 0
        Specified by:
        getIndex in interface AnalysisEngineController
      • getJmxContext

        public java.lang.String getJmxContext()
        This is called once during initialization to compute the position of the component in the JMX hierarchy and create a context path that will be used to register the component in the JMX registry.
        Specified by:
        getJmxContext in interface AnalysisEngineController
      • registerWithAgent

        protected void registerWithAgent​(java.lang.Object o,
                                         java.lang.String aName)
        Register a component with a given name with JMX MBeanServer
        Parameters:
        o - - component to register with JMX
        aName - - full jmx context name for the component
      • registerVmQueueWithJMX

        public void registerVmQueueWithJMX​(java.lang.Object o,
                                           java.lang.String aName)
                                    throws java.lang.Exception
        Specified by:
        registerVmQueueWithJMX in interface AnalysisEngineController
        Throws:
        java.lang.Exception
      • registerServiceWithJMX

        protected void registerServiceWithJMX​(java.lang.String key_value_list,
                                              boolean remote)
      • cleanUp

        protected void cleanUp()
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • setJmxManagement

        public void setJmxManagement​(JmxManagement aJmxManagement)
        Override the default JmxManager
      • getComponentName

        public java.lang.String getComponentName()
        Returns the name of the component. The name comes from the analysis engine descriptor
        Specified by:
        getComponentName in interface AnalysisEngineController
      • toString

        public java.lang.String toString()
        Print the component name rather than the class name
        Overrides:
        toString in class java.lang.Object
      • getChildUimaContext

        public org.apache.uima.UimaContext getChildUimaContext​(java.lang.String aDelegateEndpointName)
                                                        throws java.lang.Exception
        Specified by:
        getChildUimaContext in interface AnalysisEngineController
        Throws:
        java.lang.Exception
      • handleAction

        protected void handleAction​(java.lang.String anAction,
                                    java.lang.String anEndpoint,
                                    ErrorContext anErrorContext)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • plugInDefaultErrorHandlerChain

        protected void plugInDefaultErrorHandlerChain()
      • setErrorHandlerChain

        public void setErrorHandlerChain​(ErrorHandlerChain errorHandlerChain)
      • handleError

        public void handleError​(java.util.HashMap aMap,
                                java.lang.Throwable e)
      • dropCAS

        public void dropCAS​(java.lang.String aCasReferenceId,
                            boolean deleteCacheEntry)
        Specified by:
        dropCAS in interface AnalysisEngineController
      • saveTime

        public void saveTime​(long aTime,
                             java.lang.String aCasReferenceId,
                             java.lang.String anEndpointName)
        Specified by:
        saveTime in interface AnalysisEngineController
      • getTime

        public long getTime​(java.lang.String aCasReferenceId,
                            java.lang.String anEndpointName)
        Specified by:
        getTime in interface AnalysisEngineController
      • resetErrorCounter

        protected void resetErrorCounter()
      • incrementErrorCounter

        protected void incrementErrorCounter()
      • exceedsThresholdWithinWindow

        protected boolean exceedsThresholdWithinWindow​(int threshold,
                                                       long docCount,
                                                       int windowSize)
      • getResourceSpecifier

        protected org.apache.uima.resource.ResourceSpecifier getResourceSpecifier()
      • process

        public void process​(org.apache.uima.cas.CAS aCAS,
                            java.lang.String anInputCasReferenceId,
                            java.lang.String aNewCasReferenceId,
                            java.lang.String newCASProducedBy)
        Specified by:
        process in interface AnalysisEngineController
      • dropStats

        public void dropStats​(java.lang.String aCasReferenceId,
                              java.lang.String anEndpointName)
        Removes statistics from the global Map
        Specified by:
        dropStats in interface AnalysisEngineController
      • logStats

        protected void logStats()
      • getCasStatistics

        public ServicePerformance getCasStatistics​(java.lang.String aCasReferenceId)
        Returns stats associated with a given CAS. A service uses a global map to store CAS level statistics. A key to the map is the CAS id. This method creates a new instance of ServicePerformance object if one doesnt exist in the map for a given CAS id.
        Specified by:
        getCasStatistics in interface AnalysisEngineController
      • logStats

        protected void logStats​(java.lang.String aDelegateKey,
                                ServicePerformance aServicePerformance)
        Logs statistics
        Parameters:
        aDelegateKey -
        aDelegateServicePerformance -
      • clearStats

        protected void clearStats()
        Clears controller statistics.
      • getServiceName

        public java.lang.String getServiceName()
      • getDeploymentDescriptor

        public java.lang.String getDeploymentDescriptor()
      • getDeploymentMode

        public java.lang.String getDeploymentMode()
      • getBrokerURL

        public java.lang.String getBrokerURL()
      • getInputQueue

        public java.lang.String getInputQueue()
      • getTotalTimeSpentSerializingCAS

        public long getTotalTimeSpentSerializingCAS()
      • getTotalTimeSpendDeSerializingCAS

        public long getTotalTimeSpendDeSerializingCAS()
      • getTotalTimeSpentWaitingForFreeCASInstance

        public long getTotalTimeSpentWaitingForFreeCASInstance()
      • getTotalNumberOfCASesReceived

        public long getTotalNumberOfCASesReceived()
      • getTotalNumberOfCASesProcessed

        public long getTotalNumberOfCASesProcessed()
      • getTotalNumberOfCASesDropped

        public long getTotalNumberOfCASesDropped()
      • getTotalNumberOfErrors

        public long getTotalNumberOfErrors()
      • isStopped

        public boolean isStopped()
        Return true if this service is in the shutdown state
        Specified by:
        isStopped in interface AnalysisEngineController
        Returns:
        - true if stopped
      • stopTransportLayer

        protected void stopTransportLayer()
      • stop

        public void stop()
        Stops input channel(s) and initiates a shutdown of all delegates ( if this is an aggregate ). At the end sends an Exception to the client and closes an output channel.
        Specified by:
        stop in interface AnalysisEngineController
      • stop

        public void stop​(java.lang.Throwable cause,
                         java.lang.String aCasReferenceId)
      • quiesceAndStop

        public void quiesceAndStop()
        Stops input channel(s) and waits for CASes still in play to complete processing. When the InProcessCache becomes empty, initiate the service shutdown.
        Specified by:
        quiesceAndStop in interface AnalysisEngineController
      • stopDelegateTimers

        protected void stopDelegateTimers()
      • terminate

        public void terminate()
        Using a reference to its parent, propagates the terminate event to the top level controller. Typically invoked, when the error handling detects excessive errors and action=terminate. The top level controller, stops its input channel and instructs a colocated Cas Multiplier (it it has one) to stop generating new CASes. It then registers self as a listener with the InProcessCache. The callback will be called when the InProcessCache becomes empty. Only then, the top level controller will call stop() on each of a delegates (if the top level is an aggregate).
        Specified by:
        terminate in interface ControllerLifecycle
      • terminate

        public void terminate​(java.lang.Throwable cause,
                              java.lang.String aCasReferenceId)
      • stopCasMultipliers

        public void stopCasMultipliers()
      • stopCasMultiplier

        public void stopCasMultiplier​(Delegate casMultiplier,
                                      java.lang.String aCasReferenceId)
      • stopInputChannel

        protected void stopInputChannel()
        Stops a listener on the main input channel
      • stopInputChannels

        protected void stopInputChannels​(int channelsToStop)
      • getCasMultiplierController

        public AnalysisEngineController getCasMultiplierController​(java.lang.String cmKey)
        Aggregates have more than one Listener channel. This method stops all configured input channels this service is configured with.
      • onCacheEmpty

        public void onCacheEmpty()
        Callback method called the InProcessCache becomes empty meaning ALL CASes are processed. The callback is only active when the the top level component is in the process of shutting down.
        Specified by:
        onCacheEmpty in interface EventSubscriber
      • dropCasStatistics

        protected void dropCasStatistics​(java.lang.String aCasReferenceId)
      • getCpuTime

        public long getCpuTime()
        Returns CPU Time with nanosecond precision (not nanosecond accuracy). If the OS/JVM does not support reporting the CPU Time, returns the wall clock time.
        Specified by:
        getCpuTime in interface AnalysisEngineController
      • getAnalysisTime

        public long getAnalysisTime()
        Returns the total CPU time all processing threads spent in analysis. This method subtracts the serialization and de-serialization time from the total. If this service is an aggregate, the return time is a sum of CPU utilization in each colocated delegate.
        Specified by:
        getAnalysisTime in interface AnalysisEngineController
      • sendMetadata

        public void sendMetadata​(Endpoint anEndpoint,
                                 org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData metadata)
      • abortGeneratingCASes

        protected boolean abortGeneratingCASes​(java.lang.String aCasReferenceId)
        Returns true if a given CAS id is in the list of aborted CASes.
        Parameters:
        aCasReferenceId - - id of the current input CAS being processed
        Returns:
        - true if the CAS is in the list of aborted CASes, false otherwise