private void addErrorHandling(CpeCasProcessor aCasProcessorConfig)
throws ResourceConfigurationException {
CasProcessorErrorHandling casProcessorErrorHandling = aCasProcessorConfig.getErrorHandling();
if (casProcessorErrorHandling == null) {
throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] {
"errorHandling", "casProcessor" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_xml_element__WARNING",
new Object[] { Thread.currentThread().getName(), name, "<errorHandling>" })));
}
CasProcessorMaxRestarts maxRestarts = casProcessorErrorHandling.getMaxConsecutiveRestarts();
if (maxRestarts == null) {
throw new ResourceConfigurationException(
ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] {
"maxConsecutiveRestarts", "CPE" }, new Exception(CpmLocalizedMessage
.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
Thread.currentThread().getName(), name,
"<maxConsecutiveRestarts>" })));
}
maxRetryThreshold = maxRestarts.getRestartCount();
waitTimeBetweenRestarts = maxRestarts.getWaitTimeBetweenRetries();
maxRestartThreshold = maxRestarts.getRestartCount();
if (!validActionOnError(maxRestarts.getAction())) {
throw new ResourceConfigurationException(
ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] { "action",
"CPE" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_action_string__WARNING",
new Object[] { Thread.currentThread().getName(), name,
"<maxConsecutiveRestarts>", maxRestarts.getAction() })));
}
actionOnMaxRestarts = maxRestarts.getAction();
// Setup Error rate Threshold in terms of (count)/(sample size) eg. 3/1000
CasProcessorErrorRateThreshold errorRateThresholdType = casProcessorErrorHandling
.getErrorRateThreshold();
if (errorRateThresholdType == null) {
throw new ResourceConfigurationException(
ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] {
"errorRateThreshold", "CPE" },
new Exception(CpmLocalizedMessage.getLocalizedMessage(
CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] {
Thread.currentThread().getName(), name, "<errorRateThreshold>" })));
}
errorRate = errorRateThresholdType.getMaxErrorCount();
errorSampleSize = errorRateThresholdType.getMaxErrorSampleSize();
if (!validActionOnError(errorRateThresholdType.getAction())) {
throw new ResourceConfigurationException(
ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] { "action",
"CPE" }, new Exception(CpmLocalizedMessage.getLocalizedMessage(
CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_action_string__WARNING",
new Object[] { Thread.currentThread().getName(), name,
"<errorRateThreshold>", maxRestarts.getAction() })));