From 61fcd4cfd1a843d7ff5fd23d60351d7fd1c46c2b Mon Sep 17 00:00:00 2001 From: "Adrian T. Co" Date: Mon, 5 Jun 2006 10:06:34 +0000 Subject: [PATCH] - Added support for distribution of destinations between clients - Modify the support for composite destinations git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@411727 13f79535-47bb-0310-9956-ffa450edef68 --- .../activemq/tool/JmsClientSupport.java | 42 ++++++++-- .../activemq/tool/JmsClientSystemSupport.java | 78 ++++++++++++++++++- .../activemq/tool/JmsConsumerSystem.java | 4 +- .../activemq/tool/JmsProducerSystem.java | 6 +- 4 files changed, 118 insertions(+), 12 deletions(-) diff --git a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java index 914fa0282b..4962620ba1 100644 --- a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java +++ b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsClientSupport.java @@ -45,6 +45,7 @@ public class JmsClientSupport extends JmsFactorySupport { 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 class JmsClientSupport extends JmsFactorySupport { } public Destination[] createDestination() throws JMSException { - Destination[] dest = new Destination[getDestCount()]; - for (int i=0; i")}; + return new Destination[] {createCompositeDestination(getDestName(), getDestCount())}; } else { + Destination[] dest = new Destination[getDestCount()]; + for (int i=0; i 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() { @@ -139,4 +193,20 @@ public abstract class JmsClientSystemSupport { 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; + } } diff --git a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java index 7b087be43f..4c598b1767 100644 --- a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java +++ b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsConsumerSystem.java @@ -52,7 +52,7 @@ public class JmsConsumerSystem extends JmsClientSystemSupport { } 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 @@ public class JmsConsumerSystem extends JmsClientSystemSupport { options[20] = "-Dfactory.useRetroactive=false"; options[21] = "-DsysTest.numClients=5"; + options[22] = "-DsysTest.totalDests=5"; + options[23] = "-DsysTest.destDistro=all"; args = options; diff --git a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java index e716637821..8662bbfaf8 100644 --- a/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java +++ b/tooling/maven-activemq-perf-plugin/src/main/java/org/apache/activemq/tool/JmsProducerSystem.java @@ -51,8 +51,8 @@ public class JmsProducerSystem extends JmsClientSystemSupport { 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 @@ public class JmsProducerSystem extends JmsClientSystemSupport { options[15] = "-Dfactory.asyncSend=true"; options[16] = "-DsysTest.numClients=5"; + options[17] = "-DsysTest.totalDests=5"; + options[18] = "-DsysTest.destDistro=all"; args = options;