}
protected void disableDelegates(List aDelegateList, String aCasReferenceId)
throws AsynchAEException {
if (aDelegateList == null) {
throw new AsynchAEException("Controller:" + getComponentName()
+ " Unable To Disable a Delegate. The Delegate List Provided Is Invalid (Null)");
}
try {
Iterator it = aDelegateList.iterator();
while (it.hasNext()) {
String key = (String) it.next();
Endpoint endpoint = lookUpEndpoint(key, false);
// if the the current delegate is remote, destroy its listener
if (endpoint != null && endpoint.isRemote()) {
Delegate delegate = lookupDelegate(key);
if (delegate != null) {
delegate.cancelDelegateTimer();
}
stopListener(key, endpoint);
endpoint.setStatus(Endpoint.DISABLED);
}
System.out.println("Controller:" + getComponentName() + " Disabled Delegate:" + key
+ " Due to Excessive Errors");
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, getClass().getName(),
"disableDelegates", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_disable_endpoint__INFO", new Object[] { getComponentName(), key });
}
// Change state of the delegate
ServiceInfo sf = getDelegateServiceInfo(key);
if (sf != null) {
sf.setState(ServiceState.DISABLED.name());
}
synchronized (disabledDelegateList) {
disabledDelegateList.add(key);
}
}
if (flowControllerContainer != null) {
try {
synchronized (flowControllerContainer) {
flowControllerContainer.removeAnalysisEngines(aDelegateList);
}
} catch (Exception ex) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"disableDelegates", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_exception__WARNING", new Object[] { ex });
}
if (aCasReferenceId != null) {
CasStateEntry parentCasCacheEntry = getLocalCache().getTopCasAncestor(aCasReferenceId);
if (parentCasCacheEntry != null && aDelegateList.size() > 0) {
String delegateKey = (String) aDelegateList.get(0);
System.out.println("Controller:" + getComponentName()
+ " Terminating Due to FlowController Failure While Disabling Delegate:"
+ delegateKey + " Cas:" + parentCasCacheEntry.getCasReferenceId());
super.terminate(ex, parentCasCacheEntry.getCasReferenceId());
} else {
terminate();
}
} else {
terminate();
}
return;
}
}
if (!initialized && allTypeSystemsMerged()) {
try {
completeInitialization();
} catch (ResourceInitializationException ex) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
"disableDelegates", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_exception__WARNING", new Object[] { ex });
}
handleInitializationError(ex);
return;
}
}
} catch (Exception e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
"disableDelegates", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_exception__WARNING", new Object[] { e });
}
throw new AsynchAEException(e);
}
}