You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2008/09/19 16:32:17 UTC

svn commit: r697107 - in /activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store: KahaLoadTester.java perf/KahaBulkLoadingTest.java

Author: chirino
Date: Fri Sep 19 07:32:17 2008
New Revision: 697107

URL: http://svn.apache.org/viewvc?rev=697107&view=rev
Log:
renaming perf testing class

Added:
    activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java   (with props)
Removed:
    activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/KahaLoadTester.java

Added: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java?rev=697107&view=auto
==============================================================================
--- activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java (added)
+++ activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java Fri Sep 19 07:32:17 2008
@@ -0,0 +1,117 @@
+/**
+ * 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.kahadb.store.perf;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import javax.jms.BytesMessage;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import junit.framework.Test;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.JmsTestSupport;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.ProgressPrinter;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.kahadb.store.KahaDBPersistenceAdaptor;
+
+/**
+ * This tests bulk loading and unloading of messages to a Queue.s
+ * 
+ * @version $Revision$
+ */
+public class KahaBulkLoadingTest extends JmsTestSupport {
+
+    private static final Log LOG = LogFactory.getLog(KahaBulkLoadingTest.class);
+    
+    protected int messageSize = 1024 * 64;
+    protected int produceCount = 10000;
+
+    protected BrokerService createBroker() throws Exception {
+        BrokerService broker = new BrokerService();
+        KahaDBPersistenceAdaptor kaha = new KahaDBPersistenceAdaptor();
+        kaha.setDirectory(new File("target/activemq-data/kahadb"));
+        kaha.deleteAllMessages();
+        broker.setPersistenceAdapter(kaha);
+        broker.addConnector("tcp://localhost:0");
+        return broker;
+    }
+
+    protected ConnectionFactory createConnectionFactory() throws URISyntaxException, IOException {
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(((TransportConnector)broker.getTransportConnectors().get(0)).getServer().getConnectURI());
+        factory.setUseAsyncSend(true);
+        return factory;
+    }
+
+    public void testQueueSendThenAddConsumer() throws Exception {
+        ProgressPrinter printer = new ProgressPrinter(produceCount, 20);
+
+        ActiveMQDestination destination = new ActiveMQQueue("TEST");
+
+        connection.setUseCompression(false);
+        connection.getPrefetchPolicy().setAll(10);
+        connection.start();
+        Session session = connection.createSession(false, Session.DUPS_OK_ACKNOWLEDGE);
+        MessageProducer producer = session.createProducer(destination);
+        producer.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+        LOG.info("Sending " + produceCount + " messages that are " + (messageSize / 1024.0) + "k large, for a total of " + (produceCount * messageSize / (1024.0 * 1024.0))
+                 + " megs of data.");
+        // Send a message to the broker.
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < produceCount; i++) {
+            printer.increment();
+            BytesMessage msg = session.createBytesMessage();
+            msg.writeBytes(new byte[messageSize]);
+            producer.send(msg);
+        }
+        long end1 = System.currentTimeMillis();
+
+        LOG.info("Produced messages/sec: " + (produceCount * 1000.0 / (end1 - start)));
+
+        printer = new ProgressPrinter(produceCount, 10);
+        start = System.currentTimeMillis();
+        MessageConsumer consumer = session.createConsumer(destination);
+        for (int i = 0; i < produceCount; i++) {
+            printer.increment();
+            assertNotNull("Getting message: " + i, consumer.receive(20000));
+        }
+        end1 = System.currentTimeMillis();
+        LOG.info("Consumed messages/sec: " + (produceCount * 1000.0 / (end1 - start)));
+
+    }
+
+    public static Test suite() {
+        return suite(KahaBulkLoadingTest.class);
+    }
+
+    public static void main(String[] args) {
+        junit.textui.TestRunner.run(suite());
+    }
+
+}

Propchange: activemq/sandbox/kahadb/src/test/java/org/apache/kahadb/store/perf/KahaBulkLoadingTest.java
------------------------------------------------------------------------------
    svn:executable = *