You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2009/10/16 17:40:01 UTC
svn commit: r825952 - in
/incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error:
Threshold.java handler/ProcessCasErrorHandler.java
Author: burn
Date: Fri Oct 16 15:40:00 2009
New Revision: 825952
URL: http://svn.apache.org/viewvc?rev=825952&view=rev
Log:
UIMA-1623 Fix by creating unique Threshold instances when necessary
Modified:
incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/Threshold.java
incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java
Modified: incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/Threshold.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/Threshold.java?rev=825952&r1=825951&r2=825952&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/Threshold.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/Threshold.java Fri Oct 16 15:40:00 2009
@@ -26,7 +26,7 @@
private String action;
- private long window;
+ private int window;
private int maxRetries;
@@ -39,20 +39,25 @@
public Threshold() {
}
+ // Copy constructor used when a duplicate object has R/W storage so cannot be shared
+ private Threshold(Threshold t) {
+ window = t.window;
+ threshold = t.threshold;
+ action = t.action;
+ maxRetries = t.maxRetries;
+ continueOnRetryFailure = t.continueOnRetryFailure;
+ if (window >= threshold && threshold > 1) {
+ errorSequences = new long[threshold - 1];
+ Arrays.fill(errorSequences, -window);
+ }
+ }
+
public long getWindow() {
return window;
}
public void setWindow(long aWindow) {
- window = aWindow;
- // Need to save error sequences if watching for more than 1 error in a window
- // Initialize array with values outside the window
- if (aWindow >= threshold && threshold > 1) {
- errorSequences = new long[threshold - 1];
- Arrays.fill(errorSequences, -window);
- } else {
- errorSequences = null;
- }
+ window = (int) aWindow;
}
public long getThreshold() {
@@ -61,14 +66,23 @@
public void setThreshold(long aCount) {
threshold = (int) aCount;
+ }
+
+ public Threshold initialize() {
// Need to save error sequences if watching for more than 1 error in a window
- // Initialize array with values outside the window
+ // If first use of this instance, initialize array with values outside the window
+ // If shared by another delegate create a copy
if (window >= threshold && threshold > 1) {
- errorSequences = new long[threshold - 1];
- Arrays.fill(errorSequences, -window);
+ if (errorSequences == null) {
+ errorSequences = new long[threshold - 1];
+ Arrays.fill(errorSequences, -window);
+ return this;
+ } else {
+ return new Threshold(this); // Original in use so make a copy
+ }
} else {
- errorSequences = null;
- }
+ return this;
+ }
}
public boolean exceeded(long value) {
@@ -83,7 +97,6 @@
return false;
}
++errorCount;
- // casCount += errorCount; // HACK! Currently count doesn't include errors
// If no window check if total errors have REACHED the threshold
if (errorSequences == null) {
@@ -98,7 +111,8 @@
}
}
// If insert fails then have reached threshold.
- // (Should not be called again after returning true!)
+ // Should not be called again after returning true as may return false!
+ // But may be called again if no action specified, but then it doesn't matter.
return true;
}
Modified: incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java?rev=825952&r1=825951&r2=825952&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/error/handler/ProcessCasErrorHandler.java Fri Oct 16 15:40:00 2009
@@ -22,6 +22,7 @@
import java.net.ConnectException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Set;
import org.apache.uima.UIMAFramework;
import org.apache.uima.aae.UIMAEE_Constants;
@@ -59,8 +60,14 @@
delegateMap = new HashMap();
}
+ /*
+ * Copy map provided by dd2spring but create unique Threshold objects if necessary (UIMA-1623)
+ */
public ProcessCasErrorHandler(Map aDelegateMap) {
delegateMap = aDelegateMap;
+ for (Map.Entry<String, Threshold> entry : (Set<Map.Entry<String, Threshold>>)delegateMap.entrySet()) {
+ entry.setValue(entry.getValue().initialize());
+ }
}
private Endpoint getDestination(AnalysisEngineController aController, ErrorContext anErrorContext) {