activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r411727 - in /incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool: JmsClientSupport.java JmsClientSystemSupport.java JmsConsumerSystem.java JmsProducerSystem.java
Date Mon, 05 Jun 2006 10:06:36 GMT
Author: aco
Date: Mon Jun  5 03:06:34 2006
New Revision: 411727

URL: http://svn.apache.org/viewvc?rev=411727&view=rev
Log:
- Added support for distribution of destinations between clients
- Modify the support for composite destinations

Modified:
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
    incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java?rev=411727&r1=411726&r2=411727&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java
Mon Jun  5 03:06:34 2006
@@ -45,6 +45,7 @@
     protected String  sessAckMode    = SESSION_AUTO_ACKNOWLEDGE;
     protected String  destName       = "TEST.FOO";
     protected int     destCount      = 1;
+    protected int     destIndex      = 0;
     protected boolean destComposite  = false;
 
     public ConnectionFactory createConnectionFactory() throws JMSException {
@@ -78,14 +79,15 @@
     }
 
     public Destination[] createDestination() throws JMSException {
-        Destination[] dest = new Destination[getDestCount()];
-        for (int i=0; i<getDestCount(); i++) {
-            dest[i] = createDestination(getDestName() + "." + i);
-        }
 
         if (isDestComposite()) {
-            return new Destination[] {createDestination(getDestName() + ".>")};
+            return new Destination[] {createCompositeDestination(getDestName(), getDestCount())};
         } else {
+            Destination[] dest = new Destination[getDestCount()];
+            for (int i=0; i<getDestCount(); i++) {
+                dest[i] = createDestination(getDestName() + "." + (getDestIndex() + i));
+            }
+
             return dest;
         }
     }
@@ -100,6 +102,28 @@
         }
     }
 
+    public Destination createCompositeDestination(String name, int count) throws JMSException
{
+        String compDestName = "";
+        String simpleName;
+
+        if (name.startsWith("queue://")) {
+            simpleName = name.substring("queue://".length());
+        } else if (name.startsWith("topic://")) {
+            simpleName = name.substring("topic://".length());
+        } else {
+            simpleName = name;
+        }
+
+        int i;
+        compDestName = name + ".0,"; // First destination
+        for (i=1; i<count-1; i++) {
+            compDestName += (simpleName + "." + i +",");
+        }
+        compDestName += (simpleName + "." + i); // Last destination (minus the comma)
+
+        return createDestination(compDestName);
+    }
+
     public String getSpiClass() {
         return spiClass;
     }
@@ -138,6 +162,14 @@
 
     public void setDestCount(int destCount) {
         this.destCount = destCount;
+    }
+
+    public int getDestIndex() {
+        return destIndex;
+    }
+
+    public void setDestIndex(int destIndex) {
+        this.destIndex = destIndex;
     }
 
     public boolean isDestComposite() {

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java?rev=411727&r1=411726&r2=411727&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSystemSupport.java
Mon Jun  5 03:06:34 2006
@@ -26,6 +26,12 @@
     private static final Log log = LogFactory.getLog(JmsClientSystemSupport.class);
 
     public static final String PREFIX_CONFIG_SYSTEM_TEST = "sysTest.";
+    public static final String DEST_DISTRO_ALL    = "all";    // Each client will send/receive
to all destination;
+    public static final String DEST_DISTRO_EQUAL  = "equal";  // Equally divide the number
of destinations to the number of clients
+    public static final String DEST_DISTRO_DIVIDE = "divide"; // Divide the destination among
the clients, even if some have more destination than others
+
+    protected static final String KEY_CLIENT_DEST_COUNT = "client.destCount";
+    protected static final String KEY_CLIENT_DEST_INDEX = "client.destIndex";
 
     protected Properties sysTestSettings   = new Properties();
     protected Properties samplerSettings   = new Properties();
@@ -34,17 +40,20 @@
     protected PerfMeasurementTool performanceSampler;
 
     protected int numClients = 1;
+    protected int totalDests = 1;
+    protected String destDistro = DEST_DISTRO_ALL;
 
     public void runSystemTest() {
-        // Create a new copy of the settings to ensure immutability
-        final Properties clientSettings = getJmsClientSettings();
-
         // Create performance sampler
         performanceSampler = new PerfMeasurementTool();
         performanceSampler.setSamplerSettings(samplerSettings);
 
         clientThreadGroup = new ThreadGroup(getThreadGroupName());
-        for (int i=0; i<numClients; i++) {
+        for (int i=0; i<getNumClients(); i++) {
+            final Properties clientSettings = new Properties();
+            clientSettings.putAll(getJmsClientSettings());
+            distributeDestinations(getDestDistro(), i, getNumClients(), getTotalDests(),
clientSettings);
+
             final String clientName = getClientName() + i;
             Thread t = new Thread(clientThreadGroup, new Runnable() {
                 public void run() {
@@ -58,6 +67,51 @@
         performanceSampler.startSampler();
     }
 
+    protected void distributeDestinations(String distroType, int clientIndex, int numClients,
int numDests, Properties clientSettings) {
+        if (distroType.equalsIgnoreCase(DEST_DISTRO_ALL)) {
+            clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, String.valueOf(numDests));
+            clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, "0");
+        } else if (distroType.equalsIgnoreCase(DEST_DISTRO_EQUAL)) {
+            int destPerClient = (numDests / numClients);
+            // There are equal or more destinations per client
+            if (destPerClient > 0) {
+                clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, String.valueOf(destPerClient));
+                clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, String.valueOf(destPerClient
* clientIndex));
+
+            // If there are more clients than destinations, share destinations per client
+            } else {
+                clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, "1"); // At most one destination
per client
+                clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, String.valueOf(clientIndex
% numDests));
+            }
+        } else if (distroType.equalsIgnoreCase(DEST_DISTRO_DIVIDE)) {
+            int destPerClient = (numDests / numClients);
+            // There are equal or more destinations per client
+            if (destPerClient > 0) {
+                int remain = numDests % numClients;
+                int nextIndex;
+                if (clientIndex < remain) {
+                    destPerClient++;
+                    nextIndex = clientIndex * destPerClient;
+                } else {
+                    nextIndex = (clientIndex * destPerClient) + remain;
+                }
+
+                clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, String.valueOf(destPerClient));
+                clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, String.valueOf(nextIndex));
+
+            // If there are more clients than destinations, share destinations per client
+            } else {
+                clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, "1"); // At most one destination
per client
+                clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, String.valueOf(clientIndex
% numDests));
+            }
+
+        // Send to all for unknown behavior
+        } else {
+            clientSettings.setProperty(KEY_CLIENT_DEST_COUNT, String.valueOf(numDests));
+            clientSettings.setProperty(KEY_CLIENT_DEST_INDEX, "0");
+        }
+    }
+
     public abstract void runJmsClient(String clientName, Properties clientSettings);
 
     public String getClientName() {
@@ -138,5 +192,21 @@
 
     public void setNumClients(int numClients) {
         this.numClients = numClients;
+    }
+
+    public String getDestDistro() {
+        return destDistro;
+    }
+
+    public void setDestDistro(String destDistro) {
+        this.destDistro = destDistro;
+    }
+
+    public int getTotalDests() {
+        return totalDests;
+    }
+
+    public void setTotalDests(int totalDests) {
+        this.totalDests = totalDests;
     }
 }

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java?rev=411727&r1=411726&r2=411727&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java
Mon Jun  5 03:06:34 2006
@@ -52,7 +52,7 @@
     }
 
     public static void main(String[] args) throws JMSException {
-        String[] options = new String[22];
+        String[] options = new String[24];
         options[0] = "-Dsampler.duration=60000";     // 1 min
         options[1] = "-Dsampler.interval=5000";      // 5 secs
         options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
@@ -79,6 +79,8 @@
         options[20] = "-Dfactory.useRetroactive=false";
 
         options[21] = "-DsysTest.numClients=5";
+        options[22] = "-DsysTest.totalDests=5";
+        options[23] = "-DsysTest.destDistro=all";
 
         args = options;
 

Modified: incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java?rev=411727&r1=411726&r2=411727&view=diff
==============================================================================
--- incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
(original)
+++ incubator/activemq/trunk/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java
Mon Jun  5 03:06:34 2006
@@ -51,8 +51,8 @@
         return "JMS Producer Thread Group";
     }
 
-    public static void main(String[] args) throws JMSException {
-        String[] options = new String[17];
+    public static void main(String[] args) {
+        String[] options = new String[19];
         options[0] = "-Dsampler.duration=60000";     // 1 min
         options[1] = "-Dsampler.interval=5000";      // 5 secs
         options[2] = "-Dsampler.rampUpTime=10000";   // 10 secs
@@ -74,6 +74,8 @@
         options[15] = "-Dfactory.asyncSend=true";
 
         options[16] = "-DsysTest.numClients=5";
+        options[17] = "-DsysTest.totalDests=5";
+        options[18] = "-DsysTest.destDistro=all";
 
         args = options;
 



Mime
View raw message