Author: cwiklik
Date: Tue Jan 10 14:45:21 2012
New Revision: 1229564

URL: http://svn.apache.org/viewvc?rev=1229564&view=rev
Log:
UIMA-2324 Fixes NPE while recovering from CM failure. Added new testcase

Added:
    
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml
   (with props)
    
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml
   (with props)
    
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml
   (with props)
Modified:
    
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
    
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/TestUimaASExtended.java
    
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/BaseAnalysisEngineController.java

Modified: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java?rev=1229564&r1=1229563&r2=1229564&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ae/multiplier/SimpleCasGenerator.java
 Tue Jan 10 14:45:21 2012
@@ -63,6 +63,8 @@ public class SimpleCasGenerator extends 
   private String text;
 
   long docCount = 0;
+  
+  int failOnDocumentNumber;
 
   /*
    * (non-Javadoc)
@@ -73,6 +75,13 @@ public class SimpleCasGenerator extends 
   public void initialize(UimaContext aContext) throws 
ResourceInitializationException {
     super.initialize(aContext);
     this.nToGen = ((Integer) 
aContext.getConfigParameterValue("NumberToGenerate")).intValue();
+    if ( aContext.getConfigParameterValue("DocumentNumberToFailOn") != null ) {
+      int tmpCount = ((Integer) 
aContext.getConfigParameterValue("DocumentNumberToFailOn")).intValue();
+      if ( tmpCount > 0 ) {
+        this.failOnDocumentNumber = tmpCount;
+      }
+    }
+    
     FileInputStream fis = null;
     try {
       String filename = ((String) 
aContext.getConfigParameterValue("InputFile")).trim();
@@ -137,6 +146,13 @@ public class SimpleCasGenerator extends 
       System.out.println("Initializing CAS with a Document of Size:" + 
text.length());
     }
     docCount++;
+    
+    if ( this.failOnDocumentNumber == docCount ) {
+      cas.release();
+      //  force CM to finish producing CASes on error
+      this.mCount = this.nToGen;
+      throw new AnalysisEngineProcessException(new Exception("Simulated 
Exception in Cas Multiplier next() method"));
+    }
     if (UIMAFramework.getLogger().isLoggable(Level.FINE))
       System.out.println("CasMult creating document#" + docCount);
     cas.setDocumentText(this.text);

Modified: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/TestUimaASExtended.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/TestUimaASExtended.java?rev=1229564&r1=1229563&r2=1229564&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/TestUimaASExtended.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/TestUimaASExtended.java
 Tue Jan 10 14:45:21 2012
@@ -23,10 +23,13 @@ import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -53,6 +56,7 @@ import org.apache.uima.aae.client.UimaAs
 import org.apache.uima.aae.controller.Endpoint;
 import org.apache.uima.aae.error.MessageTimeoutException;
 import org.apache.uima.aae.error.ServiceShutdownException;
+import org.apache.uima.aae.monitor.statistics.AnalysisEnginePerformanceMetrics;
 import org.apache.uima.adapter.jms.JmsConstants;
 import org.apache.uima.adapter.jms.activemq.JmsOutputChannel;
 import org.apache.uima.adapter.jms.activemq.SpringContainerDeployer;
@@ -61,6 +65,8 @@ import org.apache.uima.adapter.jms.messa
 import org.apache.uima.analysis_engine.AnalysisEngineDescription;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.cas.impl.XmiCasDeserializer;
+import org.apache.uima.collection.CollectionException;
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.collection.CollectionReaderDescription;
 import org.apache.uima.collection.EntityProcessStatus;
@@ -74,6 +80,7 @@ import org.apache.uima.resourceSpecifier
 import org.apache.uima.resourceSpecifier.factory.UimaASDeploymentDescriptor;
 import org.apache.uima.util.XMLInputSource;
 import org.josql.expressions.IsNullExpression;
+import org.xml.sax.SAXException;
 
 public class TestUimaASExtended extends BaseTestSupport {
 
@@ -99,6 +106,183 @@ public class TestUimaASExtended extends 
             + System.getProperty("file.separator") + "bin" + 
System.getProperty("file.separator")
             + "dd2spring.xsl");
   }
+  
+  public void testDeployAggregateServiceWithFailingCollocatedCM() throws 
Exception {
+    System.out.println("-------------- 
testDeployAggregateServiceWithFailingCollocatedCM -------------");
+    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
+    System.setProperty(JmsConstants.SessionTimeoutOverride, "2500000");
+    deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
+    deployService(eeUimaEngine, relativePath + 
"/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml");
+    
+    Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+            "TopLevelTaeQueue");
+    appCtx.put(UimaAsynchronousEngine.Timeout, 0);
+    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 0);
+    
+    
//addExceptionToignore(org.apache.uima.aae.error.UimaEEServiceException.class); 
+    
+    runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()), "TopLevelTaeQueue",
+            1, EXCEPTION_LATCH);
+  }
+  
+  
+  public void getLargeCAS(CAS aCAS, File xmiFile) throws IOException, 
CollectionException {
+           FileInputStream inputStream = new FileInputStream(xmiFile);
+           try {
+               XmiCasDeserializer.deserialize(inputStream, aCAS, false);
+           } catch (SAXException e) {
+             throw new CollectionException(e);
+           } finally {
+             inputStream.close();
+           }
+           
+         }
+  /*
+  public void testLargeCAS() {
+           System.out.println("-------------- testLargeCAS -------------");
+           try {
+                   // Instantiate Uima AS Client
+                   BaseUIMAAsynchronousEngine_impl uimaAsEngine = new 
BaseUIMAAsynchronousEngine_impl();
+                   // Deploy Uima AS Primitive Service
+//                 deployService(uimaAsEngine, relativePath + 
"/Deploy_PersonTitleAnnotator.xml");
+                   deployService(uimaAsEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
+//                 Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+//                         "PersonTitleAnnotatorQueue");
+                   Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+                           "NoOpAnnotatorQueue");
+                   
+                   
+                   appCtx.put(UimaAsynchronousEngine.Timeout, 1100);
+                   appCtx.put(UimaAsynchronousEngine.CpcTimeout, 1100);
+                   initialize(uimaAsEngine, appCtx);
+                   waitUntilInitialized();
+               CAS cas = uimaAsEngine.getCAS();
+               getLargeCAS(cas, new 
File("C:/uima/largeCASTest/NYT_ENG_20070514.0065.out.xmi"));
+              
+               System.out.println("UIMA AS Client Sending CAS Request to a 
Service");
+                   uimaAsEngine.sendCAS(cas);
+                   uimaAsEngine.collectionProcessingComplete();
+                   System.clearProperty("DefaultBrokerURL");
+                   uimaAsEngine.stop();          
+               
+           } catch( Exception e) {
+               e.printStackTrace();
+           }
+  }
+  */
+  /**
+   * Tests service quiesce and stop support. This test sets a CasPool to 1 to 
send just one CAS at a
+   * time. After the first CAS is sent, a thread is started with a timer to 
expire before the reply
+   * is received. When the timer expires, the client initiates quiesceAndStop 
on the top level
+   * controller. As part of this, the top level controller stops its listeners 
on the input queue
+   * (GetMeta and Process Listeners), and registers a callback with the 
InProcess cache. When the
+   * cache is empty, meaning all CASes are processed, the cache notifies the 
controller which then
+   * begins the service shutdown. Meanwhile, the client receives a reply for 
the first CAS, and
+   * sends a second CAS. This CAS, will remain in the queue as the service has 
previously stopped
+   * its listeners. The client times out after 10 seconds and shuts down.
+   * 
+   * @throws Exception
+   */
+  public void testQuiesceAndStop() throws Exception {
+    System.out.println("-------------- testQuiesceAndStop -------------");
+    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
+    Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+            "TopLevelTaeQueue");
+    // Set an explicit process timeout so to test the ping on timeout
+    appCtx.put(UimaAsynchronousEngine.Timeout, 10000);
+    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 300);
+    appCtx.put(UimaAsynchronousEngine.CasPoolSize, 10);
+    String containers[] = new String[1];
+    containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_ScaledPrimitiveAggregateAnnotator.xml");
+
+    
+//    String containers[] = new String[2];
+ //   containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
+   // containers[1] =  deployService(eeUimaEngine, relativePath
+     //       + "/Deploy_AggregateAnnotatorWithInternalCM1000Docs.xml");
+//    spinShutdownThread(eeUimaEngine, 5000, containers, 
SpringContainerDeployer.QUIESCE_AND_STOP);
+    spinShutdownThread(eeUimaEngine, 5000, containers, 
SpringContainerDeployer.QUIESCE_AND_STOP);
+    
+    runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()),
+            "TopLevelTaeQueue", 1000, EXCEPTION_LATCH);
+    //eeUimaEngine.stop();
+  }
+/*
+  public void testQuiesceAndStop2() throws Exception {
+           System.out.println("-------------- testQuiesceAndStop 
-------------");
+           BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
+           Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+                   "TopLevelTaeQueue");
+           // Set an explicit process timeout so to test the ping on timeout
+           appCtx.put(UimaAsynchronousEngine.Timeout, 10000);
+           appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 300);
+           appCtx.put(UimaAsynchronousEngine.CasPoolSize, 1);
+           String containers[] = new String[1];
+           containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_ScaledPrimitiveAggregateAnnotator.xml");
+           
+           
+           runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()),
+                   "TopLevelTaeQueue", 100, PROCESS_LATCH);
+           System.out.println("------------ Undeploying ----------------");
+           eeUimaEngine.undeploy(containers[0] , 
SpringContainerDeployer.QUIESCE_AND_STOP);
+//         eeUimaEngine.stop();
+         }
+
+  */
+  
+  
+  
+  public void testStopNow() throws Exception {
+    System.out.println("-------------- testAggregateWithFailedRemoteDelegate 
-------------");
+    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
+    String containers[] = new String[2];
+
+    containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
+    containers[1] = deployService(eeUimaEngine, relativePath
+            + "/Deploy_AggregateAnnotatorWithInternalCM1000Docs.xml");
+    Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
+            "TopLevelTaeQueue");
+    // Set an explicit process timeout so to test the ping on timeout
+    appCtx.put(UimaAsynchronousEngine.Timeout, 4000);
+    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 300);
+    spinShutdownThread(eeUimaEngine, 3000, containers, 
SpringContainerDeployer.STOP_NOW);
+    //  send may fail since we forcefully stop the service. Tolerate
+    //  ResourceProcessException
+    addExceptionToignore(ResourceProcessException.class); 
+    runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()),
+            "TopLevelTaeQueue", 10, EXCEPTION_LATCH);
+  }
+  public void testSendAndReceive() throws Exception  {
+      BaseUIMAAsynchronousEngine_impl uimaAsEngine 
+       = new BaseUIMAAsynchronousEngine_impl();
+      
+      deployService(uimaAsEngine, relativePath + 
"/Deploy_MeetingDetectorAggregate.xml");
+      // Deploy Uima AS Primitive Service
+ //     deployService(uimaAsEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
+      Map<String, Object> appCtx = 
buildContext(broker.getMasterConnectorURI().toString(),"MeetingDetectorQueue");
+      appCtx.put(UimaAsynchronousEngine.Timeout, 1100);
+      appCtx.put(UimaAsynchronousEngine.CpcTimeout, 1100);
+      initialize(uimaAsEngine, appCtx);
+      waitUntilInitialized();
+      int errorCount = 0;
+      List<AnalysisEnginePerformanceMetrics> componentMetricsList = 
+                 new ArrayList<AnalysisEnginePerformanceMetrics>();
+      for (int i = 0; i < 15; i++) {
+        CAS cas = uimaAsEngine.getCAS();
+        cas.setDocumentText("Some Text");
+        System.out.println("UIMA AS Client Sending CAS#" + (i + 1) + " Request 
to a Service");
+        try {
+          uimaAsEngine.sendAndReceiveCAS(cas,componentMetricsList);
+          System.out.println("-------> Client Received Performance Metrics of 
Size:"+componentMetricsList.size());
+        } catch( Exception e) {
+          errorCount++;
+        } finally {
+          cas.release();
+          componentMetricsList.clear();
+        }
+      }
+      uimaAsEngine.stop();
+  }
   public void testMultipleSyncClientsWithMultipleBrokers() throws Exception  {
            System.out.println("-------------- 
testMultipleSyncClientsWithMultipleBrokers -------------");
            
@@ -174,58 +358,6 @@ public class TestUimaASExtended extends 
            broker.stop();
        }
   
-  /**
-   * Tests service quiesce and stop support. This test sets a CasPool to 1 to 
send just one CAS at a
-   * time. After the first CAS is sent, a thread is started with a timer to 
expire before the reply
-   * is received. When the timer expires, the client initiates quiesceAndStop 
on the top level
-   * controller. As part of this, the top level controller stops its listeners 
on the input queue
-   * (GetMeta and Process Listeners), and registers a callback with the 
InProcess cache. When the
-   * cache is empty, meaning all CASes are processed, the cache notifies the 
controller which then
-   * begins the service shutdown. Meanwhile, the client receives a reply for 
the first CAS, and
-   * sends a second CAS. This CAS, will remain in the queue as the service has 
previously stopped
-   * its listeners. The client times out after 10 seconds and shuts down.
-   * 
-   * @throws Exception
-   */
-  public void testQuiesceAndStop() throws Exception {
-    System.out.println("-------------- testQuiesceAndStop -------------");
-    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
-    Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
-            "TopLevelTaeQueue");
-    // Set an explicit process timeout so to test the ping on timeout
-    appCtx.put(UimaAsynchronousEngine.Timeout, 10000);
-    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 300);
-    appCtx.put(UimaAsynchronousEngine.CasPoolSize, 1);
-    String containers[] = new String[2];
-    containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
-    containers[1] =  deployService(eeUimaEngine, relativePath
-            + "/Deploy_AggregateAnnotatorWithInternalCM1000Docs.xml");
-    spinShutdownThread(eeUimaEngine, 5000, containers, 
SpringContainerDeployer.QUIESCE_AND_STOP);
-    runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()),
-            "TopLevelTaeQueue", 3, EXCEPTION_LATCH);
-    eeUimaEngine.stop();
-  }
-
-  public void testStopNow() throws Exception {
-    System.out.println("-------------- testAggregateWithFailedRemoteDelegate 
-------------");
-    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new 
BaseUIMAAsynchronousEngine_impl();
-    String containers[] = new String[2];
-
-    containers[0] = deployService(eeUimaEngine, relativePath + 
"/Deploy_NoOpAnnotator.xml");
-    containers[1] = deployService(eeUimaEngine, relativePath
-            + "/Deploy_AggregateAnnotatorWithInternalCM1000Docs.xml");
-    Map<String, Object> appCtx = 
buildContext(String.valueOf(broker.getMasterConnectorURI()),
-            "TopLevelTaeQueue");
-    // Set an explicit process timeout so to test the ping on timeout
-    appCtx.put(UimaAsynchronousEngine.Timeout, 4000);
-    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 300);
-    spinShutdownThread(eeUimaEngine, 3000, containers, 
SpringContainerDeployer.STOP_NOW);
-    //  send may fail since we forcefully stop the service. Tolerate
-    //  ResourceProcessException
-    addExceptionToignore(ResourceProcessException.class); 
-    runTest(appCtx, eeUimaEngine, 
String.valueOf(broker.getMasterConnectorURI()),
-            "TopLevelTaeQueue", 10, EXCEPTION_LATCH);
-  }
   public void testAggregateHttpTunnelling() throws Exception {
     System.out.println("-------------- testAggregateHttpTunnelling 
-------------");
     // Create Uima EE Client

Added: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml?rev=1229564&view=auto
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml
 (added)
+++ 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml
 Tue Jan 10 14:45:21 2012
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+  <!--
+   ***************************************************************
+   * Licensed to the Apache Software Foundation (ASF) under one
+   * or more contributor license agreements.  See the NOTICE file
+   * distributed with this work for additional information
+   * regarding copyright ownership.  The ASF licenses this file
+   * to you under the Apache License, Version 2.0 (the
+   * "License"); you may not use this file except in compliance
+   * with the License.  You may obtain a copy of the License at
+         *
+   *   http://www.apache.org/licenses/LICENSE-2.0
+   * 
+   * Unless required by applicable law or agreed to in writing,
+   * software distributed under the License is distributed on an
+   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   * KIND, either express or implied.  See the License for the
+   * specific language governing permissions and limitations
+   * under the License.
+   ***************************************************************
+   -->
+
+<analysisEngineDeploymentDescription 
xmlns="http://uima.apache.org/resourceSpecifier";>
+  
+  <name>Top Level TAE</name>
+  <description></description>
+  
+  <deployment protocol="jms" provider="activemq">
+    <casPool numberOfCASes="5"/>
+    <service>
+      <inputQueue endpoint="TopLevelTaeQueue" brokerURL="${DefaultBrokerURL}" 
prefetch="1"/>
+      <topDescriptor>
+        <import 
location="../descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml"/>
+      </topDescriptor>
+      <analysisEngine>
+        <delegates>
+        
+          <analysisEngine key="TestMultiplier">
+               <casMultiplier poolSize="5"/> 
+          </analysisEngine>
+
+          <remoteAnalysisEngine key="NoOp" remoteReplyQueueScaleout="3">
+                         <inputQueue endpoint="NoOpAnnotatorQueue" 
brokerURL="${DefaultBrokerURL}"/>
+                         <serializer method="xmi"/>
+                      <asyncAggregateErrorConfiguration>
+                            <getMetadataErrors maxRetries="3" timeout="0" 
errorAction="continue" />
+                            <processCasErrors maxRetries="0" timeout="0" 
thresholdCount="0" thresholdAction="continue" />
+                      </asyncAggregateErrorConfiguration>
+          </remoteAnalysisEngine>
+
+        </delegates>
+      </analysisEngine>
+    </service>
+  </deployment>
+  
+</analysisEngineDeploymentDescription>
\ No newline at end of file

Propchange: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/deployment/Deploy_AggregateAnnotatorWithFailingCollocatedCM.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml?rev=1229564&view=auto
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml
 (added)
+++ 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml
 Tue Jan 10 14:45:21 2012
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+       <!--
+        ***************************************************************
+        * Licensed to the Apache Software Foundation (ASF) under one
+        * or more contributor license agreements.  See the NOTICE file
+        * distributed with this work for additional information
+        * regarding copyright ownership.  The ASF licenses this file
+        * to you under the Apache License, Version 2.0 (the
+        * "License"); you may not use this file except in compliance
+        * with the License.  You may obtain a copy of the License at
+         *
+        *   http://www.apache.org/licenses/LICENSE-2.0
+        * 
+        * Unless required by applicable law or agreed to in writing,
+        * software distributed under the License is distributed on an
+        * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+        * KIND, either express or implied.  See the License for the
+        * specific language governing permissions and limitations
+        * under the License.
+        ***************************************************************
+   -->
+   
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier";>
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>false</primitive>
+  <delegateAnalysisEngineSpecifiers>
+    
+    <delegateAnalysisEngine key="TestMultiplier">
+      <import 
location="../multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml"/>
+    </delegateAnalysisEngine>
+
+
+      <delegateAnalysisEngine key="NoOp">
+      <import location="NoOpAnnotator.xml"/>
+    </delegateAnalysisEngine>
+  
+  </delegateAnalysisEngineSpecifiers>
+  <analysisEngineMetaData>
+    <name>Test Aggregate TAE</name>
+    <description>Detects Nothing</description>
+    <configurationParameters/>
+    <configurationParameterSettings/>
+    <flowConstraints>
+      <fixedFlow>
+      
+        <node>TestMultiplier</node>
+        <node>NoOp</node> 
+      </fixedFlow>
+    </flowConstraints>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs>
+        </outputs>
+        <languagesSupported>
+          <language>en</language>
+        </languagesSupported>
+      </capability>
+    </capabilities>
+       <operationalProperties>
+               <modifiesCas>true</modifiesCas>
+               <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+               <outputsNewCASes>true</outputsNewCASes>
+       </operationalProperties>
+  </analysisEngineMetaData>
+</analysisEngineDescription>

Propchange: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/analysis_engine/SimpleTestAggregateWithFailingCasMultiplier.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml?rev=1229564&view=auto
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml
 (added)
+++ 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml
 Tue Jan 10 14:45:21 2012
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <!--
+   ***************************************************************
+   * Licensed to the Apache Software Foundation (ASF) under one
+   * or more contributor license agreements.  See the NOTICE file
+   * distributed with this work for additional information
+   * regarding copyright ownership.  The ASF licenses this file
+   * to you under the Apache License, Version 2.0 (the
+   * "License"); you may not use this file except in compliance
+   * with the License.  You may obtain a copy of the License at
+         *
+   *   http://www.apache.org/licenses/LICENSE-2.0
+   * 
+   * Unless required by applicable law or agreed to in writing,
+   * software distributed under the License is distributed on an
+   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   * KIND, either express or implied.  See the License for the
+   * specific language governing permissions and limitations
+   * under the License.
+   ***************************************************************
+   -->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier";>
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>true</primitive>
+  
<annotatorImplementationName>org.apache.uima.ae.multiplier.SimpleCasGenerator</annotatorImplementationName>
+  <analysisEngineMetaData>
+    <name>Simple Text Segmenter</name>
+    <description>Generates specified number of CASes.</description>
+    <version>1.0</version>
+    <vendor>The Apache Software Foundation</vendor>
+    <configurationParameters>
+      <configurationParameter>
+        <name>NumberToGenerate</name>
+        <description>Approximate number of CASes to create.</description>
+        <type>Integer</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>DocumentNumberToFailOn</name>
+        <description>Forces failure on specified document</description>
+        <type>Integer</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      
+      
+      <configurationParameter>
+        <name>StringOne</name>
+        <description>document text</description>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>StringTwo</name>
+        <description>document text</description>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+    
+    
+      <configurationParameter>
+        <name>InputFile</name>
+        <description>document text</description>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+    
+    
+    
+    
+    </configurationParameters>
+    <configurationParameterSettings>
+      <nameValuePair>
+        <name>NumberToGenerate</name>
+        <value>
+          <integer>100</integer>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>DocumentNumberToFailOn</name>
+        <value>
+          <integer>10</integer>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>StringOne</name>
+        <value>
+          <string>Upcoming UIMA Seminars      April 7, 2004 Distillery Lunch 
Seminar   UIMA and its Metadata   12:00PM-1:00PM in HAW GN-K35.       Dave 
Ferrucci will give a UIMA overview and discuss the types of component metadata 
that UIMA components provide.  Jon Lenchner will give a demo of the Text 
Analysis Engine configurator tool.         April 16, 2004 KM &amp; I Department 
Tea    Title: An Eclipse-based TAE Configurator Tool   3:00PM-4:30PM in HAW 
GN-K35 .      Jon Lenchner will demo an Eclipse plugin for configuring TAE 
descriptors, which will be available soon for you to use.  No more editing XML 
descriptors by hand!         May 11, 2004 UIMA Tutorial    9:00AM-5:00PM in HAW 
GN-K35.      This is a full-day, hands-on tutorial on UIMA, covering the 
development of Text Analysis Engines and Collection Processing Engines, as well 
as how to include these components in your own applications.   </string>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>StringTwo</name>
+        <value>
+          <string>UIMA Summer School      August 26, 2003   UIMA 101 - The New 
UIMA Introduction    (Hands-on Tutorial)   9:00AM-5:00PM in HAW GN-K35      
August 28, 2003   FROST Tutorial   9:00AM-5:00PM in HAW GN-K35      September 
15, 2003   UIMA 201: UIMA Advanced Topics    (Hands-on Tutorial)   
9:00AM-5:00PM in HAW 1S-F53      September 17, 2003   The UIMA System 
Integration Test and Hardening Service   The "SITH"   3:00PM-4:30PM in HAW 
GN-K35            UIMA Summer School Tutorial and Presentation Details   UIMA 
101: The new UIMA tutorial     Tuesday August 26 9:00AM - 4:30PM in GN-K35      
UIMA 101 is a hands-on programming tutorial.      UIMA 101 is intended for 
people who want a first introductory course to UIMA or for people who would 
like a refresher.      The tutorial covers the same concepts in the first UIMA 
tutorial given in 3Q 2002 except for some key updates:      1) It uses a new 
interface to the CAS that makes it more natural to access and update CAS featur
 e structures using ordinary Java objects (i.e., the JCAS) and   2) It uses 
updated TAE interfaces that give the application developer more control over 
managing multiple CASs.       Please NOTE expert users of UIMA can skip this 
one and should consider attending the Advanced Topics tutorial.      
Prerequisites for the UIMA 101 Tutorial   1) Java Programming   2) Some 
experience with Eclipse IDE helpful      FROST Tutorial   August 28  9:00AM - 
5:00PM  in GN-K35      Visitors from the FROST team will be here to talk to us 
about FROST.      UIMA 201: The UIMA Advanced Topics Tutorial   September 15:   
9:00AM - 5:30PM in Hawthorne 1S-F53      UIMA 201 will introduce some new UIMA 
concepts and walk the student through hands-on examples.      The advanced 
topics tutorial is designed for people who have some experience with UIMA and 
want    to use new capabilities of UIMA 1.0 to address one or more of the 
following    Advanced Topics:      1) Collection Processing and Collection P
 rocessing Engines (CPEs)   2) Multi-Threading and CAS Pooling   3) Using the 
UIMA adapter framework to integrate network TAEs with Java TAEs   4) A Semantic 
Search Application that brings it all together          Prerequisites for UIMA 
201   1) UIMA 101 Tutorial OR Extensive UIMA Experience      The UIMA 
Integration Test bed Service (The "SITH")   September 17 3:00PM - 4:30PM in HAW 
GN-K35      We have developed the first version of the UIMA Integration Test 
bed service.      This service is being developed to help test, evaluate, 
certify and publish UIMA compliant components.      In this talk we will 
explain the service and what it is intended to provide the UIMA community. We 
will address the following topics:      1. SITH Services   2. How to submit 
components and what to expect in return   3. Overview of the test bed 
implementation using Collection Processing UIMA and Juru.    4. Next Steps for 
the SITH         </string>
+        </value>
+      </nameValuePair>
+    
+      <nameValuePair>
+        <name>InputFile</name>
+        <value>
+        <string>data/IBM_LifeSciences.xml</string>
+          <!-- <string>c:/new-nt.xml</string>  -->
+        </value>
+      </nameValuePair>
+    
+    </configurationParameterSettings>
+    <typeSystemDescription/>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs/>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>false</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>true</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+</analysisEngineDescription>

Propchange: 
uima/uima-as/trunk/uimaj-as-activemq/src/test/resources/descriptors/multiplier/SimpleCasGeneratorWithFailureOnNthDocument.xml
------------------------------------------------------------------------------
    svn:eol-style = native

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=1229564&r1=1229563&r2=1229564&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
 Tue Jan 10 14:45:21 2012
@@ -1269,14 +1269,14 @@ public class AggregateAnalysisEngineCont
           CAS cas = cacheEntry.getCas();
           logCasForEndpoint(analysisEngineKey, cas);
         }
-
+        Delegate delegate = lookupDelegate(analysisEngineKey);
+        casStateEntry.setLastDelegate(delegate);
         if (endpoint.isCasMultiplier()) {
-          Delegate delegateCM = lookupDelegate(analysisEngineKey);
-          delegateCM.setGeneratingChildrenFrom(aCasReferenceId, true);
+          delegate.setGeneratingChildrenFrom(aCasReferenceId, true);
           // Record the outgoing CAS. CASes destined for remote CM are recorded
           // in JmsOutputchannel.
           if (!endpoint.isRemote()) {
-            delegateCM.addNewCasToOutstandingList(aCasReferenceId, true);
+            delegate.addNewCasToOutstandingList(aCasReferenceId, true);
           }
         }
 

Modified: 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java?rev=1229564&r1=1229563&r2=1229564&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
 Tue Jan 10 14:45:21 2012
@@ -1781,6 +1781,29 @@ public abstract class BaseAnalysisEngine
     if (!isStopped()) {
       setStopped();
     }
+    /*
+     * Send an exception to the client if this is a top level service
+     */
+    if (cause != null && aCasReferenceId != null && getOutputChannel() != null
+            && isTopLevelComponent()) {
+      Endpoint clientEndpoint = null;
+      if ((clientEndpoint = getClientEndpoint()) != null) {
+        try {
+          getOutputChannel().sendReply(cause, aCasReferenceId, null, 
clientEndpoint,
+                  clientEndpoint.getCommand());
+        } catch (Exception e) {
+          if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
+            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
CLASS_NAME.getName(),
+                    "stop", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
+                    "UIMAEE_service_exception_WARNING", getComponentName());
+
+            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
CLASS_NAME.getName(), "stop",
+                    UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, 
"UIMAEE_exception__WARNING",
+                   e);
+          }
+        }
+      }
+    }
 
     if (daemonServiceExecutor != null) {
       daemonServiceExecutor.shutdown();
@@ -1821,35 +1844,20 @@ public abstract class BaseAnalysisEngine
     }
     // Stops internal transport used to communicate with colocated services
     stopTransportLayer();
-    /*
-     * Commented this block. It generates ShutdownException which causes 
problems The shutdown of
-     * services happens ad hoc and not orderly. This whole logic needs to be 
revisited.
-     * 
-     * // Send an exception to the client if this is a top level service
-     */
-    if (cause != null && aCasReferenceId != null && getOutputChannel() != null
-            && isTopLevelComponent()) {
-
-      Endpoint clientEndpoint = null;
-      if ((clientEndpoint = getClientEndpoint()) != null) {
-        try {
-          getOutputChannel().sendReply(cause, aCasReferenceId, null, 
clientEndpoint,
-                  clientEndpoint.getCommand());
-        } catch (Exception e) {
-          if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
-            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
CLASS_NAME.getName(),
-                    "stop", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
-                    "UIMAEE_service_exception_WARNING", getComponentName());
-
-            UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, 
CLASS_NAME.getName(), "stop",
-                    UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, 
"UIMAEE_exception__WARNING",
-                   e);
-          }
-        }
-      }
-    }
+    for (Iterator it = getLocalCache().entrySet().iterator(); it.hasNext();) {
+       Map.Entry entry = (Map.Entry) it.next();
+       CasStateEntry casStateEntry = (CasStateEntry) entry.getValue();
+       if ( casStateEntry.isSubordinate() ) {
+         try {
+           
getInProcessCache().getCacheEntryForCAS(casStateEntry.getCasReferenceId()).getCas().release();
+         } catch( Exception e) {
+           
+         }
+       }
+    }   
+    
     getInProcessCache().releaseAllCASes();
-
+    getLocalCache().clear();
     releasedAllCASes = true;
     if (!isTopLevelComponent()) {
       adminContext = null;


Reply via email to