From 27b98a2514475ba34150ca01ae70703fca18f9a3 Mon Sep 17 00:00:00 2001 From: Clebert Suconic Date: Fri, 14 Aug 2015 14:49:57 -0400 Subject: [PATCH] performance tests on openwire --- .../artemis/cli/commands/etc/broker.xml | 3 +- .../protocol/openwire/OpenWireConnection.java | 3 +- examples/features/perf/perf/pom.xml | 141 ++++++++++-------- .../artemis/jms/example/PerfBase.java | 38 +++-- .../artemis/jms/example/PerfParams.java | 47 +++--- .../resources/activemq/server0/broker.xml | 46 ------ .../perf/src/main/resources/jndi.properties | 20 --- .../perf/src/main/resources/perf.properties | 9 +- examples/pom.xml | 2 + 9 files changed, 136 insertions(+), 173 deletions(-) delete mode 100644 examples/features/perf/perf/src/main/resources/activemq/server0/broker.xml delete mode 100644 examples/features/perf/perf/src/main/resources/jndi.properties diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml index 75cd6ee17e..35b77257a6 100644 --- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml +++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/etc/broker.xml @@ -46,7 +46,8 @@ ${journal-buffer.settings} ${connector-config.settings} - tcp://${host}:${default.port} + + tcp://${host}:${default.port}?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576 tcp://${host}:${amqp.port}?protocols=AMQP diff --git a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java index ada2a700ac..fc1438201c 100644 --- a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java +++ b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java @@ -194,9 +194,8 @@ public class OpenWireConnection implements RemotingConnection, CommandVisitor { @Override public void bufferReceived(Object connectionID, ActiveMQBuffer buffer) { try { - Object object = wireFormat.unmarshal(buffer); + Command command = (Command) wireFormat.unmarshal(buffer); - Command command = (Command) object; boolean responseRequired = command.isResponseRequired(); int commandId = command.getCommandId(); // the connection handles pings, negotiations directly. diff --git a/examples/features/perf/perf/pom.xml b/examples/features/perf/perf/pom.xml index bcab911a79..190f505684 100644 --- a/examples/features/perf/perf/pom.xml +++ b/examples/features/perf/perf/pom.xml @@ -18,7 +18,8 @@ specific language governing permissions and limitations under the License. --> - + 4.0.0 @@ -27,9 +28,9 @@ under the License. 1.0.1-SNAPSHOT - perf + openwire-perf jar - ActiveMQ Artemis JMS PerfExample Example + ActiveMQ Artemis JMS Perf example for openwire ${project.basedir}/../../../.. @@ -37,33 +38,24 @@ under the License. - org.apache.activemq - artemis-server - ${project.version} + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 org.apache.activemq - artemis-jms-server - ${project.version} + activemq-client + ${activemq5-version} + org.slf4j + slf4j-nop + ${slf4j-version} + + + org.apache.activemq - artemis-core-client - ${project.version} - - - org.apache.activemq - artemis-commons - ${project.version} - - - io.netty - netty-all - ${netty.version} - - - org.apache.activemq - artemis-jms-client + artemis-cli ${project.version} @@ -76,30 +68,37 @@ under the License. org.apache.activemq artemis-maven-plugin - - - create - - create - - - - runClient - - runClient - - - org.apache.activemq.artemis.jms.example.Server - - - - - - org.apache.activemq.examples.soak - perf - ${project.version} - - + + + create + + false + + --queues + perfQueue + + + + create + + + + runClient + + runClient + + + org.apache.activemq.artemis.jms.example.Server + + + + + + org.apache.activemq.examples.soak + openwire-perf + ${project.version} + + @@ -109,20 +108,26 @@ under the License. - org.codehaus.mojo - exec-maven-plugin - 1.1 + org.apache.activemq + artemis-maven-plugin - package + runClient - java + runClient + + org.apache.activemq.artemis.jms.example.PerfListener + - - org.apache.activemq.artemis.jms.example.PerfListener - + + + org.apache.activemq.examples.soak + openwire-perf + ${project.version} + + @@ -132,25 +137,29 @@ under the License. - org.codehaus.mojo - exec-maven-plugin - 1.1 + org.apache.activemq + artemis-maven-plugin - package + runClient - java + runClient + + org.apache.activemq.artemis.jms.example.PerfSender + - - org.apache.activemq.artemis.jms.example.PerfSender - + + + org.apache.activemq.examples.soak + openwire-perf + ${project.version} + + - - diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java index bf18077c83..8fcafa4b28 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java @@ -27,7 +27,6 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.MessageProducer; import javax.jms.Session; -import javax.naming.InitialContext; import java.io.FileInputStream; import java.io.InputStream; import java.util.Properties; @@ -60,7 +59,7 @@ public abstract class PerfBase { protected static String getPerfFileName(final String[] args) { String fileName; - if (args.length > 0) { + if (args != null && args.length > 0) { fileName = args[0]; } else { @@ -95,12 +94,13 @@ public abstract class PerfBase { boolean transacted = Boolean.valueOf(props.getProperty("transacted")); int batchSize = Integer.valueOf(props.getProperty("batch-size")); boolean drainQueue = Boolean.valueOf(props.getProperty("drain-queue")); - String destinationLookup = props.getProperty("destination-lookup"); - String connectionFactoryLookup = props.getProperty("connection-factory-lookup"); + String destinationName = props.getProperty("destination-name"); int throttleRate = Integer.valueOf(props.getProperty("throttle-rate")); boolean dupsOK = Boolean.valueOf(props.getProperty("dups-ok-acknowlege")); boolean disableMessageID = Boolean.valueOf(props.getProperty("disable-message-id")); boolean disableTimestamp = Boolean.valueOf(props.getProperty("disable-message-timestamp")); + boolean openwire = Boolean.valueOf(props.getProperty("openwire", "true")); + String uri = props.getProperty("server-uri", "tcp://localhost:61616"); PerfBase.log.info("num-messages: " + noOfMessages); PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages); @@ -110,11 +110,12 @@ public abstract class PerfBase { PerfBase.log.info("batch-size: " + batchSize); PerfBase.log.info("drain-queue: " + drainQueue); PerfBase.log.info("throttle-rate: " + throttleRate); - PerfBase.log.info("connection-factory-lookup: " + connectionFactoryLookup); - PerfBase.log.info("destination-lookup: " + destinationLookup); + PerfBase.log.info("destination-name: " + destinationName); PerfBase.log.info("disable-message-id: " + disableMessageID); PerfBase.log.info("disable-message-timestamp: " + disableTimestamp); PerfBase.log.info("dups-ok-acknowledge: " + dupsOK); + PerfBase.log.info("server-uri: " + uri); + PerfBase.log.info("openwire:" + openwire); PerfParams perfParams = new PerfParams(); perfParams.setNoOfMessagesToSend(noOfMessages); @@ -124,12 +125,13 @@ public abstract class PerfBase { perfParams.setSessionTransacted(transacted); perfParams.setBatchSize(batchSize); perfParams.setDrainQueue(drainQueue); - perfParams.setConnectionFactoryLookup(connectionFactoryLookup); - perfParams.setDestinationLookup(destinationLookup); + perfParams.setDestinationName(destinationName); perfParams.setThrottleRate(throttleRate); perfParams.setDisableMessageID(disableMessageID); perfParams.setDisableTimestamp(disableTimestamp); perfParams.setDupsOK(dupsOK); + perfParams.setOpenwire(openwire); + perfParams.setUri(uri); return perfParams; } @@ -151,17 +153,23 @@ public abstract class PerfBase { private long start; private void init() throws Exception { - InitialContext ic = new InitialContext(); - System.out.println("ic = " + ic); - factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup()); + if (perfParams.isOpenwire()) { + factory = new org.apache.activemq.ActiveMQConnectionFactory(perfParams.getUri()); - destination = (Destination) ic.lookup(perfParams.getDestinationLookup()); + destination = new org.apache.activemq.command.ActiveMQQueue(perfParams.getDestinationName()); - connection = factory.createConnection(); + connection = factory.createConnection(); + } + else { + factory = new org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory(perfParams.getUri()); + + destination = new org.apache.activemq.artemis.jms.client.ActiveMQQueue(perfParams.getDestinationName()); + + connection = factory.createConnection(); + + } session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE); - - ic.close(); } private void displayAverage(final long numberOfMessages, final long start, final long end) { diff --git a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java index c3581711ab..ce78ffdba7 100644 --- a/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java +++ b/examples/features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java @@ -39,9 +39,7 @@ public class PerfParams implements Serializable { private boolean drainQueue = true; - private String connectionFactoryLookup; - - private String destinationLookup; + private String destinationName; private int throttleRate; @@ -49,8 +47,20 @@ public class PerfParams implements Serializable { private boolean disableTimestamp; + private boolean openwire; + private boolean dupsOK; + private String uri; + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + public synchronized int getNoOfMessagesToSend() { return noOfMessagesToSend; } @@ -99,6 +109,14 @@ public class PerfParams implements Serializable { this.batchSize = batchSize; } + public String getDestinationName() { + return destinationName; + } + + public void setDestinationName(String destinationName) { + this.destinationName = destinationName; + } + public synchronized boolean isDrainQueue() { return drainQueue; } @@ -107,22 +125,6 @@ public class PerfParams implements Serializable { this.drainQueue = drainQueue; } - public synchronized String getConnectionFactoryLookup() { - return connectionFactoryLookup; - } - - public synchronized void setConnectionFactoryLookup(final String connectionFactoryLookup) { - this.connectionFactoryLookup = connectionFactoryLookup; - } - - public synchronized String getDestinationLookup() { - return destinationLookup; - } - - public synchronized void setDestinationLookup(final String destinationLookup) { - this.destinationLookup = destinationLookup; - } - public synchronized int getThrottleRate() { return throttleRate; } @@ -155,4 +157,11 @@ public class PerfParams implements Serializable { this.dupsOK = dupsOK; } + public boolean isOpenwire() { + return openwire; + } + + public void setOpenwire(boolean openwire) { + this.openwire = openwire; + } } diff --git a/examples/features/perf/perf/src/main/resources/activemq/server0/broker.xml b/examples/features/perf/perf/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index a642ac5174..0000000000 --- a/examples/features/perf/perf/src/main/resources/activemq/server0/broker.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - false - true - - - - tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576 - - - - -
perfAddress
-
-
- -
-
diff --git a/examples/features/perf/perf/src/main/resources/jndi.properties b/examples/features/perf/perf/src/main/resources/jndi.properties deleted file mode 100644 index bcf6926185..0000000000 --- a/examples/features/perf/perf/src/main/resources/jndi.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory -connectionFactory.ConnectionFactory=tcp://localhost:61616?tcp-no-delay=false&tcp-send-buffer-size=1048576&tcp-receive-buffer-size=1048576 -queue.perfQueue=perfQueue diff --git a/examples/features/perf/perf/src/main/resources/perf.properties b/examples/features/perf/perf/src/main/resources/perf.properties index f5ca7be9fb..7a0242a1ad 100644 --- a/examples/features/perf/perf/src/main/resources/perf.properties +++ b/examples/features/perf/perf/src/main/resources/perf.properties @@ -15,16 +15,17 @@ # specific language governing permissions and limitations # under the License. -num-messages=100000 +num-messages=25000 num-warmup-messages=1000 message-size=1024 -durable=false +durable=true transacted=false batch-size=1000 drain-queue=false -destination-lookup=perfQueue -connection-factory-lookup=ConnectionFactory +destination-name=perfQueue throttle-rate=-1 dups-ok-acknowledge=false disable-message-id=true disable-message-timestamp=true +server-uri=tcp://localhost:61616 +openwire=false diff --git a/examples/pom.xml b/examples/pom.xml index e17ee02cd4..4381cbb05a 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -33,6 +33,8 @@ under the License. ActiveMQ Artemis Examples + 1.7.10 + 5.12.0 231.7.7.7 ${project.basedir}/..