in uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java [297:494]
public BaseAnalysisEngineController(AnalysisEngineController aParentController,
int aComponentCasPoolSize, long anInitialCasHeapSize, String anEndpointName,
String aDescriptor, AsynchAECasManager aCasManager, InProcessCache anInProcessCache,
Map aDestinationMap, JmxManagement aJmxManagement,boolean disableJCasCache) throws Exception {
casManager = aCasManager;
inProcessCache = anInProcessCache;
localCache = new LocalCache(this);
aeDescriptor = aDescriptor;
parentController = aParentController;
componentCasPoolSize = aComponentCasPoolSize;
if (this instanceof AggregateAnalysisEngineController) {
// Populate a list of un-registered co-located delegates. A delegate will be taken off the
// un-registered list
// when it calls its parent registerChildController() method.
Set set = aDestinationMap.entrySet();
synchronized (unregisteredDelegateList) {
for (Iterator it = set.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
Endpoint endpoint = (Endpoint) entry.getValue();
if (endpoint != null && !endpoint.isRemote()) {
unregisteredDelegateList.add(entry.getKey());
}
}
if (unregisteredDelegateList.size() == 0) // All delegates are remote
{
allDelegatesAreRemote = true;
}
}
}
endpointName = anEndpointName;
delegateKey = anEndpointName;
if (this instanceof AggregateAnalysisEngineController) {
ConcurrentHashMap endpoints = new ConcurrentHashMap();
endpoints.putAll(aDestinationMap);
// Create a map containing: Endpoint-DelegateKey pairs, to enable look-up
// of a delegate key based on delegate's endpoint
((AggregateAnalysisEngineController) this).mapEndpointsToKeys(endpoints);
}
// If not the top level, retrieve the name of the endpoint from the parent
if (!isTopLevelComponent()) {
Endpoint endpoint = ((AggregateAnalysisEngineController) parentController).lookUpEndpoint(
endpointName, false);
endpointName = endpoint.getEndpoint();
}
resourceSpecifier = UimaClassFactory.produceResourceSpecifier(aDescriptor);
if (resourceSpecifier instanceof PearSpecifier ) {
serviceName = ((PearSpecifier)resourceSpecifier).getPearPath();
int pos=0;
if ( (pos = serviceName.lastIndexOf(".") ) > -1 ) {
serviceName = serviceName.substring(pos+1);
}
}
if (isTopLevelComponent()) {
// ******************************************************************************
// Set a global UncaughtExceptionHandler to handle OOM and other uncaught Throwables
// ******************************************************************************
// this adds the handler to every thread
Thread.setDefaultUncaughtExceptionHandler(new UimaAsUncaughtExceptionHandler(getComponentName()));
// Check the version of uimaj that UIMA AS was built with, against the UIMA Core version. If not the same throw Exception
// throws an exception if verions of UIMA-AS is not compatible with UIMA SDK
VersionCompatibilityChecker.check(CLASS_NAME, getComponentName(),"BaseAnalysisEngineController()");
logPlatformInfo(getComponentName());
} else {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
"BaseAnalysisEngineController", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_service_id_INFO", new Object[] { endpointName });
}
}
// Is this service a CAS Multiplier?
if ((resourceSpecifier instanceof AnalysisEngineDescription && ((AnalysisEngineDescription) resourceSpecifier)
.getAnalysisEngineMetaData().getOperationalProperties().getOutputsNewCASes())
|| resourceSpecifier instanceof CollectionReaderDescription) {
casMultiplier = true;
}
paramsMap = new HashMap();
if (aJmxManagement == null) {
if ( isTopLevelComponent()) {
serviceInstance++;
}
jmxManagement = new JmxManager(getJMXDomain(serviceInstance));
} else {
jmxManagement = aJmxManagement;
if (jmxManagement.getMBeanServer() != null) {
paramsMap.put(AnalysisEngine.PARAM_MBEAN_SERVER, jmxManagement.getMBeanServer());
}
}
paramsMap.put(AnalysisEngine.PARAM_MBEAN_NAME_PREFIX, jmxManagement.getJmxDomain());
if (isTopLevelComponent() && this instanceof AggregateAnalysisEngineController) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "C'tor",
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, "UIMAEE_using_vm_transport_INFO",
new Object[] { getComponentName() });
}
}
// Top level component?
String casLogComponents = System.getProperty("UIMA_CASLOG_COMPONENT_ARRAY");
if (parentController == null) {
paramsMap.put(Resource.PARAM_RESOURCE_MANAGER, casManager.getResourceManager());
initialize(resourceSpecifier, paramsMap);
AnalysisEngineManagementImpl mbean = (AnalysisEngineManagementImpl) getUimaContextAdmin()
.getManagementInterface();
if (this instanceof AggregateAnalysisEngineController) {
// Override uima core jmx domain setting
mbean.setName(getComponentName(), getUimaContextAdmin(), jmxManagement.getJmxDomain());
}
if (resourceSpecifier instanceof AnalysisEngineDescription) {
// Is this service a CAS Multiplier?
if (((AnalysisEngineDescription) resourceSpecifier).getAnalysisEngineMetaData()
.getOperationalProperties().getOutputsNewCASes()) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME)
.logrb(
Level.INFO,
CLASS_NAME.getName(),
"C'tor",
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_multiplier_cas_pool_config_INFO",
new Object[] { getComponentName(), aComponentCasPoolSize,
anInitialCasHeapSize,getUimaContextAdmin().getQualifiedContextName() });
}
initializeComponentCasPool(aComponentCasPoolSize, anInitialCasHeapSize, disableJCasCache);
}
}
} else {
UimaContext childContext = parentController.getChildUimaContext(endpointName);
if ( childContext != null && childContext instanceof UimaContextAdmin ) {
String qualifiedContextName = ((UimaContextAdmin)childContext).getQualifiedContextName();
}
uimaContext = childContext; // save this controller's context
paramsMap.put(Resource.PARAM_UIMA_CONTEXT, childContext);
initialize(resourceSpecifier, paramsMap);
initializeComponentCasPool(aComponentCasPoolSize, anInitialCasHeapSize, disableJCasCache);
if (parentController instanceof AggregateAnalysisEngineController) {
// Register self with the parent controller
((AggregateAnalysisEngineController) parentController).registerChildController(this,
delegateKey);
}
}
// Each component in the service hierarchy has its own index. The index is used
// to construct jmx context path to which every object belongs.
int index = getIndex();
// Get uima ee jmx base context path
jmxContext = getJmxContext();
if (!isTopLevelComponent() && this instanceof PrimitiveAnalysisEngineController) {
String thisComponentName = ((AggregateAnalysisEngineController) parentController)
.lookUpDelegateKey(endpointName);
jmxContext += (thisComponentName + " Uima EE Service");
}
// Register InProcessCache with JMX under the top level component
if (inProcessCache != null && isTopLevelComponent()) {
inProcessCache.setName(jmxManagement.getJmxDomain() + jmxContext + ",name="
+ inProcessCache.getName());
ObjectName on = new ObjectName(inProcessCache.getName());
jmxManagement.registerMBean(inProcessCache, on);
}
initializeServiceStats();
// Show Serialization Strategy of each remote delegate
if (this instanceof AggregateAnalysisEngineController) {
Set set = aDestinationMap.entrySet();
for (Iterator it = set.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
Endpoint endpoint = (Endpoint) entry.getValue();
if (endpoint != null && endpoint.isRemote()) {
String key = ((AggregateAnalysisEngineController) this).lookUpDelegateKey(endpoint
.getEndpoint());
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "C'tor",
UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_show_remote_delegate_serialization_INFO",
new Object[] { getComponentName(), key, endpoint.getSerializer() });
}
}
}
}
// Create an instance of ControllerMBean and register it with JMX Server.
// This bean exposes service lifecycle APIs to enable remote stop
if (isTopLevelComponent()) {
Controller controller = new Controller(this);
String jmxName = getManagementInterface().getJmxDomain() + "name=" + "Controller";
registerWithAgent(controller, jmxName);
}
}