Package org.apache.uima.aae.controller
Class BaseAnalysisEngineController
java.lang.Object
org.apache.uima.resource.Resource_ImplBase
org.apache.uima.aae.controller.BaseAnalysisEngineController
- All Implemented Interfaces:
AnalysisEngineController,ControllerLifecycle,EventSubscriber,org.apache.uima.resource.Resource
- Direct Known Subclasses:
AggregateAnalysisEngineController_impl,PrimitiveAnalysisEngineController_impl
public abstract class BaseAnalysisEngineController
extends org.apache.uima.resource.Resource_ImplBase
implements AnalysisEngineController, EventSubscriber
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentHashMap<String,String> protected Stringprotected booleanprotected booleanprotected Objectprotected booleanprotected Endpointprotected ConcurrentHashMapprotected intprotected Listprotected ConcurrentHashMap<String,String> protected Stringprotected longprotected ErrorHandlerChainprotected final Objectprotected longprotected InputChannelprotected Listprotected ConcurrentHashMapprotected Stringprotected ControllerLatchprotected LocalCacheprotected ConcurrentHashMap<String,UimaMessageListener> protected Monitorstatic final booleanprotected HashMapprotected AnalysisEngineControllerprotected ConcurrentHashMapprotected Stringprotected longprotected org.apache.uima.resource.ResourceSpecifierprotected ConcurrentHashMapprotected ServiceErrorsprotected booleanprotected ServicePerformanceprotected ConcurrentHashMap<String,Long> protected booleanprotected Objectprotected ConcurrentHashMap<String,UimaTransport> protected ListFields inherited from interface org.apache.uima.aae.controller.AnalysisEngineController
AEInstanceCount, CasPoolSizeFields inherited from interface org.apache.uima.resource.Resource
PARAM_AGGREGATE_SOFA_MAPPINGS, PARAM_CONFIG_MANAGER, PARAM_CONFIG_PARAM_SETTINGS, PARAM_EXTERNAL_OVERRIDE_SETTINGS, PARAM_PERFORMANCE_TUNING_SETTINGS, PARAM_RESOURCE_MANAGER, PARAM_UIMA_CONTEXT -
Constructor Summary
ConstructorsConstructorDescriptionBaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, long anInitialCasHeapSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap, JmxManagement aJmxManagement) BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache) BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap) BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap, JmxManagement aJmxManagement) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanabortGeneratingCASes(String aCasReferenceId) Returns true if a given CAS id is in the list of aborted CASes.voidaddAbortedCasReferenceId(String aCasReferenceId) voidRegister one or more listeners through which the controller can send notification of events.voidaddInputChannel(InputChannel anInputChannel) voidaddServiceInfo(ServiceInfo aServiceInfo) voidbeginProcess(int msgType) voidcacheClientEndpoint(Endpoint anEndpoint) voidprotected voidcleanUp()protected voidClears controller statistics.voidvoiddropCAS(org.apache.uima.cas.CAS aCAS) protected voiddropCasStatistics(String aCasReferenceId) voidRemoves statistics from the global Mapabstract voiddumpState(StringBuffer buffer, String lbl1) voidendProcess(int msgType) protected booleanexceedsThresholdWithinWindow(int threshold, long docCount, int windowSize) voidlongReturns the total CPU time all processing threads spent in analysis.getCasMultiplierController(String cmKey) Aggregates have more than one Listener channel.getCasStatistics(String aCasReferenceId) Returns stats associated with a given CAS.org.apache.uima.UimaContextgetChildUimaContext(String aDelegateEndpointName) Returns the name of the component.longReturns CPU Time with nanosecond precision (not nanosecond accuracy).Returns interface via which this instance receives callbackslonglonggetIdleTimeBetweenProcessCalls(int msgType) intgetIndex()Returns a unique id for each component in the service hierarchy.getInputChannel(String anEndpointName) 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.Get the domain for Uima JMX.getKey()getName()getReplyInputChannel(String aDelegateKey) longprotected org.apache.uima.resource.ResourceSpecifiergetState()getStats()Returns a copy of the controller statistics.longlonglonglonglonglonglonglonggetTransport(String aKey) getTransport(UimaAsContext asContext) getTransport(UimaAsContext asContext, String aKey) getUimaMessageListener(String aDelegateKey) protected voidhandleAction(String anAction, String anEndpoint, ErrorContext anErrorContext) voidhandleError(HashMap aMap, Throwable e) voidincrementDeserializationTime(long cpuTime) Increments the time this thread spent in deserialization of a CASprotected voidvoidincrementSerializationTime(long cpuTime) Increments the time this thread spent in serialization of a CASvoidinitializeVMTransport(int parentControllerReplyConsumerCount) Initializes transport used for internal messaging between collocated Uima AS services.booleanbooleanbooleanReturn true if this service is in the shutdown statebooleanprotected voidlogStats()protected voidlogStats(String aDelegateKey, ServicePerformance aServicePerformance) Logs statisticsvoidvoidCallback method called the InProcessCache becomes empty meaning ALL CASes are processed.protected voidvoidvoidprocess(org.apache.uima.cas.CAS aCAS, String anInputCasReferenceId, String aNewCasReferenceId, String newCASProducedBy) voidvoidStops input channel(s) and waits for CASes still in play to complete processing.protected voidregisterServiceWithJMX(String key_value_list, boolean remote) voidregisterVmQueueWithJMX(Object o, String aName) protected voidregisterWithAgent(Object o, String aName) Register a component with a given name with JMX MBeanServervoidreleaseNextCas(String casReferenceId) voidRemoves named application listener.protected voidvoidsaveReplyTime(long snapshot, String aKey) voidvoidsendMetadata(Endpoint anEndpoint, org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData metadata) voidsetCasManager(AsynchAECasManager casManager) voidsetDeployDescriptor(String aDeployDescriptor) voidsetErrorHandlerChain(ErrorHandlerChain errorHandlerChain) voidsetInputChannel(InputChannel anInputChannel) voidsetJmxManagement(JmxManagement aJmxManagement) Override the default JmxManagervoidsetOutputChannel(OutputChannel outputChannel) voidCalled to set the state of the AnalysisEngineController to STOPPED.voidsetUimaEEAdminContext(UimaEEAdminContext anAdminContext) voidstop()Stops input channel(s) and initiates a shutdown of all delegates ( if this is an aggregate ).voidvoidstopCasMultiplier(Delegate casMultiplier, String aCasReferenceId) voidprotected voidprotected voidStops a listener on the main input channelprotected voidstopInputChannels(int channelsToStop) protected voidvoidUsing a reference to its parent, propagates the terminate event to the top level controller.voidtoString()Print the component name rather than the class nameMethods inherited from class org.apache.uima.resource.Resource_ImplBase
destroy, getCasManager, getLogger, getMetaData, getRelativePathResolver, getResourceManager, getUimaContext, getUimaContextAdmin, initialize, setLogger, setMetaDataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.uima.aae.controller.AnalysisEngineController
collectionProcessComplete, getControllerLatch, getMonitor, getServiceEndpointName, getServiceInfo, handleDelegateLifeCycleEvent, initialize, isPrimitive, onInitialize, sendMetadata, takeAction
-
Field Details
-
NO_RECOVERY
public static final boolean NO_RECOVERY- See Also:
-
currentState
-
latch
-
statsMap
-
monitor
-
clientEndpoint
-
parentController
-
resourceSpecifier
protected org.apache.uima.resource.ResourceSpecifier resourceSpecifier -
paramsMap
-
inputChannel
-
errorHandlerChain
-
errorCount
protected long errorCount -
inputChannelList
-
inputChannelMap
-
componentCasPoolSize
protected int componentCasPoolSize -
replyTime
protected long replyTime -
idleTime
protected long idleTime -
serviceErrorMap
-
jmxContext
-
servicePerformance
-
serviceErrors
-
stopped
protected volatile boolean stopped -
delegateKey
-
unregisteredDelegateList
-
allDelegatesAreRemote
protected volatile boolean allDelegatesAreRemote -
controllerListeners
-
serviceInitialized
protected volatile boolean serviceInitialized -
perCasStatistics
-
syncObject
-
cmOutstandingCASes
-
finalStepMux
-
transports
-
messageListeners
-
localCache
-
aeDescriptor
-
delegates
-
callbackReceived
protected volatile boolean callbackReceived -
callbackMonitor
-
awaitingCacheCallbackNotification
protected volatile boolean awaitingCacheCallbackNotification -
abortedCasesMap
-
processPid
-
deadClientDestinationMap
-
-
Constructor Details
-
BaseAnalysisEngineController
public BaseAnalysisEngineController() -
BaseAnalysisEngineController
public BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache) throws Exception - Throws:
Exception
-
BaseAnalysisEngineController
public BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap) throws Exception - Throws:
Exception
-
BaseAnalysisEngineController
public BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap, JmxManagement aJmxManagement) throws Exception - Throws:
Exception
-
BaseAnalysisEngineController
public BaseAnalysisEngineController(AnalysisEngineController aParentController, int aComponentCasPoolSize, long anInitialCasHeapSize, String anEndpointName, String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache, Map aDestinationMap, JmxManagement aJmxManagement) throws Exception - Throws:
Exception
-
-
Method Details
-
dumpState
- Specified by:
dumpStatein interfaceAnalysisEngineController
-
getParentController
- Specified by:
getParentControllerin interfaceAnalysisEngineController
-
getTransport
- Specified by:
getTransportin interfaceAnalysisEngineController- Throws:
Exception
-
getTransport
- Throws:
Exception
-
getTransport
- Specified by:
getTransportin interfaceAnalysisEngineController- Throws:
Exception
-
initializeVMTransport
Initializes transport used for internal messaging between collocated Uima AS services.- Specified by:
initializeVMTransportin interfaceAnalysisEngineController- Throws:
Exception
-
getUimaMessageListener
- Specified by:
getUimaMessageListenerin interfaceAnalysisEngineController
-
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:
getJMXDomainin interfaceAnalysisEngineController
-
getManagementInterface
- Specified by:
getManagementInterfacein interfaceAnalysisEngineController
-
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:
getIndexin interfaceAnalysisEngineController
-
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:
getJmxContextin interfaceAnalysisEngineController
-
registerWithAgent
Register a component with a given name with JMX MBeanServer- Parameters:
o- - component to register with JMXaName- - full jmx context name for the component
-
registerVmQueueWithJMX
- Specified by:
registerVmQueueWithJMXin interfaceAnalysisEngineController- Throws:
Exception
-
registerServiceWithJMX
-
cleanUp
- Throws:
Exception
-
setJmxManagement
Override the default JmxManager -
isTopLevelComponent
public boolean isTopLevelComponent()- Specified by:
isTopLevelComponentin interfaceAnalysisEngineController
-
getComponentName
Returns the name of the component. The name comes from the analysis engine descriptor- Specified by:
getComponentNamein interfaceAnalysisEngineController
-
toString
Print the component name rather than the class name -
addServiceInfo
- Specified by:
addServiceInfoin interfaceAnalysisEngineController
-
getServicePerformance
- Specified by:
getServicePerformancein interfaceAnalysisEngineController
-
getServiceErrors
- Specified by:
getServiceErrorsin interfaceAnalysisEngineController
-
getChildUimaContext
public org.apache.uima.UimaContext getChildUimaContext(String aDelegateEndpointName) throws Exception - Specified by:
getChildUimaContextin interfaceAnalysisEngineController- Throws:
Exception
-
setInputChannel
- Specified by:
setInputChannelin interfaceAnalysisEngineController- Throws:
Exception
-
addInputChannel
- Specified by:
addInputChannelin interfaceAnalysisEngineController
-
getInputChannel
- Specified by:
getInputChannelin interfaceAnalysisEngineController
-
dropCAS
public void dropCAS(org.apache.uima.cas.CAS aCAS) - Specified by:
dropCASin interfaceAnalysisEngineController
-
saveReplyTime
- Specified by:
saveReplyTimein interfaceAnalysisEngineController
-
getReplyTime
public long getReplyTime()- Specified by:
getReplyTimein interfaceAnalysisEngineController
-
handleAction
protected void handleAction(String anAction, String anEndpoint, ErrorContext anErrorContext) throws Exception - Throws:
Exception
-
forceTimeoutOnPendingCases
- Specified by:
forceTimeoutOnPendingCasesin interfaceAnalysisEngineController
-
plugInDefaultErrorHandlerChain
protected void plugInDefaultErrorHandlerChain() -
setErrorHandlerChain
-
getErrorHandlerChain
- Specified by:
getErrorHandlerChainin interfaceAnalysisEngineController
-
handleError
-
dropCAS
- Specified by:
dropCASin interfaceAnalysisEngineController
-
saveTime
- Specified by:
saveTimein interfaceAnalysisEngineController
-
getTime
- Specified by:
getTimein interfaceAnalysisEngineController
-
resetErrorCounter
protected void resetErrorCounter() -
incrementErrorCounter
protected void incrementErrorCounter() -
exceedsThresholdWithinWindow
protected boolean exceedsThresholdWithinWindow(int threshold, long docCount, int windowSize) -
getOutputChannel
- Specified by:
getOutputChannelin interfaceAnalysisEngineController
-
setOutputChannel
- Specified by:
setOutputChannelin interfaceAnalysisEngineController- Throws:
Exception
-
getCasManagerWrapper
- Specified by:
getCasManagerWrapperin interfaceAnalysisEngineController
-
setCasManager
- Specified by:
setCasManagerin interfaceAnalysisEngineController
-
getInProcessCache
- Specified by:
getInProcessCachein interfaceAnalysisEngineController
-
getResourceSpecifier
protected org.apache.uima.resource.ResourceSpecifier getResourceSpecifier() -
getName
- Specified by:
getNamein interfaceAnalysisEngineController
-
getKey
- Specified by:
getKeyin interfaceAnalysisEngineController
-
process
- Specified by:
processin interfaceAnalysisEngineController
-
process
public void process(org.apache.uima.cas.CAS aCAS, String anInputCasReferenceId, String aNewCasReferenceId, String newCASProducedBy) - Specified by:
processin interfaceAnalysisEngineController
-
process
- Specified by:
processin interfaceAnalysisEngineController
-
setUimaEEAdminContext
- Specified by:
setUimaEEAdminContextin interfaceAnalysisEngineController
-
getUimaEEAdminContext
- Specified by:
getUimaEEAdminContextin interfaceAnalysisEngineController
-
dropStats
Removes statistics from the global Map- Specified by:
dropStatsin interfaceAnalysisEngineController
-
logStats
protected void logStats() -
getCasStatistics
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:
getCasStatisticsin interfaceAnalysisEngineController
-
logStats
Logs statistics- Parameters:
aDelegateKey-aDelegateServicePerformance-
-
clearStats
protected void clearStats()Clears controller statistics. -
getStats
Returns a copy of the controller statistics.- Specified by:
getStatsin interfaceAnalysisEngineController
-
setDeployDescriptor
- Specified by:
setDeployDescriptorin interfaceAnalysisEngineController
-
getServiceName
-
getDeploymentDescriptor
-
getDeploymentMode
-
getBrokerURL
-
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() -
getClientEndpoint
- Specified by:
getClientEndpointin interfaceAnalysisEngineController
-
cacheClientEndpoint
- Specified by:
cacheClientEndpointin interfaceAnalysisEngineController- Parameters:
anEndpoint-
-
isStopped
public boolean isStopped()Return true if this service is in the shutdown state- Specified by:
isStoppedin interfaceAnalysisEngineController- Returns:
- - true if stopped
-
setStopped
public void setStopped()Description copied from interface:AnalysisEngineControllerCalled to set the state of the AnalysisEngineController to STOPPED. This method does not stop input or output channels.- Specified by:
setStoppedin interfaceAnalysisEngineController
-
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:
stopin interfaceAnalysisEngineController
-
stop
-
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:
quiesceAndStopin interfaceAnalysisEngineController
-
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:
terminatein interfaceControllerLifecycle
-
terminate
-
stopCasMultipliers
public void stopCasMultipliers() -
stopCasMultiplier
-
stopInputChannel
protected void stopInputChannel()Stops a listener on the main input channel -
stopInputChannels
protected void stopInputChannels(int channelsToStop) -
getCasMultiplierController
Aggregates have more than one Listener channel. This method stops all configured input channels this service is configured with. -
getInputChannel
- Specified by:
getInputChannelin interfaceAnalysisEngineController
-
getReplyInputChannel
- Specified by:
getReplyInputChannelin interfaceAnalysisEngineController
-
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:
onCacheEmptyin interfaceEventSubscriber
-
getEventListener
Returns interface via which this instance receives callbacks- Specified by:
getEventListenerin interfaceAnalysisEngineController
-
addControllerCallbackListener
Register one or more listeners through which the controller can send notification of events.- Specified by:
addControllerCallbackListenerin interfaceControllerLifecycle- Parameters:
aListener- - application listener object to register
-
removeControllerCallbackListener
Removes named application listener.- Specified by:
removeControllerCallbackListenerin interfaceControllerLifecycle- Parameters:
aListener- - application listener to remove
-
notifyListenersWithInitializationStatus
- Specified by:
notifyListenersWithInitializationStatusin interfaceAnalysisEngineController
-
dropCasStatistics
-
isCasMultiplier
public boolean isCasMultiplier()- Specified by:
isCasMultiplierin interfaceAnalysisEngineController
-
releaseNextCas
- Specified by:
releaseNextCasin interfaceAnalysisEngineController
-
beginProcess
public void beginProcess(int msgType) - Specified by:
beginProcessin interfaceAnalysisEngineController
-
endProcess
public void endProcess(int msgType) - Specified by:
endProcessin interfaceAnalysisEngineController
-
getIdleTimeBetweenProcessCalls
public long getIdleTimeBetweenProcessCalls(int msgType) - Specified by:
getIdleTimeBetweenProcessCallsin interfaceAnalysisEngineController
-
getIdleTime
public long getIdleTime()- Specified by:
getIdleTimein interfaceAnalysisEngineController
-
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:
getCpuTimein interfaceAnalysisEngineController
-
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:
getAnalysisTimein interfaceAnalysisEngineController
-
incrementSerializationTime
public void incrementSerializationTime(long cpuTime) Increments the time this thread spent in serialization of a CAS- Specified by:
incrementSerializationTimein interfaceAnalysisEngineController
-
incrementDeserializationTime
public void incrementDeserializationTime(long cpuTime) Increments the time this thread spent in deserialization of a CAS- Specified by:
incrementDeserializationTimein interfaceAnalysisEngineController
-
sendMetadata
public void sendMetadata(Endpoint anEndpoint, org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData metadata) -
getLocalCache
- Specified by:
getLocalCachein interfaceAnalysisEngineController
-
addAbortedCasReferenceId
- Specified by:
addAbortedCasReferenceIdin interfaceAnalysisEngineController
-
abortGeneratingCASes
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
-
isAwaitingCacheCallbackNotification
public boolean isAwaitingCacheCallbackNotification()- Specified by:
isAwaitingCacheCallbackNotificationin interfaceAnalysisEngineController
-
changeState
- Specified by:
changeStatein interfaceAnalysisEngineController
-
getState
- Specified by:
getStatein interfaceAnalysisEngineController
-
getDeadClientMap
- Specified by:
getDeadClientMapin interfaceAnalysisEngineController
-