diff options
author | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-01-24 16:14:36 +0000 |
---|---|---|
committer | Bhupendra Bhusman Bhardwaj <bhupendrab@apache.org> | 2007-01-24 16:14:36 +0000 |
commit | 8e9e60370dba3439ac1f448d300335fce66c3be5 (patch) | |
tree | e80920ffece9132a7a729e091f9cc895a62559ba | |
parent | 50cdee9303a9c5aabdbc905e96b3092750cedfe4 (diff) | |
download | qpid-python-8e9e60370dba3439ac1f448d300335fce66c3be5.tar.gz |
added some constant values
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@499461 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java | 33 | ||||
-rw-r--r-- | java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java | 75 |
2 files changed, 63 insertions, 45 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java b/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java index e7515b0f78..acb0135b86 100644 --- a/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java +++ b/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java @@ -20,13 +20,11 @@ package org.apache.qpid.ping; import javax.jms.JMSException; import javax.jms.MessageConsumer; import javax.jms.ObjectMessage; -import javax.jms.MessageListener; import org.apache.log4j.Logger; import org.apache.qpid.requestreply.PingPongProducer; import org.apache.qpid.topic.Config; -import org.apache.qpid.util.concurrent.BooleanLatch; /** * This class is used to test sending and receiving messages to (pingQueue) and from a queue (replyQueue). @@ -72,7 +70,7 @@ public class TestPingItself extends PingPongProducer messageSize, verbose, afterCommit, beforeCommit, afterSend, beforeSend, failOnce, batchSize, noOfDestinations, rate, pubsub); - if (noOfDestinations > 0) + if (noOfDestinations > DEFAULT_DESTINATION_COUNT) { createDestinations(noOfDestinations); _persistent = persistent; @@ -119,9 +117,9 @@ public class TestPingItself extends PingPongProducer boolean persistent = config.usePersistentMessages(); int messageSize = (config.getPayload() != 0) ? config.getPayload() : DEFAULT_MESSAGE_SIZE; int messageCount = config.getMessages(); - int destCount = (config.getDestinationsCount() != 0) ? config.getDestinationsCount() : 1; - int batchSize = (config.getBatchSize() != 0) ? config.getBatchSize() : BATCH_SIZE; - int rate = (config.getRate() != 0) ? config.getRate() : 0; + int destCount = (config.getDestinationsCount() != 0) ? config.getDestinationsCount() : DEFAULT_DESTINATION_COUNT; + int batchSize = (config.getBatchSize() != 0) ? config.getBatchSize() : DEFAULT_BATCH_SIZE; + int rate = (config.getRate() != 0) ? config.getRate() : DEFAULT_RATE; boolean pubsub = config.isPubSub(); String destName = config.getDestination(); @@ -129,16 +127,6 @@ public class TestPingItself extends PingPongProducer { destName = PING_DESTINATION_NAME; } - if (destCount > 1) - { - _logger.info("Destination Count:" + destCount + ", Transacted:" + transacted + ", persistent:" + - persistent + ",Message Size:" + messageSize + " bytes, pubsub:" + pubsub); - } - else - { - _logger.info("Destination:" + destName + ", Transacted:" + transacted + ", persistent:" + - persistent + ",Message Size:" + messageSize + " bytes, pubsub:" + pubsub); - } boolean afterCommit = false; boolean beforeCommit = false; @@ -193,17 +181,16 @@ public class TestPingItself extends PingPongProducer // Ensure that the ping pong producer is registered to listen for exceptions on the connection too. pingItself.getConnection().setExceptionListener(pingItself); - if ((destCount > 1) || (messageCount > 0)) + if ((destCount > DEFAULT_DESTINATION_COUNT) || (messageCount > 0)) { - ObjectMessage msg = pingItself.getTestMessage(null, messageSize, persistent); - - // Send the message and wait for a reply. - int numReplies = pingItself.pingAndWaitForReply(msg, messageCount, TIMEOUT); - - _logger.info(("Messages Sent = " + messageCount + ", MessagesReceived = " + numReplies)); + _logger.info("Destinations Count:" + destCount + ", Transacted:" + transacted + ", persistent:" + + persistent + ",Message Size:" + messageSize + " bytes, pubsub:" + pubsub); + pingItself.pingLoop(); } else { + _logger.info("Destination:" + destName + ", Transacted:" + transacted + ", persistent:" + + persistent + ",Message Size:" + messageSize + " bytes, pubsub:" + pubsub); // set the message count to 0 to run this loop // Run a few priming pings to remove warm up time from test results. pingItself.prime(PRIMING_LOOPS); diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java index da63a6ae96..be46c1805b 100644 --- a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java +++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java @@ -40,6 +40,7 @@ import org.apache.qpid.jms.MessageProducer; import org.apache.qpid.jms.Session;
import org.apache.qpid.ping.AbstractPingProducer;
import org.apache.qpid.ping.Throttle;
+import org.apache.qpid.topic.Config;
/**
* PingPongProducer is a client that sends pings to a queue and waits for pongs to be bounced back by a bounce back
@@ -75,6 +76,11 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, */
protected static final int DEFAULT_MESSAGE_SIZE = 0;
+ /** This is set and used when the test is for multiple-destinations */
+ protected static final int DEFAULT_DESTINATION_COUNT = 0;
+
+ protected static final int DEFAULT_RATE = 0;
+
/**
* Used to define how long to wait between pings.
*/
@@ -93,7 +99,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, /**
* The batch size.
*/
- protected static final int BATCH_SIZE = 100;
+ protected static final int DEFAULT_BATCH_SIZE = 100;
protected static final int PREFETCH = 100;
protected static final boolean NO_LOCAL = true;
@@ -187,7 +193,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, // total rate = throttle rate * batch size.
// 1 < throttle rate < 100
// 1 < total rate < 20000
- if (rate > 0)
+ if (rate > DEFAULT_RATE)
{
// Log base 10 over 2 is used here to get a feel for what power of 100 the total rate is.
// As the total rate goes up the powers of 100 the batch size goes up by powers of 100 to keep the
@@ -228,7 +234,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, _destinationCount = noOfDestinations;
setPubSub(pubsub);
- if (noOfDestinations == 0)
+ if (noOfDestinations == DEFAULT_DESTINATION_COUNT)
{
if (destinationName != null)
{
@@ -265,7 +271,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, */
public void createProducer() throws JMSException
{
- if (getDestinationsCount() > 1)
+ if (getDestinationsCount() > DEFAULT_DESTINATION_COUNT)
{
// create producer with initial destination as null for test with multiple-destinations
// In this case, a different destination will be used while sending the message
@@ -354,23 +360,33 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, public static void main(String[] args) throws Exception
{
// Extract the command line.
- if (args.length < 2)
+ Config config = new Config();
+ config.setOptions(args);
+ if (args.length == 0)
{
- System.err.println("Usage: TestPingPublisher <brokerDetails> <virtual path> [verbose (true/false)] " +
- "[transacted (true/false)] [persistent (true/false)] [message size in bytes] [batchsize]" +
- " [rate] [pubsub(true/false)]");
- System.exit(0);
+ _logger.info("Running test with default values...");
+ //usage();
+ //System.exit(0);
}
- String brokerDetails = args[0];
- String virtualpath = args[1];
- boolean verbose = (args.length >= 3) ? Boolean.parseBoolean(args[2]) : true;
- boolean transacted = (args.length >= 4) ? Boolean.parseBoolean(args[3]) : false;
- boolean persistent = (args.length >= 5) ? Boolean.parseBoolean(args[4]) : false;
- int messageSize = (args.length >= 6) ? Integer.parseInt(args[5]) : DEFAULT_MESSAGE_SIZE;
- int batchSize = (args.length >= 7) ? Integer.parseInt(args[6]) : 1;
- int rate = (args.length >= 8) ? Integer.parseInt(args[7]) : 0;
- boolean ispubsub = (args.length >= 9) ? Boolean.parseBoolean(args[8]) : false;
+ String brokerDetails = config.getHost() + ":" + config.getPort();
+ String virtualpath = "/test";
+ String selector = config.getSelector();
+ boolean verbose = true;
+ boolean transacted = config.isTransacted();
+ boolean persistent = config.usePersistentMessages();
+ int messageSize = (config.getPayload() != 0) ? config.getPayload() : DEFAULT_MESSAGE_SIZE;
+ //int messageCount = config.getMessages();
+ int destCount = (config.getDestinationsCount() != 0) ? config.getDestinationsCount() : DEFAULT_DESTINATION_COUNT;
+ int batchSize = (config.getBatchSize() != 0) ? config.getBatchSize() : DEFAULT_BATCH_SIZE;
+ int rate = (config.getRate() != 0) ? config.getRate() : DEFAULT_RATE;
+ boolean pubsub = config.isPubSub();
+
+ String destName = config.getDestination();
+ if (destName == null)
+ {
+ destName = PING_DESTINATION_NAME;
+ }
boolean afterCommit = false;
boolean beforeCommit = false;
@@ -412,9 +428,9 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, // Create a ping producer to handle the request/wait/reply cycle.
PingPongProducer pingProducer = new PingPongProducer(brokerDetails, "guest", "guest", virtualpath,
- PING_DESTINATION_NAME, null, transacted, persistent, messageSize, verbose,
+ destName, selector, transacted, persistent, messageSize, verbose,
afterCommit, beforeCommit, afterSend, beforeSend, failOnce, batchSize,
- 0, rate, ispubsub);
+ destCount, rate, pubsub);
pingProducer.getConnection().start();
@@ -432,6 +448,21 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, pingThread.join();
}
+ private static void usage()
+ {
+ System.err.println("Usage: TestPingPublisher \n" + "-host : broker host" + "-port : broker port" +
+ "-destinationname : queue/topic name\n" +
+ "-transacted : (true/false). Default is false\n" +
+ "-persistent : (true/false). Default is false\n" +
+ "-pubsub : (true/false). Default is false\n" +
+ "-selector : selector string\n" +
+ "-payload : paylaod size. Default is 0\n" +
+ //"-messages : no of messages to be sent (if 0, the ping loop will run indefinitely)\n" +
+ "-destinationscount : no of destinations for multi-destinations test\n" +
+ "-batchsize : batch size\n" +
+ "-rate : thruput rate\n");
+ }
+
/**
* Primes the test loop by sending a few messages, then introduces a short wait. This allows the bounce back client
* on the other end a chance to configure its reply producer on the reply to destination. It is also worth calling
@@ -605,7 +636,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, // Check if the test is with multiple-destinations, in which case round robin the destinations
// as the messages are sent.
- if (getDestinationsCount() > 1)
+ if (getDestinationsCount() > DEFAULT_DESTINATION_COUNT)
{
sendMessage(getDestination(i % getDestinationsCount()), message);
}
@@ -656,7 +687,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable, msg.setLongProperty("timestamp", System.currentTimeMillis());
// Send the message and wait for a reply.
- pingAndWaitForReply(msg, BATCH_SIZE, TIMEOUT);
+ pingAndWaitForReply(msg, DEFAULT_BATCH_SIZE, TIMEOUT);
// Introduce a short pause if desired.
pause(SLEEP_TIME);
|