Author: chirino
Date: Fri Feb 20 03:58:14 2009
New Revision: 746131

URL: http://svn.apache.org/viewvc?rev=746131&view=rev
Log:
Switch to using AsciiBuffers instead of strings wherever possible to avoid UTF8 
marshalling.. also someimes you can avoid demarshalling alltogether.


Modified:
    activemq/sandbox/activemq-flow/src/main/proto/test.proto
    
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Message.java
    
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java
    
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockQueue.java
    
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Router.java

Modified: activemq/sandbox/activemq-flow/src/main/proto/test.proto
URL: 
http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/main/proto/test.proto?rev=746131&r1=746130&r2=746131&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/src/main/proto/test.proto (original)
+++ activemq/sandbox/activemq-flow/src/main/proto/test.proto Fri Feb 20 
03:58:14 2009
@@ -21,12 +21,12 @@
 option deferred_decode = true;
 
 message Destination {
-  optional string name = 1;
+  optional bytes name = 1 [java_override_type = "AsciiBuffer"];
   optional bool ptp = 3;
 }
 
 message Message {
-  optional string msg = 1;
+  optional bytes msg = 1 [java_override_type = "UTF8Buffer"];
   optional Destination dest=2;
   optional int32 hopCount=3;
   optional int64  msgId=4;

Modified: 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Message.java
URL: 
http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Message.java?rev=746131&r1=746130&r2=746131&view=diff
==============================================================================
--- 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Message.java
 (original)
+++ 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Message.java
 Fri Feb 20 03:58:14 2009
@@ -21,6 +21,7 @@
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.Commands.Message.MessageBean;
 import org.apache.activemq.flow.Commands.Message.MessageBuffer;
+import org.apache.activemq.protobuf.UTF8Buffer;
 import org.apache.activemq.queue.Mapper;
 
 public class Message implements Serializable {
@@ -49,7 +50,7 @@
         MessageBean message = new MessageBean();
         message.setMsgId(msgId);
         message.setProducerId(producerId);
-        message.setMsg(msg);
+        message.setMsg(new UTF8Buffer(msg));
         message.setDest(dest);
         message.setPriority(priority);
         this.message = message.freeze();

Modified: 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java
URL: 
http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java?rev=746131&r1=746130&r2=746131&view=diff
==============================================================================
--- 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java
 (original)
+++ 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java
 Fri Feb 20 03:58:14 2009
@@ -30,6 +30,7 @@
 import org.apache.activemq.flow.Commands.Destination.DestinationBuffer;
 import org.apache.activemq.metric.MetricAggregator;
 import org.apache.activemq.metric.Period;
+import org.apache.activemq.protobuf.AsciiBuffer;
 import org.apache.activemq.queue.Mapper;
 import org.apache.activemq.transport.nio.SelectorManager;
 
@@ -356,7 +357,7 @@
 
         for (int i = 0; i < destCount; i++) {
             DestinationBean bean = new DestinationBean();
-            bean.setName("dest" + (i + 1));
+            bean.setName(new AsciiBuffer("dest" + (i + 1)));
             bean.setPtp(ptp);
             dests[i] = bean.freeze();
             if (ptp) {

Modified: 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockQueue.java
URL: 
http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockQueue.java?rev=746131&r1=746130&r2=746131&view=diff
==============================================================================
--- 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockQueue.java
 (original)
+++ 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockQueue.java
 Fri Feb 20 03:58:14 2009
@@ -34,7 +34,7 @@
                 }
             };
             queue.setPartitionMapper(partitionMapper);
-            queue.setResourceName(destination.getName());
+            queue.setResourceName(destination.getName().toString());
             return queue;
         } else {
             return createSharedFlowQueue();
@@ -45,14 +45,14 @@
         if (MockBrokerTest.PRIORITY_LEVELS > 1) {
             PrioritySizeLimiter<Message> limiter = new 
PrioritySizeLimiter<Message>(100, 1, MockBrokerTest.PRIORITY_LEVELS);
             limiter.setPriorityMapper(Message.PRIORITY_MAPPER);
-            SharedPriorityQueue<Long, Message> queue = new 
SharedPriorityQueue<Long, Message>(destination.getName(), limiter);
+            SharedPriorityQueue<Long, Message> queue = new 
SharedPriorityQueue<Long, Message>(destination.getName().toString(), limiter);
             queue.setKeyMapper(keyExtractor);
             queue.setAutoRelease(true);
             queue.setDispatcher(broker.getDispatcher());
             return queue;
         } else {
             SizeLimiter<Message> limiter = new SizeLimiter<Message>(100, 1);
-            SharedQueue<Long, Message> queue = new SharedQueue<Long, 
Message>(destination.getName(), limiter);
+            SharedQueue<Long, Message> queue = new SharedQueue<Long, 
Message>(destination.getName().toString(), limiter);
             queue.setKeyMapper(keyExtractor);
             queue.setAutoRelease(true);
             queue.setDispatcher(broker.getDispatcher());

Modified: 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Router.java
URL: 
http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Router.java?rev=746131&r1=746130&r2=746131&view=diff
==============================================================================
--- 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Router.java
 (original)
+++ 
activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/Router.java
 Fri Feb 20 03:58:14 2009
@@ -9,12 +9,13 @@
 
 import org.apache.activemq.flow.Commands.Destination;
 import org.apache.activemq.flow.MockBroker.DeliveryTarget;
+import org.apache.activemq.protobuf.AsciiBuffer;
 
 public class Router {
-    final HashMap<String, Collection<DeliveryTarget>> lookupTable = new 
HashMap<String, Collection<DeliveryTarget>>();
+    final HashMap<AsciiBuffer, Collection<DeliveryTarget>> lookupTable = new 
HashMap<AsciiBuffer, Collection<DeliveryTarget>>();
 
     final synchronized void bind(DeliveryTarget dt, Destination destination) {
-        String key = destination.getName();
+        AsciiBuffer key = destination.getName();
         Collection<DeliveryTarget> targets = lookupTable.get(key);
         if (targets == null) {
             targets = new ArrayList<DeliveryTarget>();
@@ -24,7 +25,7 @@
     }
 
     final void route(ISourceController<Message> source, Message msg) {
-        String key = msg.getDestination().getName();
+        AsciiBuffer key = msg.getDestination().getName();
         Collection<DeliveryTarget> targets = lookupTable.get(key);
         if( targets == null ) 
             return;


Reply via email to