You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2013/06/15 01:00:42 UTC

svn commit: r1493276 - in /uima/uima-as/trunk: uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/ uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/ uimaj-as-activemq/src/test/java/org/apache/uima/ee/test/ uimaj-as-c...

Author: schor
Date: Fri Jun 14 23:00:41 2013
New Revision: 1493276

URL: http://svn.apache.org/r1493276
Log:
[UIMA-2791] add basic support to uima-as for compressed binary transport, but leave disabled until testing done.

Modified:
    uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java
    uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.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/InProcessCache.java
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaSerializer.java
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/client/UimaAsynchronousEngine.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/Endpoint_impl.java
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java
    uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/message/AsynchAEMessage.java
    uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java

Modified: uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/activemq/JmsOutputChannel.java Fri Jun 14 23:00:41 2013
@@ -91,7 +91,7 @@ public class JmsOutputChannel implements
   private static final Class CLASS_NAME = JmsOutputChannel.class;
 
   private static final long INACTIVITY_TIMEOUT = 60; // MINUTES
-  
+
   private CountDownLatch controllerLatch = new CountDownLatch(1);
 
   private ActiveMQConnectionFactory connectionFactory;
@@ -721,6 +721,7 @@ public class JmsOutputChannel implements
               getAnalysisEngineController());
     }
   }
+  
   private void serializeCasAndSend(CacheEntry entry, Endpoint anEndpoint) throws Exception {
     if (anEndpoint.getSerialFormat() == SerialFormat.XMI) {
       String serializedCAS = getSerializedCasAndReleaseIt(false, entry.getCasReferenceId(), anEndpoint,
@@ -1024,8 +1025,9 @@ public class JmsOutputChannel implements
 
       tm.setIntProperty(AsynchAEMessage.Payload, AsynchAEMessage.Metadata);
       // This service supports Binary Serialization
-//      tm.setIntProperty(AsynchAEMessage.Serialization, AsynchAEMessage.BinarySerialization);
+      // change comment on next 2 lines to install compressed serialization as the capability
       tm.setIntProperty(AsynchAEMessage.SERIALIZATION, AsynchAEMessage.BINARY_SERIALIZATION);
+//      tm.setIntProperty(AsynchAEMessage.SERIALIZATION, AsynchAEMessage.BINARY_COMPRESSED_FILTERED_SERIALIZATION);
 
       populateHeaderWithResponseContext(tm, anEndpoint, AsynchAEMessage.GetMeta);
       if (freeCASTempQueue != null) {
@@ -1106,18 +1108,36 @@ public class JmsOutputChannel implements
       //  Fetch dedicated Serializer associated with this thread
       UimaSerializer serializer = SerializerCache.lookupSerializerByThreadId();
 
-      if (serializerType == SerialFormat.BINARY) {
+      if (serializerType == SerialFormat.BINARY || serializerType == SerialFormat.COMPRESSED_FILTERED) {
         
         if (entry.acceptsDeltaCas() && isReply) {
           if (entry.getMarker() != null && entry.getMarker().isValid()) {
-            serializedCAS = serializer.serializeCasToBinary(cas, entry.getMarker());
+            if (serializerType == SerialFormat.COMPRESSED_FILTERED) {
+              serializedCAS = serializer.serializeCasToBinary6(cas, entry.getMarker(), entry.getCompress6ReuseInfo());  
+            } else {
+              serializedCAS = serializer.serializeCasToBinary(cas, entry.getMarker());
+            }
             entry.setSentDeltaCas(true);
           } else {
-            serializedCAS = serializer.serializeCasToBinary(cas);
+            if (serializerType == SerialFormat.COMPRESSED_FILTERED) {
+              serializedCAS = serializer.serializeCasToBinary6(cas); 
+            } else {
+              serializedCAS = serializer.serializeCasToBinary(cas);
+            }
             entry.setSentDeltaCas(false);
           }
         } else {
-          serializedCAS = serializer.serializeCasToBinary(cas);
+          // either is a reply to a caller not accepting delta, or
+          //        is not a reply
+          if (serializerType == SerialFormat.COMPRESSED_FILTERED) {
+            if (isReply) {
+              serializedCAS = serializer.serializeCasToBinary6(cas);  // never called? 
+            } else {
+              serializedCAS = serializer.serializeCasToBinary6(cas, entry, anEndpoint.getTypeSystemImpl());
+            }
+          } else {
+            serializedCAS = serializer.serializeCasToBinary(cas);
+          }
           entry.setSentDeltaCas(false);
           if (isReply) {
             if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
@@ -1928,7 +1948,7 @@ public class JmsOutputChannel implements
                       			value.getValue().close();  // close the jms session
                       			it.remove();
 /*
-                      			System.out.println("-------- Closing Session for Destination:"+value.getValue().delegateEndpoint.getDestination());
+                    			System.out.println("-------- Closing Session for Destination:"+value.getValue().delegateEndpoint.getDestination());
                                 UIMAFramework.getLogger(CLASS_NAME).logrb(
                                         Level.INFO,
                                         CLASS_NAME.getName(),
@@ -1938,7 +1958,7 @@ public class JmsOutputChannel implements
                                         new Object[] { Thread.currentThread().getId(), componentName,
                                             inactivityTimeout, value.getValue().delegateEndpoint.getDestination(), brokerDestinations.getBrokerURL()  });
 */
-                      		}
+                    		}
                       	}
                       } catch (Exception e) {
                       	e.printStackTrace();
@@ -1969,7 +1989,7 @@ public class JmsOutputChannel implements
                   } catch (Exception e) {
                   } 
             }
-        }, 0, inactivityTimeout,TimeUnit.MINUTES);
+        }, 0, inactivityTimeout * 60,TimeUnit.SECONDS);
         
       }
     private void cancelTimer() {

Modified: uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java Fri Jun 14 23:00:41 2013
@@ -298,6 +298,7 @@ public class BaseUIMAAsynchronousEngine_
 				}
 				// Undeploy all containers
 				undeploy();
+				clientCache.clear();
 				if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(
 						Level.INFO)) {
 					UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO,
@@ -657,7 +658,9 @@ public class BaseUIMAAsynchronousEngine_
     }
     if (anApplicationContext.containsKey(UimaAsynchronousEngine.SERIALIZATION_STRATEGY)) {
       final String serializationStrategy = (String) anApplicationContext.get(UimaAsynchronousEngine.SERIALIZATION_STRATEGY);
+      // change this to support compressed filitered as the default
       setSerialFormat((serializationStrategy.equalsIgnoreCase("xmi")) ? SerialFormat.XMI : SerialFormat.BINARY);
+//      setSerialFormat((serializationStrategy.equalsIgnoreCase("xmi")) ? SerialFormat.XMI : SerialFormat.COMPRESSED_FILTERED);
       clientSideJmxStats.setSerialization(getSerialFormat());
     }
     if (anApplicationContext.containsKey(UimaAsynchronousEngine.userName)) {

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=1493276&r1=1493275&r2=1493276&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 Fri Jun 14 23:00:41 2013
@@ -99,6 +99,34 @@ public class TestUimaASExtended extends 
 
   public BaseTestSupport superRef = null;
 
+  /**
+   * bring up testing for compressed binary serialization
+   */
+  
+  /**
+   * Test binary compressed serialization between client and svc, and between 
+   * service and remote delegate
+   * 
+   * @throws Exception
+   */
+  public void testCompressedTypeFiltering() throws Exception {
+    System.out.println("-------------- testCompressedTypeFiltering -------------");
+    // Instantiate Uima-AS Client
+    final BaseUIMAAsynchronousEngine_impl uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
+    // Deploy Uima-AS Primitive Service
+    deployService(uimaAsEngine, relativePath + "/Deploy_RoomNumberAnnotator.xml");
+    deployService(uimaAsEngine, relativePath + "/Deploy_MeetingDetectorTAE_RemoteRoomNumberBinary.xml");
+    Map<String, Object> appCtx = buildContext(String.valueOf(broker.getMasterConnectorURI()), "MeetingDetectorTaeQueue");
+    // Set an explicit getMeta (Ping)timeout
+    appCtx.put(UimaAsynchronousEngine.GetMetaTimeout, 2000);
+    // Set an explicit process timeout so to test the ping on timeout
+    appCtx.put(UimaAsynchronousEngine.Timeout, 1000);
+    appCtx.put(UimaAsynchronousEngine.SERIALIZATION_STRATEGY, "binary");
+
+    runTest(null, uimaAsEngine, String.valueOf(broker.getMasterConnectorURI()),
+            "MeetingDetectorTaeQueue", 3, PROCESS_LATCH);
+  }
+
   
   /**
    * Tests Broker startup and shutdown
@@ -433,7 +461,7 @@ public class TestUimaASExtended extends 
   
   public void testAggregateHttpTunnelling() throws Exception {
     System.out.println("-------------- testAggregateHttpTunnelling -------------");
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
@@ -448,7 +476,7 @@ public class TestUimaASExtended extends 
     System.out.println("-------------- testClientHttpTunnellingToAggregate -------------");
     // Add HTTP Connector to the broker. 
     String httpURI = getHttpURI();
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
@@ -460,7 +488,7 @@ public class TestUimaASExtended extends 
   public void testClientHttpTunnelling() throws Exception {
     System.out.println("-------------- testClientHttpTunnelling -------------");
     String httpURI = getHttpURI();
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
@@ -491,7 +519,7 @@ public class TestUimaASExtended extends 
         System.out.println(" ***   in the apache-uima-as source distribution.");
 
         String httpURI = getHttpURI();
-      // Create Uima EE Client
+      // Create Uima-AS Client
         BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
         // Deploy remote service
         deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
@@ -1305,7 +1333,7 @@ public class TestUimaASExtended extends 
    */
   public void testInvalidInitializeCall() throws Exception {
     System.out.println("-------------- testInvalidInitializeCall -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
 
     deployService(eeUimaEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
@@ -1335,8 +1363,8 @@ public class TestUimaASExtended extends 
   }
 
   /**
-   * Tests deployment of a primitive Uima EE Service (PersontTitleAnnotator). Deploys the primitive
-   * in the same jvm using Uima EE Client API and blocks on a monitor until the Uima Client calls
+   * Tests deployment of a primitive Uima-AS Service (PersontTitleAnnotator). Deploys the primitive
+   * in the same jvm using Uima-AS Client API and blocks on a monitor until the Uima Client calls
    * initializationComplete() method. Once the primitive service starts it is expected to send its
    * metadata to the Uima client which in turn notifies this object with a call to
    * initializationComplete() where the monitor is signaled to unblock the thread. This code will
@@ -1346,18 +1374,18 @@ public class TestUimaASExtended extends 
    */
   public void testDeployPrimitiveService() throws Exception {
     System.out.println("-------------- testDeployPrimitiveService -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()),
             "PersonTitleAnnotatorQueue", 0, EXCEPTION_LATCH);
   }
   public void testDeployPrimitiveServiceWithInitFailure() throws Exception {
 	    System.out.println("-------------- testDeployPrimitiveServiceWithInitFailure -------------");
-	    // Instantiate Uima EE Client
+	    // Instantiate Uima-AS Client
 	    BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-	    // Deploy Uima EE Primitive Service
+	    // Deploy Uima-AS Primitive Service
 	    try {
 		    deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithInitException.xml");
 	    } catch( ResourceInitializationException e) {
@@ -1369,9 +1397,9 @@ public class TestUimaASExtended extends 
   
   public void testTypeSystemMerge() throws Exception {
     System.out.println("-------------- testTypeSystemMerge -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath+ "/Deploy_GovernmentOfficialRecognizer.xml");
     deployService(eeUimaEngine, relativePath+ "/Deploy_NamesAndPersonTitlesRecognizer.xml");
     deployService(eeUimaEngine, relativePath+ "/Deploy_TokenSentenceRecognizer.xml");
@@ -1421,10 +1449,10 @@ public class TestUimaASExtended extends 
    */
   public void testMultiInstanceDeployFailureInPrimitiveService() throws Exception {
     System.out.println("-------------- testMultiInstanceDeployFailureInPrimitiveService -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     try {
-      // Deploy Uima EE Primitive Service
+      // Deploy Uima-AS Primitive Service
       deployService(eeUimaEngine, relativePath + "/Deploy_ScaledPersonTitleAnnotator.xml");
       fail("Expected ResourceInitializationException Due to Misconfiguration but instead the service initialized successfully");
     } catch ( ResourceInitializationException e) {
@@ -1438,9 +1466,9 @@ public class TestUimaASExtended extends 
    */
   public void testDeployAggregateWithDelegateCpCException() throws Exception {
     System.out.println("-------------- testDeployAggregateWithDelegateCpCException -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithCpCException.xml");
     deployService(eeUimaEngine, relativePath + "/Deploy_AggregateAnnotator.xml");
     addExceptionToignore(org.apache.uima.aae.error.UimaEEServiceException.class);
@@ -1474,9 +1502,9 @@ public class TestUimaASExtended extends 
 
   public void testDeployPrimitiveServiceWithCpCException() throws Exception {
     System.out.println("-------------- testDeployPrimitiveServiceWithCpCException -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithCpCException.xml");
     // Add expected exception so that we release CPC Latch
     addExceptionToignore(org.apache.uima.aae.error.UimaEEServiceException.class);
@@ -1492,9 +1520,9 @@ public class TestUimaASExtended extends 
    */
   public void testCpCWithNoCASesSent() throws Exception {
     System.out.println("-------------- testCpCWithNoCASesSent -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl uimaAsEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(uimaAsEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
     Map<String, Object> appCtx = buildContext(String.valueOf(broker.getMasterConnectorURI()),
             "PersonTitleAnnotatorQueue");
@@ -1641,9 +1669,9 @@ public class TestUimaASExtended extends 
   
   public void testScaledSyncAggregateProcess() throws Exception {
     System.out.println("-------------- testScaledSyncAggregateProcess -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_ScaledPrimitiveAggregateAnnotator.xml");
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()), "TopLevelTaeQueue",
             5, PROCESS_LATCH);
@@ -1951,7 +1979,7 @@ public class TestUimaASExtended extends 
 	  }
 
   /**
-   * Tests exception thrown in the Uima EE Client when the Collection Reader is added after the uima
+   * Tests exception thrown in the Uima-AS Client when the Collection Reader is added after the uima
    * ee client is initialized
    * 
    * @throws Exception
@@ -1959,7 +1987,7 @@ public class TestUimaASExtended extends 
   public void testExceptionOnPostInitializeCollectionReaderInjection() throws Exception {
     System.out
             .println("-------------- testExceptionOnPostInitializeCollectionReaderInjection -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     deployService(eeUimaEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
     Map<String, Object> appCtx = buildContext(String.valueOf(broker.getMasterConnectorURI()),
@@ -2056,48 +2084,48 @@ public class TestUimaASExtended extends 
   }
 
   /**
-   * Deploys a Primitive Uima EE service and sends 5 CASes to it.
+   * Deploys a Primitive Uima-AS service and sends 5 CASes to it.
    * 
    * @throws Exception
    */
 
   public void testPrimitiveServiceProcess() throws Exception {
     System.out.println("-------------- testPrimitiveServiceProcess -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()),
             "PersonTitleAnnotatorQueue", 5, PROCESS_LATCH);
   }
 
   /**
-   * Deploys a Primitive Uima EE service and sends 5 CASes to it.
+   * Deploys a Primitive Uima-AS service and sends 5 CASes to it.
    * 
    * @throws Exception
    */
 
   public void testSyncAggregateProcess() throws Exception {
     System.out.println("-------------- testSyncAggregateProcess -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_MeetingDetectorAggregate.xml");
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()),
             "MeetingDetectorQueue", 5, PROCESS_LATCH);
   }
 
   /**
-   * Deploys a Primitive Uima EE service and sends 5 CASes to it.
+   * Deploys a Primitive Uima-AS service and sends 5 CASes to it.
    * 
    * @throws Exception
    */
 
   public void testPrimitiveServiceProcessPingFailure() throws Exception {
     System.out.println("-------------- testPrimitiveServiceProcessPingFailure -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     final BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     final String containerID = deployService(eeUimaEngine, relativePath
             + "/Deploy_PersonTitleAnnotator.xml");
     Map<String, Object> appCtx = buildContext(String.valueOf(broker.getMasterConnectorURI()),
@@ -2148,9 +2176,9 @@ public class TestUimaASExtended extends 
    */
   public void testDelegateTimeoutAndDisable() throws Exception {
     System.out.println("-------------- testDelegateTimeoutAndDisable -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     final BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     final String containerID = deployService(eeUimaEngine, relativePath
             + "/Deploy_RoomNumberAnnotator.xml");
     deployService(eeUimaEngine, relativePath
@@ -2196,9 +2224,9 @@ public class TestUimaASExtended extends 
    */
   public void testDisableDelegateOnTimeoutWithCM() throws Exception {
     System.out.println("-------------- testDisableDelegateOnTimeoutWithCM -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     final BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     final String containerID = deployService(eeUimaEngine, relativePath
             + "/Deploy_RoomNumberAnnotator.xml");
     deployService(eeUimaEngine, relativePath
@@ -2234,8 +2262,8 @@ public class TestUimaASExtended extends 
   }
 
   /**
-   * Tests Uima EE client ability to test sendAndReceive in multiple/concurrent threads It spawns 4
-   * thread each sending 100 CASes to a Primitive Uima EE service
+   * Tests Uima-AS client ability to test sendAndReceive in multiple/concurrent threads It spawns 4
+   * thread each sending 100 CASes to a Primitive Uima-AS service
    * 
    * @throws Exception
    */
@@ -2254,7 +2282,7 @@ public class TestUimaASExtended extends 
   public void testPrimitiveProcessCallWithLongDelay() throws Exception {
     System.out.println("-------------- testPrimitiveProcessCallWithLongDelay -------------");
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithLongDelay.xml");
     // We expect 18000ms to be spent in process method
     super.setExpectedProcessTime(6000);
@@ -2280,7 +2308,7 @@ public class TestUimaASExtended extends 
 
     System.out.println("-------------- testAggregateProcessCallWithLongDelay -------------");
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Services each with 6000ms delay in process()
+    // Deploy Uima-AS Primitive Services each with 6000ms delay in process()
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorAWithLongDelay.xml");
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorBWithLongDelay.xml");
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorCWithLongDelay.xml");
@@ -2305,7 +2333,7 @@ public class TestUimaASExtended extends 
   public void testAggregateProcessCallWithLastCM() throws Exception {
     System.out.println("-------------- testAggregateProcessCallWithLastCM -------------");
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
-    // Deploy Uima EE Primitive Services each with 6000ms delay in process()
+    // Deploy Uima-AS Primitive Services each with 6000ms delay in process()
     deployService(eeUimaEngine, relativePath + "/Deploy_AggregateWithLastCM.xml");
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()), "TopLevelTaeQueue",
             1, PROCESS_LATCH, true);
@@ -2350,7 +2378,7 @@ public class TestUimaASExtended extends 
   }
 
   /**
-   * Tests a parallel flow in the Uima EE aggregate.
+   * Tests a parallel flow in the Uima-AS aggregate.
    * 
    * @throws Exception
    */
@@ -2749,11 +2777,11 @@ public class TestUimaASExtended extends 
    */
   public void testPrimitiveServiceResponseOnException() throws Exception {
     System.out.println("-------------- testPrimitiveServiceResponseOnException -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithException.xml");
-    // Deploy Uima EE Primitive Service
+    // Deploy Uima-AS Primitive Service
     // Initialize and run the Test. Wait for a completion and cleanup resources.
     runTest(null, eeUimaEngine, String.valueOf(broker.getMasterConnectorURI()),
             "NoOpAnnotatorQueue", 1, EXCEPTION_LATCH);
@@ -2761,7 +2789,7 @@ public class TestUimaASExtended extends 
 
   public void testProcessParallelFlowWithDelegateFailure() throws Exception {
     System.out.println("-------------- testProcessParallelFlowWithDelegateFailure -------------");
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithException.xml");
@@ -2800,7 +2828,7 @@ public class TestUimaASExtended extends 
 
   public void testProcessParallelFlowWithDelegateDisable() throws Exception {
     System.out.println("-------------- testProcessParallelFlowWithDelegateDisable -------------");
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotatorWithException.xml");
     deployService(eeUimaEngine, relativePath + "/Deploy_SimpleAnnotator.xml");
@@ -2812,7 +2840,7 @@ public class TestUimaASExtended extends 
 
   public void testPrimitiveShutdownOnTooManyErrors() throws Exception {
     System.out.println("-------------- testPrimitiveShutdownOnTooManyErrors -------------");
-    // Create Uima EE Client
+    // Create Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     // Deploy remote service
     deployService(eeUimaEngine, relativePath + "/Deploy_NoOpAnnotator.xml");
@@ -2825,7 +2853,7 @@ public class TestUimaASExtended extends 
 
 
   /**
-   * Tests exception thrown in the Uima EE Client when the Collection Reader is added after the uima
+   * Tests exception thrown in the Uima-AS Client when the Collection Reader is added after the uima
    * ee client is initialized
    * 
    * @throws Exception
@@ -2833,7 +2861,7 @@ public class TestUimaASExtended extends 
 
   public void testCollectionReader() throws Exception {
     System.out.println("-------------- testCollectionReader -------------");
-    // Instantiate Uima EE Client
+    // Instantiate Uima-AS Client
     BaseUIMAAsynchronousEngine_impl eeUimaEngine = new BaseUIMAAsynchronousEngine_impl();
     deployService(eeUimaEngine, relativePath + "/Deploy_PersonTitleAnnotator.xml");
     Map<String, Object> appCtx = buildContext(String.valueOf(broker.getMasterConnectorURI()),
@@ -3217,7 +3245,9 @@ public class TestUimaASExtended extends 
   }
 
 
-  
+  public void testCatchExtraThreads() throws Exception {
+    Thread.sleep(24 * 60 * 60 * 1000);  // sleep for one day
+  }
   
   public void testDeployAgainAndAgain() throws Exception {
     System.out.println("-------------- testDeployAgainAndAgain -------------");

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/InProcessCache.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/InProcessCache.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/InProcessCache.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/InProcessCache.java Fri Jun 14 23:00:41 2013
@@ -433,10 +433,12 @@ public class InProcessCache implements I
 //  }
 
   public CacheEntry register(CAS aCAS, MessageContext aMessageContext,
-          XmiSerializationSharedData sharedData, String aCasReferenceId, Marker marker,
+          XmiSerializationSharedData sharedData, 
+          ReuseInfo compress6ReuseInfo, 
+          String aCasReferenceId, Marker marker,
           boolean acceptsDeltaCas) throws AsynchAEException {
     return registerCacheEntry(aCasReferenceId, new CacheEntry(aCAS, aCasReferenceId,
-            aMessageContext, sharedData, marker, acceptsDeltaCas));
+            aMessageContext, sharedData, compress6ReuseInfo, marker, acceptsDeltaCas));
   }
   
   public CacheEntry register(CAS aCAS, MessageContext aMessageContext,
@@ -617,15 +619,20 @@ public class InProcessCache implements I
 
     protected CacheEntry(CAS aCas, String aCasReferenceId, MessageContext aMessageAccessor,
             XmiSerializationSharedData sdata, Marker aMarker, boolean acceptsDeltaCas) {
-      this(aCas, aCasReferenceId, aMessageAccessor);
-      deserSharedData = sdata;
-      this.marker = aMarker;
-      this.acceptsDeltaCas = acceptsDeltaCas;
+      this(aCas, aCasReferenceId, aMessageAccessor, sdata, null, aMarker, acceptsDeltaCas);
     }
 
     protected CacheEntry(CAS aCas, String aCasReferenceId, MessageContext aMessageAccessor,
         ReuseInfo compress6ReuseInfo, Marker aMarker, boolean acceptsDeltaCas) {
+      this(aCas, aCasReferenceId, aMessageAccessor, null, compress6ReuseInfo, aMarker, acceptsDeltaCas);
+    }
+
+    protected CacheEntry(CAS aCas, String aCasReferenceId, MessageContext aMessageAccessor,
+        XmiSerializationSharedData sdata,
+        ReuseInfo compress6ReuseInfo, 
+        Marker aMarker, boolean acceptsDeltaCas) {
       this(aCas, aCasReferenceId, aMessageAccessor);
+      this.deserSharedData = sdata;
       this.compress6ReuseInfo = compress6ReuseInfo;
       this.marker = aMarker;
       this.acceptsDeltaCas = acceptsDeltaCas;

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaSerializer.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaSerializer.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaSerializer.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/UimaSerializer.java Fri Jun 14 23:00:41 2013
@@ -34,14 +34,19 @@ import javax.xml.parsers.FactoryConfigur
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.OutputKeys;
 
+import org.apache.uima.aae.InProcessCache.CacheEntry;
 import org.apache.uima.aae.monitor.statistics.AnalysisEnginePerformanceMetrics;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.Marker;
 import org.apache.uima.cas.SerialFormat;
 import org.apache.uima.cas.TypeSystem;
 import org.apache.uima.cas.impl.AllowPreexistingFS;
+import org.apache.uima.cas.impl.BinaryCasSerDes6;
+import org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo;
+import org.apache.uima.cas.impl.MarkerImpl;
 import org.apache.uima.cas.impl.OutOfTypeSystemData;
 import org.apache.uima.cas.impl.Serialization;
+import org.apache.uima.cas.impl.TypeSystemImpl;
 import org.apache.uima.cas.impl.XmiCasDeserializer;
 import org.apache.uima.cas.impl.XmiCasSerializer;
 import org.apache.uima.cas.impl.XmiSerializationSharedData;
@@ -254,6 +259,34 @@ public class UimaSerializer {
       }
     }
   }
+  
+  // used to return non-delta cas's (used if delta cas disallowed, for instance by having a CPP delegate)
+  public byte[] serializeCasToBinary6(CAS aCAS) throws Exception {
+    ByteArrayOutputStream fos = null;
+    fos = new ByteArrayOutputStream();
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(aCAS);
+    bcs.serialize(fos);
+    return fos.toByteArray();
+  }
+
+  // used to send CASes to remotes
+  public byte[] serializeCasToBinary6(CAS aCAS, CacheEntry entry, TypeSystemImpl tgtTs) throws Exception {
+    ByteArrayOutputStream fos = null;
+    fos = new ByteArrayOutputStream();
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(aCAS, tgtTs);
+    bcs.serialize(fos);
+    entry.setCompress6ReuseInfo(bcs.getReuseInfo());
+    return fos.toByteArray();
+  }
+  
+  public byte[] serializeCasToBinary6(CAS aCAS, Marker aMark, ReuseInfo reuseInfo) throws Exception {
+    ByteArrayOutputStream fos = null;
+    fos = new ByteArrayOutputStream();
+    BinaryCasSerDes6 bcs = new BinaryCasSerDes6(aCAS, (MarkerImpl) aMark, null, reuseInfo);
+    bcs.serialize(fos);
+    return fos.toByteArray();
+  }
+  
   @SuppressWarnings("unchecked")
   public static List<AnalysisEnginePerformanceMetrics> deserializePerformanceMetrics(String serializedComponentStats) {
     // check if we received components stats. Currently UIMA AS is not supporting per component

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/client/UimaAsynchronousEngine.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/client/UimaAsynchronousEngine.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/client/UimaAsynchronousEngine.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/client/UimaAsynchronousEngine.java Fri Jun 14 23:00:41 2013
@@ -172,9 +172,10 @@ public interface UimaAsynchronousEngine 
   public static final String UimaEeDebug = "-uimaEeDebug";
 
   /**
-   * Type of serialization to use when serializing CASes to remote Uima AS service. Valid serialization types are: XMI or
-   * BINARY or COMPRESSED_BINARY_6. If this setting is omitted, the Uima AS client uses XMI as a default. The application provides it to the Uima AS client
-   * in a Map which is an argument in {@link #initialize(Map)}
+   * Type of serialization to use when serializing CASes to remote Uima AS service. 
+   * Valid serialization types are the string "xmi" (any case) or other (taken to be binary).
+   * If this setting is omitted, the Uima AS client uses XMI as a default. 
+   * The application provides it to the Uima AS client in a Map which is an argument in {@link #initialize(Map)}
    */
   public static final String SERIALIZATION_STRATEGY = "SerializationStrategy";
   

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=1493276&r1=1493275&r2=1493276&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 23:00:41 2013
@@ -3129,6 +3129,10 @@ public class AggregateAnalysisEngineCont
       delegateStatMap.clear();
     }
 
+    InProcessCache cache = getInProcessCache();
+    if (cache != null) {
+      cache.destroy();
+    }
   }
 
   public void stop() {

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/Endpoint_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/Endpoint_impl.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/Endpoint_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/Endpoint_impl.java Fri Jun 14 23:00:41 2013
@@ -33,7 +33,7 @@ public class Endpoint_impl implements En
 
   private volatile Object destination = null;
 
-  private String endpoint;
+  private String endpoint;  // is the queue name (only)
 
   private String serverURI;
 

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java Fri Jun 14 23:00:41 2013
@@ -19,6 +19,7 @@
 
 package org.apache.uima.aae.handler.input;
 
+import java.io.ByteArrayInputStream;
 import java.util.concurrent.Semaphore;
 
 import org.apache.uima.UIMAFramework;
@@ -47,6 +48,8 @@ import org.apache.uima.aae.monitor.stati
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.Marker;
 import org.apache.uima.cas.SerialFormat;
+import org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo;
+import org.apache.uima.cas.impl.Serialization;
 import org.apache.uima.cas.impl.XmiSerializationSharedData;
 import org.apache.uima.util.Level;
 
@@ -197,8 +200,11 @@ public class ProcessRequestHandler_impl 
       t1 = getController().getCpuTime();
       SerialFormat serialFormat = endpoint.getSerialFormat();
       XmiSerializationSharedData deserSharedData = null;
+      ReuseInfo reuseInfo = null;
       
       UimaSerializer uimaSerializer = SerializerCache.lookupSerializerByThreadId();
+      byte[] binarySource = aMessageContext.getByteMessage();
+
       switch (serialFormat) {
       case XMI:
         // Fetch serialized CAS from the message
@@ -207,19 +213,20 @@ public class ProcessRequestHandler_impl 
         uimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, -1);
         break;
       case BINARY:
-      case COMPRESSED:
-      case COMPRESSED_FILTERED:
         // *************************************************************************
         // Register the CAS with a local cache
         // *************************************************************************
         // CacheEntry entry = getController().getInProcessCache().register(cas, aMessageContext,
         // deserSharedData, casReferenceId);
-        byte[] binarySource = aMessageContext.getByteMessage();
         // BINARY format may be COMPRESSED etc, so update it upon reading
         serialFormat = uimaSerializer.deserializeCasFromBinary(binarySource, cas);
         // BINARY format may be COMPRESSED etc, so update it upon reading
         endpoint.setSerialFormat(serialFormat);
         break;
+      case COMPRESSED_FILTERED:
+        ByteArrayInputStream bais = new ByteArrayInputStream(binarySource);
+        reuseInfo = Serialization.deserializeCAS(cas, bais, endpoint.getTypeSystemImpl(), null).getReuseInfo();
+        break;
       default:
         throw new RuntimeException("Never Happen");
       }
@@ -240,7 +247,7 @@ public class ProcessRequestHandler_impl 
       // *************************************************************************
       // CacheEntry entry = getController().getInProcessCache().register(cas, aMessageContext,
       // deserSharedData, casReferenceId);
-      entry = getController().getInProcessCache().register(cas, aMessageContext, deserSharedData,
+      entry = getController().getInProcessCache().register(cas, aMessageContext, deserSharedData, reuseInfo,
               casReferenceId, marker, acceptsDeltaCas);
       
       /*

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessResponseHandler.java Fri Jun 14 23:00:41 2013
@@ -19,10 +19,12 @@
 
 package org.apache.uima.aae.handler.input;
 
+import java.io.ByteArrayInputStream;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.uima.UIMAFramework;
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.aae.InProcessCache.CacheEntry;
 import org.apache.uima.aae.SerializerCache;
 import org.apache.uima.aae.UIMAEE_Constants;
@@ -49,7 +51,13 @@ import org.apache.uima.aae.monitor.stati
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.SerialFormat;
 import org.apache.uima.cas.impl.AllowPreexistingFS;
+import org.apache.uima.cas.impl.BinaryCasSerDes6;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.MarkerImpl;
+import org.apache.uima.cas.impl.Serialization;
+import org.apache.uima.cas.impl.TypeSystemImpl;
 import org.apache.uima.cas.impl.XmiSerializationSharedData;
+import org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo;
 import org.apache.uima.util.Level;
 
 public class ProcessResponseHandler extends HandlerBase {
@@ -145,6 +153,7 @@ public class ProcessResponseHandler exte
     String casReferenceId = null;
     Endpoint endpointWithTimer = null;
     try {
+      final int payload = aMessageContext.getMessageIntProperty(AsynchAEMessage.Payload);
       casReferenceId = aMessageContext.getMessageStringProperty(AsynchAEMessage.CasReference);
       endpointWithTimer = lookupEndpoint(aMessageContext.getEndpoint().getEndpoint(),
               casReferenceId);
@@ -255,7 +264,8 @@ public class ProcessResponseHandler exte
       if ( !aMessageContext.getMessageBooleanProperty(AsynchAEMessage.SentDeltaCas))  {
     	cacheEntry.setAcceptsDeltaCas(false);
       }
-     
+
+      SerialFormat serialFormat = endpointWithTimer.getSerialFormat();
       // check if the CAS is part of the Parallel Step
       if (totalNumberOfParallelDelegatesProcessingCas > 1) {
         // Synchronized because replies are merged into the same CAS.
@@ -268,11 +278,21 @@ public class ProcessResponseHandler exte
           }
           // If a delta CAS, merge it while checking that no pre-existing FSs are modified.
           if (aMessageContext.getMessageBooleanProperty(AsynchAEMessage.SentDeltaCas)) {
-            int highWaterMark = cacheEntry.getHighWaterMark();
-            deserialize(xmi, cas, casReferenceId, highWaterMark, AllowPreexistingFS.disallow);
+            switch (serialFormat) {
+            case XMI:
+              int highWaterMark = cacheEntry.getHighWaterMark();
+              deserialize(xmi, cas, casReferenceId, highWaterMark, AllowPreexistingFS.disallow);
+              break;
+            case COMPRESSED_FILTERED:
+              deserialize(aMessageContext.getByteMessage(), cas, cacheEntry, endpointWithTimer.getTypeSystemImpl(), AllowPreexistingFS.disallow);
+              break;
+            default:
+              throw new UIMARuntimeException(new Exception("Internal error"));
+            }
           } else {
             // If not a delta CAS (old service), take all of first reply, and merge in the new
             // entries in the later replies. Ignoring pre-existing FS for 2.2.2 compatibility
+            // Note: can't be a compressed binary - that would have returned a delta
             if (casStateEntry.howManyDelegatesResponded() == 0) {
               deserialize(xmi, cas, casReferenceId);
             } else { // process secondary reply from a parallel step
@@ -283,14 +303,15 @@ public class ProcessResponseHandler exte
           casStateEntry.incrementHowManyDelegatesResponded();
         }
       } else { // Processing a reply from a non-parallel delegate (binary or delta xmi or xmi)
-        SerialFormat serialFormat = endpointWithTimer.getSerialFormat();
+        byte[] binaryData = aMessageContext.getByteMessage();
+        ByteArrayInputStream istream = new ByteArrayInputStream(binaryData);
         switch (serialFormat) {
         case BINARY:
-        case COMPRESSED:
+          ((CASImpl)cas).reinit(istream);
+          break;
         case COMPRESSED_FILTERED:
-          UimaSerializer uimaSerializer = SerializerCache.lookupSerializerByThreadId();
-          byte[] binaryData = aMessageContext.getByteMessage();
-          uimaSerializer.deserializeCasFromBinary(binaryData, cas);
+          BinaryCasSerDes6 bcs = new BinaryCasSerDes6(cas, (MarkerImpl) cacheEntry.getMarker(), endpointWithTimer.getTypeSystemImpl(), cacheEntry.getCompress6ReuseInfo());          
+          bcs.deserialize(istream, AllowPreexistingFS.allow);
           break;
         case XMI:
           if (aMessageContext.getMessageBooleanProperty(AsynchAEMessage.SentDeltaCas)) {
@@ -301,7 +322,7 @@ public class ProcessResponseHandler exte
           }
           break;
         default:
-          throw new RuntimeException("Never happen");
+          throw new UIMARuntimeException(new Exception("Internal error"));
         }
       }
       long timeToDeserializeCAS = getController().getCpuTime() - t1;
@@ -386,6 +407,14 @@ public class ProcessResponseHandler exte
     UimaSerializer uimaSerializer = SerializerCache.lookupSerializerByThreadId();
     uimaSerializer.deserializeCasFromXmi(xmi, cas, deserSharedData, true, highWaterMark, allow);
   }
+  
+  private void deserialize(byte[] bytes, CAS cas, CacheEntry cacheEntry, TypeSystemImpl remoteTs,
+          AllowPreexistingFS allow) throws Exception {
+    ByteArrayInputStream istream = new ByteArrayInputStream(bytes);
+    ReuseInfo reuseInfo = cacheEntry.getCompress6ReuseInfo();
+
+    Serialization.deserializeCAS(cas, istream, remoteTs, reuseInfo, allow);
+  }
 
   private void deserialize(String xmi, CAS cas, String casReferenceId) throws Exception {
     CacheEntry entry = getController().getInProcessCache().getCacheEntryForCAS(casReferenceId);

Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/message/AsynchAEMessage.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/message/AsynchAEMessage.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/message/AsynchAEMessage.java (original)
+++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/message/AsynchAEMessage.java Fri Jun 14 23:00:41 2013
@@ -125,12 +125,26 @@ public interface AsynchAEMessage {
   public static final String SentDeltaCas = "SentDeltaCas";
 
   public static final String SERIALIZATION = "Serialization";
+  
+  /*
+   * Serialization codes are done as a bit position, to allow 
+   * future expansion - 
+   *   Implementations will be able to turn on bits to indicate what they support
+   *   Code:
+   *   0x 01 bb bb bb
+   *   where the bb bb bb represent 24 bits of alternatives being supported
+   *   
+   *   XMI is always supported, and has a code of 01 00 00 00
+   *     or for old services, 4000 (but wasn't used in old code)
+   *     (Binary was 4001 but that wasn't used in old code)
+   *     
+   */
 
-  public static final int XMI_SERIALIZATION = 4000;  
+  public static final int XMI_SERIALIZATION = 0x01000000;  
 
-  public static final int BINARY_SERIALIZATION = 4001; // supports uncompressed binary serialization, but not compressed binary serialization
+  public static final int BINARY_SERIALIZATION = 0x01000001; // supports uncompressed binary serialization, identical ts required, but not compressed binary serialization
   
-  public static final int BINARY_COMPRESSED_FILTERED_SERIALIZATION = 4002;  // supports use of BinaryCasSerDes6
+  public static final int BINARY_COMPRESSED_FILTERED_SERIALIZATION = 0x01000002;  // supports use of BinaryCasSerDes6
 
   public static final String ErrorCause = "Cause";
 

Modified: uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java?rev=1493276&r1=1493275&r2=1493276&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngineCommon_impl.java Fri Jun 14 23:00:41 2013
@@ -20,6 +20,7 @@
 package org.apache.uima.adapter.jms.client;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
@@ -48,6 +49,7 @@ import javax.jms.TextMessage;
 
 import org.apache.activemq.ActiveMQConnection;
 import org.apache.uima.UIMAFramework;
+import org.apache.uima.UIMARuntimeException;
 import org.apache.uima.UIMA_IllegalStateException;
 import org.apache.uima.aae.AsynchAECasManager;
 import org.apache.uima.aae.UIDGenerator;
@@ -81,8 +83,12 @@ import org.apache.uima.adapter.jms.messa
 import org.apache.uima.cas.CAS;
 import org.apache.uima.cas.SerialFormat;
 import org.apache.uima.cas.impl.AllowPreexistingFS;
+import org.apache.uima.cas.impl.BinaryCasSerDes6;
+import org.apache.uima.cas.impl.CASImpl;
+import org.apache.uima.cas.impl.Serialization;
 import org.apache.uima.cas.impl.TypeSystemImpl;
 import org.apache.uima.cas.impl.XmiSerializationSharedData;
+import org.apache.uima.cas.impl.BinaryCasSerDes6.ReuseInfo;
 import org.apache.uima.collection.CollectionReader;
 import org.apache.uima.collection.EntityProcessStatus;
 import org.apache.uima.jms.error.handler.BrokerConnectionException;
@@ -166,7 +172,7 @@ public abstract class BaseUIMAAsynchrono
 
   protected SerialFormat serialFormat = SerialFormat.XMI;
   
-  protected TypeSystemImpl typeSystemImpl; // of the remote service, for filtered binary compression
+  protected TypeSystemImpl remoteTypeSystem; // of the remote service, for filtered binary compression
 
   protected UimaASClientInfoMBean clientSideJmxStats = new UimaASClientInfo();
 
@@ -273,13 +279,14 @@ public abstract class BaseUIMAAsynchrono
     serialFormat = aSerialFormat;
   }
   
-  public TypeSystemImpl getTypeSystemImpl() {
-    return typeSystemImpl;
+  public TypeSystemImpl getRemoteTypeSystem() {
+    return remoteTypeSystem;
   }
 
-  protected void setTypeSystemImpl(TypeSystemImpl typeSystemImpl) {
-    this.typeSystemImpl = typeSystemImpl;
+  protected void setRemoteTypeSystem(TypeSystemImpl remoteTypeSystem) {
+    this.remoteTypeSystem = remoteTypeSystem;
   }
+  
   /**
    * Serializes a given CAS.
    * 
@@ -840,24 +847,36 @@ public abstract class BaseUIMAAsynchrono
         clientCache.put(casReferenceId, requestToCache);
         PendingMessage msg = new PendingMessage(AsynchAEMessage.Process);
         long t1 = System.nanoTime();
-        if (serialFormat == SerialFormat.XMI) {
+        switch (serialFormat) {
+        case XMI:
           XmiSerializationSharedData serSharedData = new XmiSerializationSharedData();
           String serializedCAS = serializeCAS(aCAS, serSharedData);
           msg.put(AsynchAEMessage.CAS, serializedCAS);
-          if (remoteService) {
-            requestToCache.setCAS(aCAS);
+          if (remoteService) {  // always true 5/2013
             // Store the serialized CAS in case the timeout occurs and need to send the
             // the offending CAS to listeners for reporting
             requestToCache.setCAS(serializedCAS);
             requestToCache.setXmiSerializationSharedData(serSharedData);
           }
-        } else {
-          byte[] serializedCAS = uimaSerializer.serializeCasToBinary(aCAS);
-          msg.put(AsynchAEMessage.CAS, serializedCAS);
-          if (remoteService) {
-            requestToCache.setCAS(aCAS);
-          }
+          break;
+        case BINARY:
+          byte[] serializedBinaryCAS = uimaSerializer.serializeCasToBinary(aCAS);
+          msg.put(AsynchAEMessage.CAS, serializedBinaryCAS);
+          break;
+        case COMPRESSED_FILTERED:
+          // can't use uimaserializer directly - project doesn't have ref to this one
+          // for storing the reuse info
+          BinaryCasSerDes6 bcs = new BinaryCasSerDes6(aCAS, this.getRemoteTypeSystem());
+          ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+          bcs.serialize(baos);
+          requestToCache.setCompress6ReuseInfo(bcs.getReuseInfo());           
+          msg.put(AsynchAEMessage.CAS, baos.toByteArray());
+          break;
+        default:
+          throw new UIMARuntimeException(new Exception("Internal Error"));    
         }
+        
+        requestToCache.setCAS(aCAS);
 
         requestToCache.setSerializationTime(System.nanoTime() - t1);
         msg.put(AsynchAEMessage.CasReference, casReferenceId);
@@ -1131,7 +1150,7 @@ public abstract class BaseUIMAAsynchrono
                 .parseResourceMetaData(in1);
         // if remote delegate, save type system 
         if (!brokerURI.startsWith("vm:")) { // test if remote
-          setTypeSystemImpl(AggregateAnalysisEngineController_impl.getTypeSystemImpl(resourceMetadata));
+          setRemoteTypeSystem(AggregateAnalysisEngineController_impl.getTypeSystemImpl(resourceMetadata));
         }
         casMultiplierDelegate = resourceMetadata.getOperationalProperties().getOutputsNewCASes();
         if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.FINEST)) {
@@ -1868,12 +1887,27 @@ public abstract class BaseUIMAAsynchrono
     return deserialize(aSerializedCAS, cas);
   }
 
+  /**
+   * handle both ordinary binary and compressed6 binary
+   * @param aSerializedCAS
+   * @param cachedRequest
+   * @return
+   * @throws Exception
+   */
   protected CAS deserializeCAS(byte[] aSerializedCAS, ClientRequest cachedRequest) throws Exception {
     CAS cas = cachedRequest.getCAS();
-    uimaSerializer.deserializeCasFromBinary(aSerializedCAS, cas);
+    ReuseInfo reuseInfo = cachedRequest.getCompress6ReuseInfo();
+    ByteArrayInputStream bais = new ByteArrayInputStream(aSerializedCAS);
+    if (reuseInfo != null) {
+      Serialization.deserializeCAS(cas, bais, null, reuseInfo);
+    } else {
+      ((CASImpl)cas).reinit(bais);
+    }
+//    uimaSerializer.deserializeCasFromBinary(aSerializedCAS, cas);
     return cas;
   }
 
+  // never called 5/2013 ??
   protected CAS deserializeCAS(byte[] aSerializedCAS, CAS aCas) throws Exception {
     uimaSerializer.deserializeCasFromBinary(aSerializedCAS, aCas);
     return aCas;
@@ -2351,6 +2385,10 @@ public abstract class BaseUIMAAsynchrono
     return null;
   }
 
+  /**
+   * has some cache values for CAS, similar to class CacheEntry 
+   *
+   */
   public class ClientRequest {
     private Timer timer = null;
 
@@ -2400,6 +2438,8 @@ public abstract class BaseUIMAAsynchrono
     private long processErrorCount;
 
     private XmiSerializationSharedData sharedData;
+    
+    private ReuseInfo compress6ReuseInfo;
 
     private byte[] binaryCas = null;
 
@@ -2740,6 +2780,14 @@ public abstract class BaseUIMAAsynchrono
     public void setXmiSerializationSharedData(XmiSerializationSharedData data) {
       this.sharedData = data;
     }
+    
+    public ReuseInfo getCompress6ReuseInfo() {
+      return compress6ReuseInfo;
+    }
+    
+    public void setCompress6ReuseInfo(ReuseInfo compress6ReuseInfo) {
+      this.compress6ReuseInfo = compress6ReuseInfo;
+    }
   }
 
   protected static class ThreadMonitor {