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 String
protected boolean
protected boolean
protected Object
protected boolean
protected Endpoint
protected ConcurrentHashMap
protected int
protected List
protected ConcurrentHashMap<String,
String> protected String
protected long
protected ErrorHandlerChain
protected final Object
protected long
protected InputChannel
protected List
protected ConcurrentHashMap
protected String
protected ControllerLatch
protected LocalCache
protected ConcurrentHashMap<String,
UimaMessageListener> protected Monitor
static final boolean
protected HashMap
protected AnalysisEngineController
protected ConcurrentHashMap
protected String
protected long
protected org.apache.uima.resource.ResourceSpecifier
protected ConcurrentHashMap
protected ServiceErrors
protected boolean
protected ServicePerformance
protected ConcurrentHashMap<String,
Long> protected boolean
protected Object
protected ConcurrentHashMap<String,
UimaTransport> protected List
Fields inherited from interface org.apache.uima.aae.controller.AnalysisEngineController
AEInstanceCount, CasPoolSize
Fields 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 boolean
abortGeneratingCASes
(String aCasReferenceId) Returns true if a given CAS id is in the list of aborted CASes.void
addAbortedCasReferenceId
(String aCasReferenceId) void
Register one or more listeners through which the controller can send notification of events.void
addInputChannel
(InputChannel anInputChannel) void
addServiceInfo
(ServiceInfo aServiceInfo) void
beginProcess
(int msgType) void
cacheClientEndpoint
(Endpoint anEndpoint) void
protected void
cleanUp()
protected void
Clears controller statistics.void
void
dropCAS
(org.apache.uima.cas.CAS aCAS) protected void
dropCasStatistics
(String aCasReferenceId) void
Removes statistics from the global Mapabstract void
dumpState
(StringBuffer buffer, String lbl1) void
endProcess
(int msgType) protected boolean
exceedsThresholdWithinWindow
(int threshold, long docCount, int windowSize) void
long
Returns 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.UimaContext
getChildUimaContext
(String aDelegateEndpointName) Returns the name of the component.long
Returns CPU Time with nanosecond precision (not nanosecond accuracy).Returns interface via which this instance receives callbackslong
long
getIdleTimeBetweenProcessCalls
(int msgType) int
getIndex()
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) long
protected org.apache.uima.resource.ResourceSpecifier
getState()
getStats()
Returns a copy of the controller statistics.long
long
long
long
long
long
long
long
getTransport
(String aKey) getTransport
(UimaAsContext asContext) getTransport
(UimaAsContext asContext, String aKey) getUimaMessageListener
(String aDelegateKey) protected void
handleAction
(String anAction, String anEndpoint, ErrorContext anErrorContext) void
handleError
(HashMap aMap, Throwable e) void
incrementDeserializationTime
(long cpuTime) Increments the time this thread spent in deserialization of a CASprotected void
void
incrementSerializationTime
(long cpuTime) Increments the time this thread spent in serialization of a CASvoid
initializeVMTransport
(int parentControllerReplyConsumerCount) Initializes transport used for internal messaging between collocated Uima AS services.boolean
boolean
boolean
Return true if this service is in the shutdown stateboolean
protected void
logStats()
protected void
logStats
(String aDelegateKey, ServicePerformance aServicePerformance) Logs statisticsvoid
void
Callback method called the InProcessCache becomes empty meaning ALL CASes are processed.protected void
void
void
process
(org.apache.uima.cas.CAS aCAS, String anInputCasReferenceId, String aNewCasReferenceId, String newCASProducedBy) void
void
Stops input channel(s) and waits for CASes still in play to complete processing.protected void
registerServiceWithJMX
(String key_value_list, boolean remote) void
registerVmQueueWithJMX
(Object o, String aName) protected void
registerWithAgent
(Object o, String aName) Register a component with a given name with JMX MBeanServervoid
releaseNextCas
(String casReferenceId) void
Removes named application listener.protected void
void
saveReplyTime
(long snapshot, String aKey) void
void
sendMetadata
(Endpoint anEndpoint, org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData metadata) void
setCasManager
(AsynchAECasManager casManager) void
setDeployDescriptor
(String aDeployDescriptor) void
setErrorHandlerChain
(ErrorHandlerChain errorHandlerChain) void
setInputChannel
(InputChannel anInputChannel) void
setJmxManagement
(JmxManagement aJmxManagement) Override the default JmxManagervoid
setOutputChannel
(OutputChannel outputChannel) void
Called to set the state of the AnalysisEngineController to STOPPED.void
setUimaEEAdminContext
(UimaEEAdminContext anAdminContext) void
stop()
Stops input channel(s) and initiates a shutdown of all delegates ( if this is an aggregate ).void
void
stopCasMultiplier
(Delegate casMultiplier, String aCasReferenceId) void
protected void
protected void
Stops a listener on the main input channelprotected void
stopInputChannels
(int channelsToStop) protected void
void
Using a reference to its parent, propagates the terminate event to the top level controller.void
toString()
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, setMetaData
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
dumpState
in interfaceAnalysisEngineController
-
getParentController
- Specified by:
getParentController
in interfaceAnalysisEngineController
-
getTransport
- Specified by:
getTransport
in interfaceAnalysisEngineController
- Throws:
Exception
-
getTransport
- Throws:
Exception
-
getTransport
- Specified by:
getTransport
in interfaceAnalysisEngineController
- Throws:
Exception
-
initializeVMTransport
Initializes transport used for internal messaging between collocated Uima AS services.- Specified by:
initializeVMTransport
in interfaceAnalysisEngineController
- Throws:
Exception
-
getUimaMessageListener
- Specified by:
getUimaMessageListener
in 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:
getJMXDomain
in interfaceAnalysisEngineController
-
getManagementInterface
- Specified by:
getManagementInterface
in 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:
getIndex
in 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:
getJmxContext
in 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:
registerVmQueueWithJMX
in interfaceAnalysisEngineController
- Throws:
Exception
-
registerServiceWithJMX
-
cleanUp
- Throws:
Exception
-
setJmxManagement
Override the default JmxManager -
isTopLevelComponent
public boolean isTopLevelComponent()- Specified by:
isTopLevelComponent
in interfaceAnalysisEngineController
-
getComponentName
Returns the name of the component. The name comes from the analysis engine descriptor- Specified by:
getComponentName
in interfaceAnalysisEngineController
-
toString
Print the component name rather than the class name -
addServiceInfo
- Specified by:
addServiceInfo
in interfaceAnalysisEngineController
-
getServicePerformance
- Specified by:
getServicePerformance
in interfaceAnalysisEngineController
-
getServiceErrors
- Specified by:
getServiceErrors
in interfaceAnalysisEngineController
-
getChildUimaContext
public org.apache.uima.UimaContext getChildUimaContext(String aDelegateEndpointName) throws Exception - Specified by:
getChildUimaContext
in interfaceAnalysisEngineController
- Throws:
Exception
-
setInputChannel
- Specified by:
setInputChannel
in interfaceAnalysisEngineController
- Throws:
Exception
-
addInputChannel
- Specified by:
addInputChannel
in interfaceAnalysisEngineController
-
getInputChannel
- Specified by:
getInputChannel
in interfaceAnalysisEngineController
-
dropCAS
public void dropCAS(org.apache.uima.cas.CAS aCAS) - Specified by:
dropCAS
in interfaceAnalysisEngineController
-
saveReplyTime
- Specified by:
saveReplyTime
in interfaceAnalysisEngineController
-
getReplyTime
public long getReplyTime()- Specified by:
getReplyTime
in interfaceAnalysisEngineController
-
handleAction
protected void handleAction(String anAction, String anEndpoint, ErrorContext anErrorContext) throws Exception - Throws:
Exception
-
forceTimeoutOnPendingCases
- Specified by:
forceTimeoutOnPendingCases
in interfaceAnalysisEngineController
-
plugInDefaultErrorHandlerChain
protected void plugInDefaultErrorHandlerChain() -
setErrorHandlerChain
-
getErrorHandlerChain
- Specified by:
getErrorHandlerChain
in interfaceAnalysisEngineController
-
handleError
-
dropCAS
- Specified by:
dropCAS
in interfaceAnalysisEngineController
-
saveTime
- Specified by:
saveTime
in interfaceAnalysisEngineController
-
getTime
- Specified by:
getTime
in interfaceAnalysisEngineController
-
resetErrorCounter
protected void resetErrorCounter() -
incrementErrorCounter
protected void incrementErrorCounter() -
exceedsThresholdWithinWindow
protected boolean exceedsThresholdWithinWindow(int threshold, long docCount, int windowSize) -
getOutputChannel
- Specified by:
getOutputChannel
in interfaceAnalysisEngineController
-
setOutputChannel
- Specified by:
setOutputChannel
in interfaceAnalysisEngineController
- Throws:
Exception
-
getCasManagerWrapper
- Specified by:
getCasManagerWrapper
in interfaceAnalysisEngineController
-
setCasManager
- Specified by:
setCasManager
in interfaceAnalysisEngineController
-
getInProcessCache
- Specified by:
getInProcessCache
in interfaceAnalysisEngineController
-
getResourceSpecifier
protected org.apache.uima.resource.ResourceSpecifier getResourceSpecifier() -
getName
- Specified by:
getName
in interfaceAnalysisEngineController
-
getKey
- Specified by:
getKey
in interfaceAnalysisEngineController
-
process
- Specified by:
process
in interfaceAnalysisEngineController
-
process
public void process(org.apache.uima.cas.CAS aCAS, String anInputCasReferenceId, String aNewCasReferenceId, String newCASProducedBy) - Specified by:
process
in interfaceAnalysisEngineController
-
process
- Specified by:
process
in interfaceAnalysisEngineController
-
setUimaEEAdminContext
- Specified by:
setUimaEEAdminContext
in interfaceAnalysisEngineController
-
getUimaEEAdminContext
- Specified by:
getUimaEEAdminContext
in interfaceAnalysisEngineController
-
dropStats
Removes statistics from the global Map- Specified by:
dropStats
in 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:
getCasStatistics
in interfaceAnalysisEngineController
-
logStats
Logs statistics- Parameters:
aDelegateKey
-aDelegateServicePerformance
-
-
clearStats
protected void clearStats()Clears controller statistics. -
getStats
Returns a copy of the controller statistics.- Specified by:
getStats
in interfaceAnalysisEngineController
-
setDeployDescriptor
- Specified by:
setDeployDescriptor
in 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:
getClientEndpoint
in interfaceAnalysisEngineController
-
cacheClientEndpoint
- Specified by:
cacheClientEndpoint
in interfaceAnalysisEngineController
- Parameters:
anEndpoint
-
-
isStopped
public boolean isStopped()Return true if this service is in the shutdown state- Specified by:
isStopped
in interfaceAnalysisEngineController
- Returns:
- - true if stopped
-
setStopped
public void setStopped()Description copied from interface:AnalysisEngineController
Called to set the state of the AnalysisEngineController to STOPPED. This method does not stop input or output channels.- Specified by:
setStopped
in 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:
stop
in 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:
quiesceAndStop
in 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:
terminate
in 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:
getInputChannel
in interfaceAnalysisEngineController
-
getReplyInputChannel
- Specified by:
getReplyInputChannel
in 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:
onCacheEmpty
in interfaceEventSubscriber
-
getEventListener
Returns interface via which this instance receives callbacks- Specified by:
getEventListener
in interfaceAnalysisEngineController
-
addControllerCallbackListener
Register one or more listeners through which the controller can send notification of events.- Specified by:
addControllerCallbackListener
in interfaceControllerLifecycle
- Parameters:
aListener
- - application listener object to register
-
removeControllerCallbackListener
Removes named application listener.- Specified by:
removeControllerCallbackListener
in interfaceControllerLifecycle
- Parameters:
aListener
- - application listener to remove
-
notifyListenersWithInitializationStatus
- Specified by:
notifyListenersWithInitializationStatus
in interfaceAnalysisEngineController
-
dropCasStatistics
-
isCasMultiplier
public boolean isCasMultiplier()- Specified by:
isCasMultiplier
in interfaceAnalysisEngineController
-
releaseNextCas
- Specified by:
releaseNextCas
in interfaceAnalysisEngineController
-
beginProcess
public void beginProcess(int msgType) - Specified by:
beginProcess
in interfaceAnalysisEngineController
-
endProcess
public void endProcess(int msgType) - Specified by:
endProcess
in interfaceAnalysisEngineController
-
getIdleTimeBetweenProcessCalls
public long getIdleTimeBetweenProcessCalls(int msgType) - Specified by:
getIdleTimeBetweenProcessCalls
in interfaceAnalysisEngineController
-
getIdleTime
public long getIdleTime()- Specified by:
getIdleTime
in 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:
getCpuTime
in 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:
getAnalysisTime
in interfaceAnalysisEngineController
-
incrementSerializationTime
public void incrementSerializationTime(long cpuTime) Increments the time this thread spent in serialization of a CAS- Specified by:
incrementSerializationTime
in interfaceAnalysisEngineController
-
incrementDeserializationTime
public void incrementDeserializationTime(long cpuTime) Increments the time this thread spent in deserialization of a CAS- Specified by:
incrementDeserializationTime
in interfaceAnalysisEngineController
-
sendMetadata
public void sendMetadata(Endpoint anEndpoint, org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData metadata) -
getLocalCache
- Specified by:
getLocalCache
in interfaceAnalysisEngineController
-
addAbortedCasReferenceId
- Specified by:
addAbortedCasReferenceId
in 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:
isAwaitingCacheCallbackNotification
in interfaceAnalysisEngineController
-
changeState
- Specified by:
changeState
in interfaceAnalysisEngineController
-
getState
- Specified by:
getState
in interfaceAnalysisEngineController
-
getDeadClientMap
- Specified by:
getDeadClientMap
in interfaceAnalysisEngineController
-