From d25455fd0d6820f30dd515a3484fb33446a17fed Mon Sep 17 00:00:00 2001 From: Robert Greig Date: Fri, 30 Mar 2007 11:51:09 +0000 Subject: Removed excess logging to optimize performance. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2@524050 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/ping/PingDurableClient.java | 29 +++++++++++++ .../apache/qpid/requestreply/PingPongProducer.java | 49 ++++++++++++---------- .../org/apache/qpid/ping/PingAsyncTestPerf.java | 4 +- 3 files changed, 58 insertions(+), 24 deletions(-) (limited to 'java/perftests/src') diff --git a/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java b/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java index 77526141d6..7afa893e5f 100644 --- a/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java +++ b/java/perftests/src/main/java/org/apache/qpid/ping/PingDurableClient.java @@ -284,6 +284,9 @@ public class PingDurableClient extends PingPongProducer implements ExceptionList } catch (JMSException e) { + log.debug("There was an error whilst closing the connection: " + e, e); + System.out.println("There was an error whilst closing the connection."); + // Ignore as did best could manage to clean up. } @@ -329,6 +332,32 @@ public class PingDurableClient extends PingPongProducer implements ExceptionList } } + // Ensure messages received are committed. + if (_transacted) + { + try + { + _consumerSession.commit(); + System.out.println("Committed for all messages received."); + } + catch (JMSException e) + { + log.debug("Error during commit: " + e, e); + System.out.println("Error during commit."); + try + { + _consumerSession.rollback(); + System.out.println("Rolled back on all messages received."); + } + catch (JMSException e2) + { + log.debug("Error during rollback: " + e, e); + System.out.println("Error on roll back of all messages received."); + } + + } + } + log.debug("messagesReceived = " + messagesReceived); System.out.println("Messages received: " + messagesReceived); 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 44f7083bb5..3afff6f7d1 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 @@ -118,7 +118,7 @@ import uk.co.thebadgerset.junit.extensions.util.ParsedProperties; * by the PPP that it is atteched to. * * @todo Use read/write lock in the onmessage, not for reading writing but to make use of a shared and exlcusive lock pair. - * Obtian read lock on all messages, before decrementing the message count. At the end of the on message method add a + * Obtain read lock on all messages, before decrementing the message count. At the end of the on message method add a * block that obtains the write lock for the very last message, releases any waiting producer. Means that the last * message waits until all other messages have been handled before releasing producers but allows messages to be * processed concurrently, unlike the current synchronized block. @@ -737,6 +737,8 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis log.debug("public void createReplyConsumers(Collection destinations = " + destinations + ", String selector = " + selector + "): called"); + log.debug("Creating " + destinations.size() + " reply consumers."); + for (Destination destination : destinations) { // Create a consumer for the destination and set this pinger to listen to its messages. @@ -744,6 +746,8 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis _consumerSession.createConsumer(destination, PREFETCH_DEFAULT, NO_LOCAL_DEFAULT, EXCLUSIVE_DEFAULT, selector); _consumer.setMessageListener(this); + + log.debug("Set this to listen to replies sent to destination: " + destination); } } @@ -755,13 +759,13 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis */ public void onMessage(Message message) { - log.debug("public void onMessage(Message message): called"); + // log.debug("public void onMessage(Message message): called"); try { // Extract the messages correlation id. String correlationID = message.getJMSCorrelationID(); - log.debug("correlationID = " + correlationID); + // log.debug("correlationID = " + correlationID); // Countdown on the traffic light if there is one for the matching correlation id. PerCorrelationId perCorrelationId = perCorrelationIds.get(correlationID); @@ -773,7 +777,7 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis // Restart the timeout timer on every message. perCorrelationId.timeOutStart = System.nanoTime(); - log.debug("Reply was expected, decrementing the latch for the id, " + correlationID); + // log.debug("Reply was expected, decrementing the latch for the id, " + correlationID); // Decrement the countdown latch. Before this point, it is possible that two threads might enter this // method simultanesouly with the same correlation id. Decrementing the latch in a synchronized block @@ -788,8 +792,8 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis trueCount = trafficLight.getCount(); remainingCount = trueCount - 1; - log.debug("remainingCount = " + remainingCount); - log.debug("trueCount = " + trueCount); + // log.debug("remainingCount = " + remainingCount); + // log.debug("trueCount = " + trueCount); // Commit on transaction batch size boundaries. At this point in time the waiting producer remains // blocked, even on the last message. @@ -818,23 +822,23 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis } // Print out ping times for every message in verbose mode only. - if (_verbose) + /*if (_verbose) { Long timestamp = message.getLongProperty(MESSAGE_TIMESTAMP_PROPNAME); if (timestamp != null) { long diff = System.nanoTime() - timestamp; - log.trace("Time for round trip (nanos): " + diff); + //log.trace("Time for round trip (nanos): " + diff); } - } + }*/ } catch (JMSException e) { log.warn("There was a JMSException: " + e.getMessage(), e); } - log.debug("public void onMessage(Message message): ending"); + // log.debug("public void onMessage(Message message): ending"); } /** @@ -1188,6 +1192,7 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis if (_connection != null) { _connection.close(); + log.debug("Close connection."); } } finally @@ -1225,20 +1230,20 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis */ protected boolean commitTx(Session session) throws JMSException { - log.debug("protected void commitTx(Session session): called"); + // log.debug("protected void commitTx(Session session): called"); boolean committed = false; - log.trace("Batch time reached"); + // log.trace("Batch time reached"); if (_failAfterSend) { - log.trace("Batch size reached"); + // log.trace("Batch size reached"); if (_failOnce) { _failAfterSend = false; } - log.trace("Failing After Send"); + // log.trace("Failing After Send"); waitForUser(KILL_BROKER_PROMPT); } @@ -1253,14 +1258,14 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis _failBeforeCommit = false; } - log.trace("Failing Before Commit"); + // log.trace("Failing Before Commit"); waitForUser(KILL_BROKER_PROMPT); } - long l = System.nanoTime(); + // long l = System.nanoTime(); session.commit(); committed = true; - log.debug("Time taken to commit :" + ((System.nanoTime() - l) / 1000000f) + " ms"); + // log.debug("Time taken to commit :" + ((System.nanoTime() - l) / 1000000f) + " ms"); if (_failAfterCommit) { @@ -1269,15 +1274,15 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis _failAfterCommit = false; } - log.trace("Failing After Commit"); + // log.trace("Failing After Commit"); waitForUser(KILL_BROKER_PROMPT); } - log.trace("Session Commited."); + // log.trace("Session Commited."); } catch (JMSException e) { - log.trace("JMSException on commit:" + e.getMessage(), e); + log.debug("JMSException on commit:" + e.getMessage(), e); // Warn that the bounce back client is not available. if (e.getLinkedException() instanceof AMQNoConsumersException) @@ -1288,11 +1293,11 @@ public class PingPongProducer implements Runnable, MessageListener, ExceptionLis try { session.rollback(); - log.trace("Message rolled back."); + log.debug("Message rolled back."); } catch (JMSException jmse) { - log.trace("JMSE on rollback:" + jmse.getMessage(), jmse); + log.debug("JMSE on rollback:" + jmse.getMessage(), jmse); // Both commit and rollback failed. Throw the rollback exception. throw jmse; diff --git a/java/perftests/src/test/java/org/apache/qpid/ping/PingAsyncTestPerf.java b/java/perftests/src/test/java/org/apache/qpid/ping/PingAsyncTestPerf.java index 3b8e670f8f..9c24ea0379 100644 --- a/java/perftests/src/test/java/org/apache/qpid/ping/PingAsyncTestPerf.java +++ b/java/perftests/src/test/java/org/apache/qpid/ping/PingAsyncTestPerf.java @@ -246,9 +246,9 @@ public class PingAsyncTestPerf extends PingTestPerf implements TimingControllerA // Extract the correlation id from the message. String correlationId = message.getJMSCorrelationID(); - _logger.debug("public void onMessage(Message message, int remainingCount = " + remainingCount + /*_logger.debug("public void onMessage(Message message, int remainingCount = " + remainingCount + "): called on batch boundary for message id: " + correlationId + " with thread id: " - + Thread.currentThread().getId()); + + Thread.currentThread().getId());*/ // Get the details for the correlation id and check that they are not null. They can become null // if a test times out. -- cgit v1.2.1