Author: cwiklik Date: Fri Jun 14 21:01:41 2013 New Revision: 1493244 URL: http://svn.apache.org/r1493244 Log: UIMA-3001 - modified finalState to fix a race condition when a child and its parent are in play at the same time.
Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/LocalCache.java Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java?rev=1493244&r1=1493243&r2=1493244&view=diff ============================================================================== --- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java (original) +++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/AggregateAnalysisEngineController_impl.java Fri Jun 14 21:01:41 2013 @@ -1701,6 +1701,9 @@ public class AggregateAnalysisEngineCont if (!getInProcessCache().entryExists(aCasReferenceId)) { return; } + + // System.out.println(" ---- Controller::"+getComponentName()+" CAS:"+casStateEntry.getCasReferenceId()+ " Has Children:"+casHasChildrenInPlay(casStateEntry)+" Parent::"+casStateEntry.getInputCasReferenceId()); + // Check if this CAS has children that are still being processed in this aggregate if (casHasChildrenInPlay(casStateEntry)) { if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINE)) { @@ -1715,8 +1718,10 @@ public class AggregateAnalysisEngineCont } replySentToClient = false; + casStateEntry.waitingForChildrenToFinish(true); return; } + casStateEntry.waitingForChildrenToFinish(false); if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(CLASS_NAME).logrb(Level.FINEST, CLASS_NAME.getName(), "finalStep", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, @@ -1825,7 +1830,9 @@ public class AggregateAnalysisEngineCont } // For subordinate CAS, check if its parent needs to be put in play. This should happen if // this CAS was the last of the children in play - if (isSubordinate && releaseParentCas(casDropped, clientIsCollocated, parentCasStateEntry)) { + if (isSubordinate && releaseParentCas(casDropped, clientIsCollocated, parentCasStateEntry) ) { +// parentCasStateEntry.waitingForChildrenToFinish(false); +// if (isSubordinate && releaseParentCas(casDropped, clientIsCollocated, parentCasStateEntry) ) { // Put the parent CAS in play. The parent CAS can be in one of two places now depending // on the configuration. The parent CAS could have been suspended in the final step, or it // could have @@ -1835,9 +1842,11 @@ public class AggregateAnalysisEngineCont // Otherwise, the CAS is in a final state and simply needs to resume there. Endpoint lastDelegateEndpoint = parentCasStateEntry.getLastDelegate().getEndpoint(); if (lastDelegateEndpoint.processParentLast()) { + // The parent was suspended in the process call. Resume processing the CAS process(parentCASCacheEntry.getCas(), parentCasStateEntry.getCasReferenceId()); - } else { + } else if ( parentCasStateEntry.waitingForChildrenToFinish()){ + // The parent was suspended in the final step. Resume processing the CAS finalStep(parentCasStateEntry.getFinalStep(), parentCasStateEntry.getCasReferenceId()); } Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/LocalCache.java URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/LocalCache.java?rev=1493244&r1=1493243&r2=1493244&view=diff ============================================================================== --- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/LocalCache.java (original) +++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/LocalCache.java Fri Jun 14 21:01:41 2013 @@ -187,6 +187,8 @@ public class LocalCache extends Concurre private String casReferenceId; + private volatile boolean waitingForChildren; // true if in FinalState and still has children in play + private volatile boolean waitingForRealease; private volatile boolean pendingReply; @@ -238,6 +240,12 @@ public class LocalCache extends Concurre private Object monitor = new Object(); + public boolean waitingForChildrenToFinish() { + return waitingForChildren; + } + public void waitingForChildrenToFinish(boolean waiting) { + waitingForChildren = waiting; + } public String getHostIpProcessingCAS() { return hostIpProcessingCAS; }