update performance tests

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@604691 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-12-16 20:16:59 +00:00
parent 628842f69a
commit 5582cc1751
12 changed files with 216 additions and 27 deletions

View File

@ -25,12 +25,22 @@ import org.apache.activemq.store.amq.AMQPersistenceAdapter;
*/
public class AMQStoreDurableTopicTest extends SimpleDurableTopicTest {
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest/amqdb");
dataFileDir.mkdirs();
answer.setDeleteAllMessagesOnStartup(true);
AMQPersistenceAdapter adaptor = new AMQPersistenceAdapter();
adaptor.setDirectory(dataFileDir);
adaptor.setArchiveDataLogs(true);
adaptor.setMaxFileLength(1024 * 64);
answer.setDataDirectoryFile(dataFileDir);
answer.setPersistenceAdapter(adaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
}
protected void setUp() throws Exception {
numberofProducers=6;
numberOfConsumers=6;
this.consumerSleepDuration=0;
super.setUp();
}
}

View File

@ -26,7 +26,7 @@ import org.apache.activemq.store.amq.AMQPersistenceAdapter;
*/
public class AMQStoreQueueTest extends SimpleQueueTest {
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest/amq");
@ -34,7 +34,7 @@ public class AMQStoreQueueTest extends SimpleQueueTest {
adaptor.setDirectory(dataFileDir);
answer.setPersistenceAdapter(adaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}

View File

@ -27,7 +27,7 @@ import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter;
*/
public class JournalKahaDurableTopicTest extends SimpleDurableTopicTest {
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest");
File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
@ -38,7 +38,7 @@ public class JournalKahaDurableTopicTest extends SimpleDurableTopicTest {
journalAdaptor.setMaxCheckpointWorkers(1);
answer.setPersistenceAdapter(journalAdaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}

View File

@ -28,7 +28,7 @@ import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter;
*/
public class JournalKahaQueueTest extends SimpleQueueTest {
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
File dataFileDir = new File("target/test-amq-data/perfTest");
File journalDir = new File(dataFileDir, "journal").getCanonicalFile();
@ -39,7 +39,7 @@ public class JournalKahaQueueTest extends SimpleQueueTest {
journalAdaptor.setMaxCheckpointWorkers(1);
answer.setPersistenceAdapter(journalAdaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}

View File

@ -32,10 +32,10 @@ public class KahaDurableTopicTest extends SimpleDurableTopicTest {
* result=factory.getBroker(); result.start(); return result; }
*/
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
answer.setPersistenceAdapter(adaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}

View File

@ -24,10 +24,10 @@ import org.apache.activemq.store.kahadaptor.KahaPersistenceAdapter;
*/
public class KahaQueueTest extends SimpleQueueTest {
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
answer.setPersistenceAdapter(adaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}

View File

@ -47,18 +47,18 @@ public class QueueConnectionMemoryTest extends SimpleQueueTest {
// just cancel super class test
}
protected void configureBroker(BrokerService answer) throws Exception {
protected void configureBroker(BrokerService answer,String uri) throws Exception {
KahaPersistenceAdapter adaptor = new KahaPersistenceAdapter();
answer.setPersistenceAdapter(adaptor);
answer.addConnector(bindAddress);
answer.addConnector(uri);
answer.setDeleteAllMessagesOnStartup(true);
}
public void testMemory() throws Exception {
if (broker == null) {
broker = createBroker();
broker = createBroker(bindAddress);
}
factory = createConnectionFactory();
factory = createConnectionFactory(bindAddress);
Connection con = factory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationName);

View File

@ -0,0 +1,48 @@
/**
* 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.perf;
import javax.jms.ConnectionFactory;
import javax.jms.DeliveryMode;
import javax.jms.Destination;
import javax.jms.JMSException;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.network.NetworkConnector;
public class SimpleDurableTopicNetworkTest extends SimpleNetworkTest {
protected void setUp() throws Exception {
numberofProducers=6;
numberOfConsumers=6;
samepleCount=100;
playloadSize = 1;
super.setUp();
}
protected PerfProducer createProducer(ConnectionFactory fac, Destination dest, int number, byte payload[]) throws JMSException {
PerfProducer pp = new PerfProducer(fac, dest, payload);
pp.setDeliveryMode(DeliveryMode.PERSISTENT);
return pp;
}
protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException {
return new PerfConsumer(fac, dest, "subs:" + number);
}
}

View File

@ -0,0 +1,125 @@
/**
* 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.perf;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Session;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.network.NetworkConnector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import junit.framework.TestCase;
public class SimpleNetworkTest extends SimpleTopicTest {
private static final Log LOG = LogFactory.getLog(SimpleNetworkTest.class);
protected String consumerBindAddress = "tcp://localhost:61616";
protected String producerBindAddress = "tcp://localhost:61617";
protected static final String CONSUMER_BROKER_NAME = "Consumer";
protected static final String PRODUCER_BROKER_NAME = "Producer";
protected BrokerService consumerBroker;
protected BrokerService producerBroker;
protected ConnectionFactory consumerFactory;
protected ConnectionFactory producerFactory;
protected void setUp() throws Exception {
if (consumerBroker == null) {
consumerBroker = createConsumerBroker(consumerBindAddress);
}
if (producerBroker == null) {
producerBroker = createProducerBroker(producerBindAddress);
}
consumerFactory = createConnectionFactory("vm://"+CONSUMER_BROKER_NAME);
producerFactory = createConnectionFactory("vm://"+ PRODUCER_BROKER_NAME);
//consumerFactory = createConnectionFactory(consumerBindAddress);
//producerFactory = createConnectionFactory(producerBindAddress);
Connection con = consumerFactory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationName);
LOG.info("Testing against destination: " + destination);
LOG.info("Running " + numberofProducers + " producer(s) and " + numberOfConsumers + " consumer(s)");
con.close();
producers = new PerfProducer[numberofProducers];
consumers = new PerfConsumer[numberOfConsumers];
for (int i = 0; i < numberOfConsumers; i++) {
consumers[i] = createConsumer(consumerFactory, destination, i);
consumers[i].setSleepDuration(consumerSleepDuration);
}
for (int i = 0; i < numberofProducers; i++) {
array = new byte[playloadSize];
for (int j = i; j < array.length; j++) {
array[j] = (byte)j;
}
producers[i] = createProducer(producerFactory, destination, i, array);
}
}
protected void tearDown() throws Exception {
for (int i = 0; i < numberOfConsumers; i++) {
consumers[i].shutDown();
}
for (int i = 0; i < numberofProducers; i++) {
producers[i].shutDown();
}
if (producerBroker != null) {
producerBroker.stop();
producerBroker = null;
}
if (consumerBroker != null) {
consumerBroker.stop();
consumerBroker = null;
}
}
protected BrokerService createConsumerBroker(String uri) throws Exception {
BrokerService answer = new BrokerService();
configureConsumerBroker(answer,uri);
answer.start();
return answer;
}
protected void configureConsumerBroker(BrokerService answer,String uri) throws Exception {
answer.setPersistent(false);
answer.setBrokerName(CONSUMER_BROKER_NAME);
answer.setDeleteAllMessagesOnStartup(true);
answer.addConnector(uri);
answer.setUseShutdownHook(false);
}
protected BrokerService createProducerBroker(String uri) throws Exception {
BrokerService answer = new BrokerService();
configureProducerBroker(answer,uri);
answer.start();
return answer;
}
protected void configureProducerBroker(BrokerService answer,String uri) throws Exception {
answer.setBrokerName(PRODUCER_BROKER_NAME);
answer.setDeleteAllMessagesOnStartup(true);
NetworkConnector connector = answer.addNetworkConnector("static://"+consumerBindAddress);
connector.setDuplex(true);
answer.addConnector(uri);
answer.setUseShutdownHook(false);
}
}

View File

@ -28,5 +28,10 @@ public class SimpleQueueTest extends SimpleTopicTest {
protected Destination createDestination(Session s, String destinationName) throws JMSException {
return s.createQueue(destinationName);
}
protected void setUp() throws Exception {
this.consumerSleepDuration=2000;
super.setUp();
}
}

View File

@ -61,9 +61,9 @@ public class SimpleTopicTest extends TestCase {
*/
protected void setUp() throws Exception {
if (broker == null) {
broker = createBroker();
broker = createBroker(bindAddress);
}
factory = createConnectionFactory();
factory = createConnectionFactory(bindAddress);
Connection con = factory.createConnection();
Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
destination = createDestination(session, destinationName);
@ -109,9 +109,9 @@ public class SimpleTopicTest extends TestCase {
*
* @throws Exception
*/
protected BrokerService createBroker() throws Exception {
protected BrokerService createBroker(String uri) throws Exception {
BrokerService answer = new BrokerService();
configureBroker(answer);
configureBroker(answer,uri);
answer.start();
return answer;
}
@ -123,15 +123,16 @@ public class SimpleTopicTest extends TestCase {
protected PerfConsumer createConsumer(ConnectionFactory fac, Destination dest, int number) throws JMSException {
return new PerfConsumer(fac, dest);
}
protected void configureBroker(BrokerService answer) throws Exception {
answer.addConnector(bindAddress);
protected void configureBroker(BrokerService answer,String uri) throws Exception {
answer.setDeleteAllMessagesOnStartup(true);
answer.addConnector(uri);
answer.setUseShutdownHook(false);
}
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
return new ActiveMQConnectionFactory(bindAddress);
protected ActiveMQConnectionFactory createConnectionFactory(String uri) throws Exception {
return new ActiveMQConnectionFactory(uri);
}
public void testPerformance() throws JMSException, InterruptedException {

View File

@ -66,7 +66,7 @@ public class SlowConsumerTopicTest extends SimpleTopicTest {
}
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
ActiveMQConnectionFactory result = super.createConnectionFactory();
ActiveMQConnectionFactory result = super.createConnectionFactory(bindAddress);
ActiveMQPrefetchPolicy policy = new ActiveMQPrefetchPolicy();
policy.setTopicPrefetch(1000);
result.setPrefetchPolicy(policy);