You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/02/19 15:37:23 UTC

svn commit: r745885 - in /activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow: MockBrokerTest.java RemoteProducer.java

Author: chirino
Date: Thu Feb 19 14:37:23 2009
New Revision: 745885

URL: http://svn.apache.org/viewvc?rev=745885&view=rev
Log:
Made payload generation more efficent.

Modified:
    activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/MockBrokerTest.java
    activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/RemoteProducer.java

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=745885&r1=745884&r2=745885&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 Thu Feb 19 14:37:23 2009
@@ -35,7 +35,7 @@
 
 public class MockBrokerTest extends TestCase {
 
-    protected static final int PERFORMANCE_SAMPLES = 30000;
+    protected static final int PERFORMANCE_SAMPLES = 3;
 
     protected static final int IO_WORK_AMOUNT = 0;
     protected static final int FANIN_COUNT = 10;
@@ -51,7 +51,7 @@
     protected boolean ptp = false;
 
     // Set to use tcp IO
-    protected boolean tcp = true;
+    protected boolean tcp = false;
     // set to force marshalling even in the NON tcp case.
     protected boolean forceMarshalling = false;
     

Modified: activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/RemoteProducer.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/RemoteProducer.java?rev=745885&r1=745884&r2=745885&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/RemoteProducer.java (original)
+++ activemq/sandbox/activemq-flow/src/test/java/org/apache/activemq/flow/RemoteProducer.java Thu Feb 19 14:37:23 2009
@@ -14,7 +14,6 @@
 
 public class RemoteProducer extends RemoteConnection implements Dispatchable, FlowUnblockListener<Message>{
 
-    private static final int FILLER_SIZE = 100;
 
     private final MetricCounter rate = new MetricCounter();
 
@@ -30,14 +29,17 @@
     private DispatchContext dispatchContext;
 
     private String filler;
+    private int payloadSize = 20;
     
     public void start() throws Exception {
         
-        StringBuilder sb = new StringBuilder(FILLER_SIZE);
-        for( int i=0; i < FILLER_SIZE; ++i) {
-            sb.append('a'+(i%26));
+        if( payloadSize>0 ) {
+            StringBuilder sb = new StringBuilder(payloadSize);
+            for( int i=0; i < payloadSize; ++i) {
+                sb.append((char)('a'+(i%26)));
+            }
+            filler = sb.toString();
         }
-        filler = sb.toString();
         
         rate.name("Producer " + name + " Rate");
         totalProducerRate.add(rate);
@@ -104,7 +106,22 @@
 	}
 
     private String createPayload() {
-        return name + ++counter+filler;
+        if( payloadSize>=0 ) {
+            StringBuilder sb = new StringBuilder(payloadSize);
+            sb.append(name);
+            sb.append(':');
+            sb.append(++counter);
+            sb.append(':');
+            int length = sb.length();
+            if( length <= payloadSize ) {
+                sb.append(filler.subSequence(0, payloadSize-length));
+                return sb.toString();
+            } else {
+               return sb.substring(0, payloadSize); 
+            }
+        } else {
+            return name+":"+(++counter);
+        }
     }
 	
 	public void setName(String name) {
@@ -170,5 +187,13 @@
     public MetricCounter getRate() {
         return rate;
     }
+
+    public int getPayloadSize() {
+        return payloadSize;
+    }
+
+    public void setPayloadSize(int messageSize) {
+        this.payloadSize = messageSize;
+    }
 }