Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A48C184B9 for ; Thu, 13 Aug 2015 04:13:24 +0000 (UTC) Received: (qmail 12156 invoked by uid 500); 13 Aug 2015 04:13:23 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 12067 invoked by uid 500); 13 Aug 2015 04:13:23 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 8951 invoked by uid 99); 13 Aug 2015 04:13:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Aug 2015 04:13:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C91B2E6820; Thu, 13 Aug 2015 04:13:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: clebertsuconic@apache.org To: commits@activemq.apache.org Date: Thu, 13 Aug 2015 04:13:58 -0000 Message-Id: <5522d9291d564b758be0aeaae7a0cf37@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [40/48] activemq-artemis git commit: renaming broker-features -> features on examples http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/pom.xml b/examples/broker-features/perf/perf/pom.xml deleted file mode 100644 index bcab911..0000000 --- a/examples/broker-features/perf/perf/pom.xml +++ /dev/null @@ -1,156 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq.examples.soak - perf-root - 1.0.1-SNAPSHOT - - - perf - jar - ActiveMQ Artemis JMS PerfExample Example - - - ${project.basedir}/../../../.. - - - - - org.apache.activemq - artemis-server - ${project.version} - - - org.apache.activemq - artemis-jms-server - ${project.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 - ${project.version} - - - - - - server - - - - 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} - - - - - - - - listener - - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - package - - java - - - - - org.apache.activemq.artemis.jms.example.PerfListener - - - - - - - sender - - - - org.codehaus.mojo - exec-maven-plugin - 1.1 - - - package - - java - - - - - org.apache.activemq.artemis.jms.example.PerfSender - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/readme.html ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/readme.html b/examples/broker-features/perf/perf/readme.html deleted file mode 100644 index aa42266..0000000 --- a/examples/broker-features/perf/perf/readme.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - ActiveMQ Artemis JMS Queue Selector Example - - - - - -

JMS Simple Performance

- -

To start the server run mvn verify -Pexample

- -

To start the listener run mvn -Plistener package

- -

To start the sender run mvn -Psender package

- -

To configure the clients simply edit the perf.properties or client.jndi.properties in the - src/main/resources directory

- - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java deleted file mode 100644 index bf18077..0000000 --- a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfBase.java +++ /dev/null @@ -1,409 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.Message; -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; -import java.util.Random; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; - -import org.apache.activemq.artemis.utils.TokenBucketLimiter; -import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; - -public abstract class PerfBase { - - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); - - private static final String DEFAULT_PERF_PROPERTIES_FILE_NAME = "target/classes/perf.properties"; - - private static byte[] randomByteArray(final int length) { - byte[] bytes = new byte[length]; - - Random random = new Random(); - - for (int i = 0; i < length; i++) { - bytes[i] = Integer.valueOf(random.nextInt()).byteValue(); - } - - return bytes; - } - - protected static String getPerfFileName(final String[] args) { - String fileName; - - if (args.length > 0) { - fileName = args[0]; - } - else { - fileName = PerfBase.DEFAULT_PERF_PROPERTIES_FILE_NAME; - } - - return fileName; - } - - protected static PerfParams getParams(final String fileName) throws Exception { - Properties props = null; - - InputStream is = null; - - try { - is = new FileInputStream(fileName); - - props = new Properties(); - - props.load(is); - } - finally { - if (is != null) { - is.close(); - } - } - - int noOfMessages = Integer.valueOf(props.getProperty("num-messages")); - int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages")); - int messageSize = Integer.valueOf(props.getProperty("message-size")); - boolean durable = Boolean.valueOf(props.getProperty("durable")); - 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"); - 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")); - - PerfBase.log.info("num-messages: " + noOfMessages); - PerfBase.log.info("num-warmup-messages: " + noOfWarmupMessages); - PerfBase.log.info("message-size: " + messageSize); - PerfBase.log.info("durable: " + durable); - PerfBase.log.info("transacted: " + transacted); - 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("disable-message-id: " + disableMessageID); - PerfBase.log.info("disable-message-timestamp: " + disableTimestamp); - PerfBase.log.info("dups-ok-acknowledge: " + dupsOK); - - PerfParams perfParams = new PerfParams(); - perfParams.setNoOfMessagesToSend(noOfMessages); - perfParams.setNoOfWarmupMessages(noOfWarmupMessages); - perfParams.setMessageSize(messageSize); - perfParams.setDurable(durable); - perfParams.setSessionTransacted(transacted); - perfParams.setBatchSize(batchSize); - perfParams.setDrainQueue(drainQueue); - perfParams.setConnectionFactoryLookup(connectionFactoryLookup); - perfParams.setDestinationLookup(destinationLookup); - perfParams.setThrottleRate(throttleRate); - perfParams.setDisableMessageID(disableMessageID); - perfParams.setDisableTimestamp(disableTimestamp); - perfParams.setDupsOK(dupsOK); - - return perfParams; - } - - private final PerfParams perfParams; - - protected PerfBase(final PerfParams perfParams) { - this.perfParams = perfParams; - } - - private ConnectionFactory factory; - - private Connection connection; - - private Session session; - - private Destination destination; - - private long start; - - private void init() throws Exception { - InitialContext ic = new InitialContext(); - System.out.println("ic = " + ic); - factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup()); - - destination = (Destination) ic.lookup(perfParams.getDestinationLookup()); - - 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) { - double duration = (1.0 * end - start) / 1000; // in seconds - double average = 1.0 * numberOfMessages / duration; - PerfBase.log.info(String.format("average: %.2f msg/s (%d messages in %2.2fs)", average, numberOfMessages, duration)); - } - - protected void runSender() { - try { - init(); - - if (perfParams.isDrainQueue()) { - drainQueue(); - } - - start = System.currentTimeMillis(); - PerfBase.log.info("warming up by sending " + perfParams.getNoOfWarmupMessages() + " messages"); - sendMessages(perfParams.getNoOfWarmupMessages(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), false, perfParams.getThrottleRate(), perfParams.getMessageSize()); - PerfBase.log.info("warmed up"); - start = System.currentTimeMillis(); - sendMessages(perfParams.getNoOfMessagesToSend(), perfParams.getBatchSize(), perfParams.isDurable(), perfParams.isSessionTransacted(), true, perfParams.getThrottleRate(), perfParams.getMessageSize()); - long end = System.currentTimeMillis(); - displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - if (session != null) { - try { - session.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - if (connection != null) { - try { - connection.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - } - } - } - - protected void runListener() { - try { - init(); - - if (perfParams.isDrainQueue()) { - drainQueue(); - } - - MessageConsumer consumer = session.createConsumer(destination); - - connection.start(); - - PerfBase.log.info("READY!!!"); - - CountDownLatch countDownLatch = new CountDownLatch(1); - consumer.setMessageListener(new PerfListener(countDownLatch, perfParams)); - countDownLatch.await(); - long end = System.currentTimeMillis(); - // start was set on the first received message - displayAverage(perfParams.getNoOfMessagesToSend(), start, end); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - if (session != null) { - try { - session.close(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - if (connection != null) { - try { - connection.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - } - } - } - - private void drainQueue() throws Exception { - PerfBase.log.info("Draining queue"); - - Session drainSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); - - MessageConsumer consumer = drainSession.createConsumer(destination); - - connection.start(); - - Message message = null; - - int count = 0; - do { - message = consumer.receive(3000); - - if (message != null) { - message.acknowledge(); - - count++; - } - } while (message != null); - - drainSession.close(); - - PerfBase.log.info("Drained " + count + " messages"); - } - - private void sendMessages(final int numberOfMessages, - final int txBatchSize, - final boolean durable, - final boolean transacted, - final boolean display, - final int throttleRate, - final int messageSize) throws Exception { - MessageProducer producer = session.createProducer(destination); - - producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); - - producer.setDisableMessageID(perfParams.isDisableMessageID()); - - producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp()); - - BytesMessage message = session.createBytesMessage(); - - byte[] payload = PerfBase.randomByteArray(messageSize); - - message.writeBytes(payload); - - final int modulo = 2000; - - TokenBucketLimiter tbl = throttleRate != -1 ? new TokenBucketLimiterImpl(throttleRate, false) : null; - - boolean committed = false; - for (int i = 1; i <= numberOfMessages; i++) { - producer.send(message); - - if (transacted) { - if (i % txBatchSize == 0) { - session.commit(); - committed = true; - } - else { - committed = false; - } - } - - if (display && i % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - start) / 1000; - PerfBase.log.info(String.format("sent %6d messages in %2.2fs", i, duration)); - } - - if (tbl != null) { - tbl.limit(); - } - } - if (transacted && !committed) { - session.commit(); - } - } - - private class PerfListener implements MessageListener { - - private final CountDownLatch countDownLatch; - - private final PerfParams perfParams; - - private boolean warmingUp = true; - - private boolean started = false; - - private final int modulo; - - private final AtomicLong count = new AtomicLong(0); - - public PerfListener(final CountDownLatch countDownLatch, final PerfParams perfParams) { - this.countDownLatch = countDownLatch; - this.perfParams = perfParams; - warmingUp = perfParams.getNoOfWarmupMessages() > 0; - modulo = 2000; - } - - public void onMessage(final Message message) { - try { - if (warmingUp) { - boolean committed = checkCommit(); - if (count.incrementAndGet() == perfParams.getNoOfWarmupMessages()) { - PerfBase.log.info("warmed up after receiving " + count.longValue() + " msgs"); - if (!committed) { - checkCommit(); - } - warmingUp = false; - } - return; - } - - if (!started) { - started = true; - // reset count to take stats - count.set(0); - start = System.currentTimeMillis(); - } - - long currentCount = count.incrementAndGet(); - boolean committed = checkCommit(); - if (currentCount == perfParams.getNoOfMessagesToSend()) { - if (!committed) { - checkCommit(); - } - countDownLatch.countDown(); - } - if (currentCount % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - start) / 1000; - PerfBase.log.info(String.format("received %6d messages in %2.2fs", currentCount, duration)); - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private boolean checkCommit() throws Exception { - if (perfParams.isSessionTransacted()) { - if (count.longValue() % perfParams.getBatchSize() == 0) { - session.commit(); - - return true; - } - } - return false; - } - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java deleted file mode 100644 index 3f2c478..0000000 --- a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfListener.java +++ /dev/null @@ -1,46 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import java.util.logging.Logger; - -public class PerfListener extends PerfBase { - - private static final Logger log = Logger.getLogger(PerfListener.class.getName()); - - public static void main(final String[] args) { - try { - String fileName = PerfBase.getPerfFileName(args); - - PerfParams params = PerfBase.getParams(fileName); - - new PerfListener(params).run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private PerfListener(final PerfParams perfParams) { - super(perfParams); - } - - public void run() throws Exception { - runListener(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java deleted file mode 100644 index c358171..0000000 --- a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfParams.java +++ /dev/null @@ -1,158 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import java.io.Serializable; - -/** - * Class that holds the parameters used in the performance examples - */ -public class PerfParams implements Serializable { - - private static final long serialVersionUID = -4336539641012356002L; - - private int noOfMessagesToSend = 1000; - - private int noOfWarmupMessages; - - private int messageSize = 1024; // in bytes - - private boolean durable = false; - - private boolean isSessionTransacted = false; - - private int batchSize = 5000; - - private boolean drainQueue = true; - - private String connectionFactoryLookup; - - private String destinationLookup; - - private int throttleRate; - - private boolean disableMessageID; - - private boolean disableTimestamp; - - private boolean dupsOK; - - public synchronized int getNoOfMessagesToSend() { - return noOfMessagesToSend; - } - - public synchronized void setNoOfMessagesToSend(final int noOfMessagesToSend) { - this.noOfMessagesToSend = noOfMessagesToSend; - } - - public synchronized int getNoOfWarmupMessages() { - return noOfWarmupMessages; - } - - public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) { - this.noOfWarmupMessages = noOfWarmupMessages; - } - - public synchronized int getMessageSize() { - return messageSize; - } - - public synchronized void setMessageSize(final int messageSize) { - this.messageSize = messageSize; - } - - public synchronized boolean isDurable() { - return durable; - } - - public synchronized void setDurable(final boolean durable) { - this.durable = durable; - } - - public synchronized boolean isSessionTransacted() { - return isSessionTransacted; - } - - public synchronized void setSessionTransacted(final boolean isSessionTransacted) { - this.isSessionTransacted = isSessionTransacted; - } - - public synchronized int getBatchSize() { - return batchSize; - } - - public synchronized void setBatchSize(final int batchSize) { - this.batchSize = batchSize; - } - - public synchronized boolean isDrainQueue() { - return drainQueue; - } - - public synchronized void setDrainQueue(final boolean drainQueue) { - 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; - } - - public synchronized void setThrottleRate(final int throttleRate) { - this.throttleRate = throttleRate; - } - - public synchronized boolean isDisableMessageID() { - return disableMessageID; - } - - public synchronized void setDisableMessageID(final boolean disableMessageID) { - this.disableMessageID = disableMessageID; - } - - public synchronized boolean isDisableTimestamp() { - return disableTimestamp; - } - - public synchronized void setDisableTimestamp(final boolean disableTimestamp) { - this.disableTimestamp = disableTimestamp; - } - - public synchronized boolean isDupsOK() { - return dupsOK; - } - - public synchronized void setDupsOK(final boolean dupsOK) { - this.dupsOK = dupsOK; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java deleted file mode 100644 index 6649bfa..0000000 --- a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/PerfSender.java +++ /dev/null @@ -1,46 +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. - */ -package org.apache.activemq.artemis.jms.example; - -import java.util.logging.Logger; - -public class PerfSender extends PerfBase { - - private static final Logger log = Logger.getLogger(PerfSender.class.getName()); - - public static void main(final String[] args) { - try { - String fileName = PerfBase.getPerfFileName(args); - - PerfParams params = PerfBase.getParams(fileName); - - new PerfSender(params).run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private PerfSender(final PerfParams perfParams) { - super(perfParams); - } - - public void run() throws Exception { - runSender(); - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java b/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java deleted file mode 100644 index 33ccd0e..0000000 --- a/examples/broker-features/perf/perf/src/main/java/org/apache/activemq/artemis/jms/example/Server.java +++ /dev/null @@ -1,27 +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. - */ - -package org.apache.activemq.artemis.jms.example; - -public class Server { - - public static void main(String[] arg) { - System.out.println("***********************************************************************************"); - System.out.println("You need to start manually under ./target/server/bin just run ./artemis run"); - System.out.println("***********************************************************************************"); - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml b/examples/broker-features/perf/perf/src/main/resources/activemq/server0/broker.xml deleted file mode 100644 index a642ac5..0000000 --- a/examples/broker-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
-
-
- -
-
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/resources/jndi.properties b/examples/broker-features/perf/perf/src/main/resources/jndi.properties deleted file mode 100644 index bcf6926..0000000 --- a/examples/broker-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 http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/perf/src/main/resources/perf.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/perf/src/main/resources/perf.properties b/examples/broker-features/perf/perf/src/main/resources/perf.properties deleted file mode 100644 index f5ca7be..0000000 --- a/examples/broker-features/perf/perf/src/main/resources/perf.properties +++ /dev/null @@ -1,30 +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. - -num-messages=100000 -num-warmup-messages=1000 -message-size=1024 -durable=false -transacted=false -batch-size=1000 -drain-queue=false -destination-lookup=perfQueue -connection-factory-lookup=ConnectionFactory -throttle-rate=-1 -dups-ok-acknowledge=false -disable-message-id=true -disable-message-timestamp=true http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/pom.xml b/examples/broker-features/perf/pom.xml deleted file mode 100644 index eaafdaf..0000000 --- a/examples/broker-features/perf/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq.examples - artemis-examples - 1.0.1-SNAPSHOT - - - org.apache.activemq.examples.soak - perf-root - pom - ActiveMQ Artemis Performance Examples - - - - - UTF-8 - ${project.basedir}/../../.. - - - - perf - soak - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/README ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/README b/examples/broker-features/perf/soak/README deleted file mode 100644 index b69a1ac..0000000 --- a/examples/broker-features/perf/soak/README +++ /dev/null @@ -1,85 +0,0 @@ -**************************************************** -* Soak Test For Manual Reconnection of JMS Clients * -**************************************************** - -Running the Soak Tests -======================= - -Run The Server Standalone -========================== - -Use the Profile server - mvn -Pserver verify - -That will create a server under ./target/server0 - - -You can define the property server.dir under the same Profile to create other servers. or you could do it manually if desired using the regular ./artemis create - - $ mvn -Dserver.dir=server1 -Pserver verify - -server1 should contain a copy of configuration equivalent to that found under the server0 director with different -settings. - -To run a server with the same configuration but on a different host. Check out this source on the host machine and -change: -* activemq.remoting.netty.host property in broker.xml -* bindAddress and rmiBindAddress properties in activemq-beans.xml - - $ mvn verify -P server - - -To run the server just start it manually - -Configure Server Dump -===================== - -The server can "dump" info at regular interval. In broker.xml, set - - 10000 - -to have infos every 10s: - -**** Server Dump **** -date: Mon Aug 17 18:19:07 CEST 2009 -free memory: 500,79 MiB -max memory: 1,95 GiB -total memory: 507,13 MiB -available memory: 99,68% -total paging memory: 0,00 B -# of thread: 19 -# of conns: 0 -******************** - -Run The Clients -=============== - -The clients can be run separate from the server using: - - $ mvn verify -Premote - -Parameters are specified in soak.properties. - -The duration of the tests is configured by duration-in-minutes (defaults to 2 minutes, set to --1 to run the test indefinitely). - -To configure the soak properties different to the defaults for the clients, use the system property -To specify the JNDI server to connect to, use the system property jndi.address - - $ mvn verify -Premote -Dsoak.props= -Pjndi.address=jnp:remote.host:1099 - -Every 1000th message, the clients will display their recent activity: - -INFO: received 10000 messages in 5,71s (total: 55s) - -At the end of the run, the sender and receiver will sum up their activity: - -INFO: Received 223364 messages in 2,01 minutes - -Kill The Server And Check Manual Reconnection -============================================== - -You can kill the server (ctl+c or kill -9), the clients are configured to reconnect -indefinitely to the same single server (even in case of clean shutdown) -Once the server restarts, all the clients will resume their activities after reconnecting -to the server. http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/pom.xml b/examples/broker-features/perf/soak/pom.xml deleted file mode 100644 index eb07b0b..0000000 --- a/examples/broker-features/perf/soak/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - 4.0.0 - artemis-jms-soak-example - jar - ActiveMQ Artemis Soak Normal Example - - - org.apache.activemq.examples.soak - perf-root - 1.0.1-SNAPSHOT - - - - - org.apache.activemq - artemis-jms-client - ${project.version} - - - - - ${basedir}/server0/ - ${project.basedir}/../../../.. - - - - - server - - - - org.apache.activemq - artemis-maven-plugin - - - create - - create - - - ${basedir}/target/server0 - ${basedir}/server0 - - - - - - org.apache.activemq.examples.soak - artemis-jms-soak-example - ${project.version} - - - - - - - - local - - - - org.apache.activemq - artemis-maven-plugin - - - runConsumer - - runClient - - - org.apache.activemq.artemis.jms.soak.example.SoakReceiver - - - - runProducer - - runClient - - - org.apache.activemq.artemis.jms.soak.example.SoakSender - - - - - - org.apache.activemq.examples.soak - artemis-jms-soak-example - ${project.version} - - - - - - - - remote - - - - org.apache.activemq - artemis-maven-plugin - - - runConsumer - - runClient - - - org.apache.activemq.artemis.jms.soak.example.SoakReceiver - - tcp://localhost:61616 - - - - - runProducer - - runClient - - - org.apache.activemq.artemis.jms.soak.example.SoakSender - - tcp://localhost:61616 - - - - - - - org.apache.activemq.examples.soak - artemis-jms-soak-example - ${project.version} - - - - - - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/server0/broker.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/server0/broker.xml b/examples/broker-features/perf/soak/server0/broker.xml deleted file mode 100644 index 76df21f..0000000 --- a/examples/broker-features/perf/soak/server0/broker.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576 - - - - - tcp://localhost:61616?tcpNoDelay=false;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576 - - - false - - false - - 30000 - - - -
soakAddress
-
-
-
- -
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/soak.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/soak.properties b/examples/broker-features/perf/soak/soak.properties deleted file mode 100644 index 2ccff7d..0000000 --- a/examples/broker-features/perf/soak/soak.properties +++ /dev/null @@ -1,30 +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. - -duration-in-minutes=2 -num-warmup-messages=100 -message-size=1024 -durable=true -transacted=false -batch-size=1000 -drain-queue=false -destination-lookup=soakQueue -connection-factory-lookup=/ConnectionFactory -throttle-rate=-1 -dups-ok-acknowledge=false -disable-message-id=true -disable-message-timestamp=true http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java deleted file mode 100644 index ce5b9bc..0000000 --- a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakBase.java +++ /dev/null @@ -1,116 +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. - */ -package org.apache.activemq.artemis.jms.soak.example; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.util.Properties; -import java.util.Random; -import java.util.logging.Logger; - -public class SoakBase { - - private static final Logger log = Logger.getLogger(SoakBase.class.getName()); - - private static final String DEFAULT_SOAK_PROPERTIES_FILE_NAME = "soak.properties"; - - public static final int TO_MILLIS = 60 * 1000; // from minute to milliseconds - - public static byte[] randomByteArray(final int length) { - byte[] bytes = new byte[length]; - - Random random = new Random(); - - for (int i = 0; i < length; i++) { - bytes[i] = Integer.valueOf(random.nextInt()).byteValue(); - } - - return bytes; - } - - protected static String getPerfFileName() { - String fileName = System.getProperty("soak.props"); - if (fileName == null) { - fileName = SoakBase.DEFAULT_SOAK_PROPERTIES_FILE_NAME; - } - return fileName; - } - - protected static SoakParams getParams(final String fileName) throws Exception { - Properties props = null; - - InputStream is = null; - - try { - is = new FileInputStream(fileName); - - props = new Properties(); - - props.load(is); - } - finally { - if (is != null) { - is.close(); - } - } - - int durationInMinutes = Integer.valueOf(props.getProperty("duration-in-minutes")); - int noOfWarmupMessages = Integer.valueOf(props.getProperty("num-warmup-messages")); - int messageSize = Integer.valueOf(props.getProperty("message-size")); - boolean durable = Boolean.valueOf(props.getProperty("durable")); - 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"); - 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")); - - SoakBase.log.info("duration-in-minutes: " + durationInMinutes); - SoakBase.log.info("num-warmup-messages: " + noOfWarmupMessages); - SoakBase.log.info("message-size: " + messageSize); - SoakBase.log.info("durable: " + durable); - SoakBase.log.info("transacted: " + transacted); - SoakBase.log.info("batch-size: " + batchSize); - SoakBase.log.info("drain-queue: " + drainQueue); - SoakBase.log.info("throttle-rate: " + throttleRate); - SoakBase.log.info("connection-factory-lookup: " + connectionFactoryLookup); - SoakBase.log.info("destination-lookup: " + destinationLookup); - SoakBase.log.info("disable-message-id: " + disableMessageID); - SoakBase.log.info("disable-message-timestamp: " + disableTimestamp); - SoakBase.log.info("dups-ok-acknowledge: " + dupsOK); - - SoakParams soakParams = new SoakParams(); - soakParams.setDurationInMinutes(durationInMinutes); - soakParams.setNoOfWarmupMessages(noOfWarmupMessages); - soakParams.setMessageSize(messageSize); - soakParams.setDurable(durable); - soakParams.setSessionTransacted(transacted); - soakParams.setBatchSize(batchSize); - soakParams.setDrainQueue(drainQueue); - soakParams.setConnectionFactoryLookup(connectionFactoryLookup); - soakParams.setDestinationLookup(destinationLookup); - soakParams.setThrottleRate(throttleRate); - soakParams.setDisableMessageID(disableMessageID); - soakParams.setDisableTimestamp(disableTimestamp); - soakParams.setDupsOK(dupsOK); - - return soakParams; - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java deleted file mode 100644 index dda2ac1..0000000 --- a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakParams.java +++ /dev/null @@ -1,158 +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. - */ -package org.apache.activemq.artemis.jms.soak.example; - -import java.io.Serializable; - -/** - * Class that holds the parameters used in the performance examples - */ -public class SoakParams implements Serializable { - - private static final long serialVersionUID = -4336539641012356002L; - - private int durationInMinutes = 60; - - private int noOfWarmupMessages; - - private int messageSize = 1024; // in bytes - - private boolean durable = false; - - private boolean isSessionTransacted = false; - - private int batchSize = 5000; - - private boolean drainQueue = true; - - private String connectionFactoryLookup; - - private String destinationLookup; - - private int throttleRate; - - private boolean disableMessageID; - - private boolean disableTimestamp; - - private boolean dupsOK; - - public synchronized int getDurationInMinutes() { - return durationInMinutes; - } - - public synchronized void setDurationInMinutes(final int durationInMinutes) { - this.durationInMinutes = durationInMinutes; - } - - public synchronized int getNoOfWarmupMessages() { - return noOfWarmupMessages; - } - - public synchronized void setNoOfWarmupMessages(final int noOfWarmupMessages) { - this.noOfWarmupMessages = noOfWarmupMessages; - } - - public synchronized int getMessageSize() { - return messageSize; - } - - public synchronized void setMessageSize(final int messageSize) { - this.messageSize = messageSize; - } - - public synchronized boolean isDurable() { - return durable; - } - - public synchronized void setDurable(final boolean durable) { - this.durable = durable; - } - - public synchronized boolean isSessionTransacted() { - return isSessionTransacted; - } - - public synchronized void setSessionTransacted(final boolean isSessionTransacted) { - this.isSessionTransacted = isSessionTransacted; - } - - public synchronized int getBatchSize() { - return batchSize; - } - - public synchronized void setBatchSize(final int batchSize) { - this.batchSize = batchSize; - } - - public synchronized boolean isDrainQueue() { - return drainQueue; - } - - public synchronized void setDrainQueue(final boolean drainQueue) { - 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; - } - - public synchronized void setThrottleRate(final int throttleRate) { - this.throttleRate = throttleRate; - } - - public synchronized boolean isDisableMessageID() { - return disableMessageID; - } - - public synchronized void setDisableMessageID(final boolean disableMessageID) { - this.disableMessageID = disableMessageID; - } - - public synchronized boolean isDisableTimestamp() { - return disableTimestamp; - } - - public synchronized void setDisableTimestamp(final boolean disableTimestamp) { - this.disableTimestamp = disableTimestamp; - } - - public synchronized boolean isDupsOK() { - return dupsOK; - } - - public synchronized void setDupsOK(final boolean dupsOK) { - this.dupsOK = dupsOK; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java deleted file mode 100644 index ce39968..0000000 --- a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakReceiver.java +++ /dev/null @@ -1,190 +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. - */ -package org.apache.activemq.artemis.jms.soak.example; - -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageConsumer; -import javax.jms.MessageListener; -import javax.jms.Session; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; - -public class SoakReceiver { - - private static final Logger log = Logger.getLogger(SoakReceiver.class.getName()); - - private static final String EOF = UUID.randomUUID().toString(); - - public static void main(final String[] args) { - Runnable runnable = new Runnable() { - @Override - public void run() { - - try { - String fileName = SoakBase.getPerfFileName(); - - SoakParams params = SoakBase.getParams(fileName); - - final SoakReceiver receiver = new SoakReceiver(params); - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - receiver.disconnect(); - } - }); - - receiver.run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - }; - - Thread t = new Thread(runnable); - t.start(); - } - - private final SoakParams perfParams; - - private final ExceptionListener exceptionListener = new ExceptionListener() { - public void onException(final JMSException e) { - disconnect(); - connect(); - } - }; - - private final MessageListener listener = new MessageListener() { - int modulo = 10000; - - private final AtomicLong count = new AtomicLong(0); - - private final long start = System.currentTimeMillis(); - - long moduloStart = start; - - public void onMessage(final Message msg) { - long totalDuration = System.currentTimeMillis() - start; - - try { - if (SoakReceiver.EOF.equals(msg.getStringProperty("eof"))) { - SoakReceiver.log.info(String.format("Received %s messages in %.2f minutes", count, 1.0 * totalDuration / SoakBase.TO_MILLIS)); - SoakReceiver.log.info("END OF RUN"); - - return; - } - } - catch (JMSException e1) { - e1.printStackTrace(); - } - if (count.incrementAndGet() % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - moduloStart) / 1000; - moduloStart = System.currentTimeMillis(); - SoakReceiver.log.info(String.format("received %s messages in %2.2fs (total: %.0fs)", modulo, duration, totalDuration / 1000.0)); - } - } - }; - - private Session session; - - private Connection connection; - - private SoakReceiver(final SoakParams perfParams) { - this.perfParams = perfParams; - } - - public void run() throws Exception { - connect(); - - boolean runInfinitely = perfParams.getDurationInMinutes() == -1; - - if (!runInfinitely) { - Thread.sleep(perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS); - - // send EOF message - Message eof = session.createMessage(); - eof.setStringProperty("eof", SoakReceiver.EOF); - listener.onMessage(eof); - - if (connection != null) { - connection.close(); - connection = null; - } - } - else { - while (true) { - Thread.sleep(500); - } - } - } - - private void disconnect() { - if (connection != null) { - try { - connection.setExceptionListener(null); - connection.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - finally { - connection = null; - } - } - } - - private void connect() { - InitialContext ic = null; - try { - ic = new InitialContext(); - - ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup()); - - Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup()); - - connection = factory.createConnection(); - connection.setExceptionListener(exceptionListener); - - session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE); - - MessageConsumer messageConsumer = session.createConsumer(destination); - messageConsumer.setMessageListener(listener); - - connection.start(); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - try { - ic.close(); - } - catch (NamingException e) { - e.printStackTrace(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java b/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java deleted file mode 100644 index 10fbbd8..0000000 --- a/examples/broker-features/perf/soak/src/main/java/org/apache/activemq/artemis/jms/soak/example/SoakSender.java +++ /dev/null @@ -1,195 +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. - */ -package org.apache.activemq.artemis.jms.soak.example; - -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.DeliveryMode; -import javax.jms.Destination; -import javax.jms.ExceptionListener; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.naming.InitialContext; -import javax.naming.NamingException; -import java.util.concurrent.atomic.AtomicLong; -import java.util.logging.Logger; - -import org.apache.activemq.artemis.utils.TokenBucketLimiter; -import org.apache.activemq.artemis.utils.TokenBucketLimiterImpl; - -public class SoakSender { - - private static final Logger log = Logger.getLogger(SoakSender.class.getName()); - - public static void main(final String[] args) { - try { - String fileName = SoakBase.getPerfFileName(); - - SoakParams params = SoakBase.getParams(fileName); - final SoakSender sender = new SoakSender(params); - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - sender.disconnect(); - } - }); - - sender.run(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - private final SoakParams perfParams; - - private Connection connection; - - private Session session; - - private MessageProducer producer; - - private final ExceptionListener exceptionListener = new ExceptionListener() { - public void onException(final JMSException e) { - System.out.println("SoakReconnectableSender.exceptionListener.new ExceptionListener() {...}.onException()"); - disconnect(); - connect(); - } - - }; - - private SoakSender(final SoakParams perfParams) { - this.perfParams = perfParams; - } - - public void run() throws Exception { - connect(); - - boolean runInfinitely = perfParams.getDurationInMinutes() == -1; - - BytesMessage message = session.createBytesMessage(); - - byte[] payload = SoakBase.randomByteArray(perfParams.getMessageSize()); - - message.writeBytes(payload); - - final int modulo = 10000; - - TokenBucketLimiter tbl = perfParams.getThrottleRate() != -1 ? new TokenBucketLimiterImpl(perfParams.getThrottleRate(), false) : null; - - boolean transacted = perfParams.isSessionTransacted(); - int txBatchSize = perfParams.getBatchSize(); - boolean display = true; - - long start = System.currentTimeMillis(); - long moduleStart = start; - AtomicLong count = new AtomicLong(0); - while (true) { - try { - producer.send(message); - count.incrementAndGet(); - - if (transacted) { - if (count.longValue() % txBatchSize == 0) { - session.commit(); - } - } - - long totalDuration = System.currentTimeMillis() - start; - - if (display && count.longValue() % modulo == 0) { - double duration = (1.0 * System.currentTimeMillis() - moduleStart) / 1000; - moduleStart = System.currentTimeMillis(); - SoakSender.log.info(String.format("sent %s messages in %2.2fs (time: %.0fs)", modulo, duration, totalDuration / 1000.0)); - } - - if (tbl != null) { - tbl.limit(); - } - - if (!runInfinitely && totalDuration > perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS) { - break; - } - } - catch (Exception e) { - e.printStackTrace(); - } - } - - SoakSender.log.info(String.format("Sent %s messages in %s minutes", count, perfParams.getDurationInMinutes())); - SoakSender.log.info("END OF RUN"); - - if (connection != null) { - connection.close(); - connection = null; - } - } - - private synchronized void disconnect() { - if (connection != null) { - try { - connection.setExceptionListener(null); - connection.close(); - } - catch (JMSException e) { - e.printStackTrace(); - } - finally { - connection = null; - } - } - } - - private void connect() { - InitialContext ic = null; - try { - ic = new InitialContext(); - - ConnectionFactory factory = (ConnectionFactory) ic.lookup(perfParams.getConnectionFactoryLookup()); - - Destination destination = (Destination) ic.lookup(perfParams.getDestinationLookup()); - - connection = factory.createConnection(); - - session = connection.createSession(perfParams.isSessionTransacted(), perfParams.isDupsOK() ? Session.DUPS_OK_ACKNOWLEDGE : Session.AUTO_ACKNOWLEDGE); - - producer = session.createProducer(destination); - - producer.setDeliveryMode(perfParams.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); - - producer.setDisableMessageID(perfParams.isDisableMessageID()); - - producer.setDisableMessageTimestamp(perfParams.isDisableTimestamp()); - - connection.setExceptionListener(exceptionListener); - } - catch (Exception e) { - e.printStackTrace(); - } - finally { - try { - ic.close(); - } - catch (NamingException e) { - e.printStackTrace(); - } - } - } -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/perf/soak/src/main/resources/jndi.properties ---------------------------------------------------------------------- diff --git a/examples/broker-features/perf/soak/src/main/resources/jndi.properties b/examples/broker-features/perf/soak/src/main/resources/jndi.properties deleted file mode 100644 index 93537c4..0000000 --- a/examples/broker-features/perf/soak/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 -queue.queue/exampleQueue=exampleQueue http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/pom.xml ---------------------------------------------------------------------- diff --git a/examples/broker-features/pom.xml b/examples/broker-features/pom.xml deleted file mode 100644 index f5afbee..0000000 --- a/examples/broker-features/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - 4.0.0 - - - org.apache.activemq.examples - artemis-examples - 1.0.1-SNAPSHOT - - - org.apache.activemq.examples.clustered - broker-features - pom - ActiveMQ Artemis Clustered Examples - - - - - UTF-8 - ${project.basedir}/../.. - - - - - examples - - clustered - ha - standard - sub-modules - perf - - - - release - - clustered - ha - standard - sub-modules - perf - - - - http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/6b17d966/examples/broker-features/standard/README.md ---------------------------------------------------------------------- diff --git a/examples/broker-features/standard/README.md b/examples/broker-features/standard/README.md deleted file mode 100644 index e9d9e36..0000000 --- a/examples/broker-features/standard/README.md +++ /dev/null @@ -1,32 +0,0 @@ -Running the ActiveMQ Artemis Examples -============================ - -To run an individual example firstly cd into the example directory and run - -```sh -mvn verify -``` - -Most examples offer a way to start them without creating and starting the server (say if you want to do it manually) - -```sh -mvn verify -PnoServer -``` - -If you are running against an un released version, i.e. from master branch, you will have to run `mvn install` on the root -pom.xml and the example/activemq-jms-examples-common/pom.xml first. - -If you want to run all the examples (except those that need to be run standalone) you can run `mvn verify -Pexamples` in the examples -directory but before you do you will need to up the memory used by running: - -``` -export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m" -``` -### Recreating the examples - -If you are trying to copy the examples somewhere else and modifying them. Consider asking Maven to explicitly list all the dependencies: - -``` -# if trying to modify the 'topic' example: -cd examples/jms/topic && mvn dependency:list -```