summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java10
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java12
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java24
-rw-r--r--java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java19
4 files changed, 37 insertions, 28 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java
index d2a376fff0..e7fe180d43 100644
--- a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java
+++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongBouncer.java
@@ -125,16 +125,12 @@ public class PingPongBouncer extends AbstractPingClient implements MessageListen
// Create a session to listen for messages on and one to send replies on, transactional depending on the
// command line option.
- Session consumerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
- Session producerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+ _consumerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
+ _producerSession = (Session) getConnection().createSession(transacted, Session.AUTO_ACKNOWLEDGE);
// Create the queue to listen for message on.
Queue q = new AMQQueue(queueName);
- MessageConsumer consumer = consumerSession.createConsumer(q, PREFETCH, NO_LOCAL, EXCLUSIVE, selector);
-
- // Hang on to the sessions for the messages and replies.
- _consumerSession = consumerSession;
- _producerSession = producerSession;
+ MessageConsumer consumer = _consumerSession.createConsumer(q, PREFETCH, NO_LOCAL, EXCLUSIVE, selector);
_verbose = verbose;
_persistent = persistent;
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 6956187b66..de8fbf9c39 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
@@ -215,7 +215,7 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
}
/**
- * Primes the test loop by sending a few messages, then introducing a short wait. This allows the bounce back client
+ * 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
* this a few times, in order to prime the JVMs JIT compilation.
*
@@ -309,6 +309,11 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
String messageCorrelationId = Long.toString(idGenerator.incrementAndGet());
message.setJMSCorrelationID(messageCorrelationId);
+ // Create a count down latch to count the number of replies with. This is created before the message is sent
+ // so that the message is not received before the count down is created.
+ CountDownLatch trafficLight = new CountDownLatch(numPings);
+ trafficLights.put(messageCorrelationId, trafficLight);
+
for (int i = 0; i < numPings; i++)
{
// Re-timestamp the message.
@@ -323,17 +328,12 @@ public class PingPongProducer extends AbstractPingProducer implements Runnable,
// Keep the messageId to correlate with the reply.
//String messageId = message.getJMSMessageID();
-
if (_verbose)
{
_logger.info(timestampFormatter.format(new Date()) + ": Pinged at with correlation id, " + messageCorrelationId);
}
// Block the current thread until a reply to the message is received, or it times out.
- CountDownLatch trafficLight = new CountDownLatch(numPings);
- trafficLights.put(messageCorrelationId, trafficLight);
-
- // Note that this call expects a timeout in nanoseconds, millisecond timeout is multiplied up.
trafficLight.await(timeout, TimeUnit.MILLISECONDS);
// Work out how many replies were receieved.
diff --git a/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java b/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
index 3576a088d7..4b42283023 100644
--- a/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
+++ b/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
@@ -10,13 +10,25 @@ import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.apache.log4j.NDC;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.jms.Connection;
-import org.apache.qpid.jms.MessageProducer;
-import org.apache.qpid.jms.Session;
-
/**
+ *
+ * PingTestPerf is a ping test, that has been written with the intention of being scaled up to run many times
+ * simultaneously to simluate many clients/producers/connections.
+ *
+ * <p/>A single run of the test using the default JUnit test runner will result in the sending and timing of a single
+ * full round trip ping. This test may be scaled up using a suitable JUnit test runner. See {@link TKTestRunner} or
+ * {@link PPTestRunner} for more information on how to do this.
+ *
+ * <p/>The setup/teardown cycle establishes a connection to a broker and sets up a queue to send ping messages to and a
+ * temporary queue for replies. This setup is only established once for all the test repeats/threads that may be run,
+ * except if the connection is lost in which case an attempt to re-establish the setup is made.
+ *
+ * <p/>The test cycle is: Connects to a queue, creates a temporary queue, creates messages containing a property that
+ * is the name of the temporary queue, fires off a message on the original queue and waits for a response on the
+ * temporary queue.
+ *
+ * <p/>Configurable test properties: message size, transacted or not, persistent or not. Broker connection details.
+ *
* <p><table id="crc"><caption>CRC Card</caption>
* <tr><th> Responsibilities <th> Collaborations
* </table>
diff --git a/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java b/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
index 2d0ee86b29..bd1c1baad4 100644
--- a/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
+++ b/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
@@ -16,20 +16,21 @@ import uk.co.thebadgerset.junit.extensions.AsymptoticTestCase;
/**
* PingPongTestPerf is a full round trip ping test, that has been written with the intention of being scaled up to run
- * many times simultaneously. A full round trip ping sends a message from a producer to a conumer, then the consumer
- * replies to the message on a temporary queue.
+ * many times simultaneously to simluate many clients/producer/connections. A full round trip ping sends a message from
+ * a producer to a conumer, then the consumer replies to the message on a temporary queue.
*
- * <p/>A single run of the test using the default JUnit test runner will result in the sending and timing of a single
- * full round trip ping. This test may be scaled up using a suitable JUnit test runner. See {@link TKTestRunner} or
- * {@link PPTestRunner} for more information on how to do this.
+ * <p/>A single run of the test using the default JUnit test runner will result in the sending and timing of the number
+ * of pings specified by the test size and time how long it takes for all of these to complete. This test may be scaled
+ * up using a suitable JUnit test runner. See {@link TKTestRunner} or {@link PPTestRunner} for more information on how
+ * to do this.
*
* <p/>The setup/teardown cycle establishes a connection to a broker and sets up a queue to send ping messages to and a
- * temporary queue for replies. This setup is only established once for all the test repeats/threads that may be run,
- * except if the connection is lost in which case an attempt to re-establish the setup is made.
+ * temporary queue for replies. This setup is only established once for all the test repeats, but each test threads
+ * gets its own connection/producer/consumer, this is only re-established if the connection is lost.
*
* <p/>The test cycle is: Connects to a queue, creates a temporary queue, creates messages containing a property that
- * is the name of the temporary queue, fires off a message on the original queue and waits for a response on the
- * temporary queue.
+ * is the name of the temporary queue, fires off many messages on the original queue and waits for them all to come
+ * back on the temporary queue.
*
* <p/>Configurable test properties: message size, transacted or not, persistent or not. Broker connection details.
*