You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by bh...@apache.org on 2007/01/12 10:43:10 UTC

svn commit: r495532 - in /incubator/qpid/trunk/qpid/java/perftests: bin/ src/main/java/ src/main/java/org/apache/qpid/requestreply/

Author: bhupendrab
Date: Fri Jan 12 01:43:09 2007
New Revision: 495532

URL: http://svn.apache.org/viewvc?view=rev&rev=495532
Log:
Adding a volume test script(volumetestServiceRequestingClient.sh) 
This script checks if all the messages were sent received back successfully.  ServiceRequestingClient.java and ServiceProvidingClient.java modified to add a message identifier to match the request and response message. log4j file modified to create a log file

Added:
    incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh   (with props)
Modified:
    incubator/qpid/trunk/qpid/java/perftests/bin/serviceRequestingClient.sh
    incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceProvidingClient.java
    incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java
    incubator/qpid/trunk/qpid/java/perftests/src/main/java/perftests.log4j

Modified: incubator/qpid/trunk/qpid/java/perftests/bin/serviceRequestingClient.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/bin/serviceRequestingClient.sh?view=diff&rev=495532&r1=495531&r2=495532
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/bin/serviceRequestingClient.sh (original)
+++ incubator/qpid/trunk/qpid/java/perftests/bin/serviceRequestingClient.sh Fri Jan 12 01:43:09 2007
@@ -30,4 +30,4 @@
 # XXX -Xms1024m -XX:NewSize=300m
 . ./setupclasspath.sh
 echo $CP
-$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.requestreply.ServiceRequestingClient $thehosts guest guest /test serviceQ P T "$@"
+$JAVA_HOME/bin/java -cp $CP -Damqj.logging.level="warn" -Dlog.dir="$QPID_HOME/logs" -Damqj.test.logging.level="info" -Dlog4j.configuration=perftests.log4j org.apache.qpid.requestreply.ServiceRequestingClient $thehosts guest guest /test serviceQ P T "$@"

Added: incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh?view=auto&rev=495532
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh (added)
+++ incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh Fri Jan 12 01:43:09 2007
@@ -0,0 +1,115 @@
+#!/bin/bash
+#
+# 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.
+#
+
+if [[ $# < 3 ]] ; then
+ echo "usage: ./volumetestServiceRequestingClient.sh <brokerdetails> <logfile full path> <number of messages> [<message size 4096b default>]"
+ exit 1
+fi
+
+thehosts=$1
+logname=$2
+messageCount=$3
+messageSize=$4
+
+## create the log dir
+if [ ! -d $QPID_HOME/logs ]; then
+    echo "hello"
+    mkdir $QPID_HOME/logs
+fi
+
+echo "********** Running the test **************"
+echo "..."
+echo
+./serviceRequestingClient.sh $thehosts $messageCount $messageSize
+## check for the status of test execution
+if [ $? -ne 0 ]; then
+    exit 1;
+fi
+
+LOGFILE=$logname
+FILE_SENT=$QPID_HOME/logs/sentMessageItedifiers.txt
+FILE_RECEIVED=$QPID_HOME/logs/receivedMessageItedifiers.txt
+
+echo
+## check if the logfile is present
+if [ ! -f $LOGFILE ]; then
+    echo "logfile $LOGFILE does not exist"
+    echo "please check the logfile path in log4j config file for serviceRequestingClient"
+    exit 1;
+fi
+
+## delete the old files
+if [ -f $FILE_SENT ]; then
+    rm $FILE_SENT
+fi
+
+if [ -f $FILE_RECEIVED ]; then
+    rm $FILE_RECEIVED
+fi
+
+##echo "logfile=$LOGFILE"
+echo "************* Analyzing the log *************"
+echo "..."
+
+n=`wc -l < $LOGFILE`
+i=1
+while [ "$i" -le "$n" ]
+do
+    ## get the sent and received message identifiers
+    line=`cat $LOGFILE | head -$i | tail -1`
+    `echo $line | grep "Sent Message Identifier" |cut -d" " -f4 >> $FILE_SENT`
+    `echo $line | grep "Received Message Identifier" |cut -d" " -f4 >> $FILE_RECEIVED`
+    
+    ##show if any exception
+    line=`echo $line | grep "Exception"`
+    if [ `echo $line | wc -w` -gt 0  ]; then
+        echo "Exception occured:"
+        echo $line
+    fi
+    
+    i=`expr $i + 1`
+done
+
+
+
+## get the message identifiers, which are sent but not received back
+notReceivedMessageCount=`comm -23 $FILE_SENT $FILE_RECEIVED | wc -l`
+
+echo
+echo "**** Result ****"
+messagesSent=`cat $FILE_SENT | wc -l`
+echo "$messagesSent messages were sent"
+
+if [ $notReceivedMessageCount -gt 0 ];
+then
+    echo "Total $notReceivedMessageCount messages not received back"
+    echo "please check the log $LOGFILE for errors";
+else
+    echo "$messagesSent messages were sent and received back successfully"
+fi
+
+## delete the temp files created
+if [ -f $FILE_SENT ]; then
+    rm $FILE_SENT
+fi
+
+if [ -f $FILE_RECEIVED ]; then
+    rm $FILE_RECEIVED
+fi

Propchange: incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/trunk/qpid/java/perftests/bin/volumetestServiceRequestingClient.sh
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceProvidingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceProvidingClient.java?view=diff&rev=495532&r1=495531&r2=495532
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceProvidingClient.java (original)
+++ incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceProvidingClient.java Fri Jan 12 01:43:09 2007
@@ -21,11 +21,11 @@
 package org.apache.qpid.requestreply;
 
 import org.apache.log4j.Logger;
+import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.jms.Session;
 import org.apache.qpid.jms.ConnectionListener;
-import org.apache.qpid.AMQException;
+import org.apache.qpid.jms.Session;
 import org.apache.qpid.url.URLSyntaxException;
 
 import javax.jms.*;
@@ -35,7 +35,7 @@
 public class ServiceProvidingClient
 {
     private static final Logger _logger = Logger.getLogger(ServiceProvidingClient.class);
-
+    private static final String MESSAGE_IDENTIFIER = "MessageIdentifier";
     private MessageProducer _destinationProducer;
 
     private Destination _responseDest;
@@ -102,9 +102,7 @@
             public void onMessage(Message message)
             {
                 //_logger.info("Got message '" + message + "'");
-
                 TextMessage tm = (TextMessage) message;
-
                 try
                 {
                     Destination responseDest = tm.getJMSReplyTo();
@@ -147,6 +145,12 @@
                         _logger.info("timeSent value is: " + timesent);
                         msg.setLongProperty("timeSent", timesent);
                     }
+                    // this identifier set in the serviceRequestingClient is used to match the response with the request
+                    if (tm.propertyExists(MESSAGE_IDENTIFIER))
+                    {
+                        msg.setIntProperty(MESSAGE_IDENTIFIER, tm.getIntProperty(MESSAGE_IDENTIFIER));
+                    }
+                    
                     _destinationProducer.send(msg);
 
 					if(_isTransactional)
@@ -182,7 +186,8 @@
 
         if (args.length < 7)
         {
-            System.out.println("Usage: brokerDetails username password virtual-path serviceQueue <P[ersistent]|N[onPersistent]>  <T[ransacted]|N[onTransacted]> [selector]");
+            System.out.println("Usage: <brokerDetails> <username> <password> <virtual-path> <serviceQueue>" +
+                               " <P[ersistent]|N[onPersistent]>  <T[ransacted]|N[onTransacted]> [selector]");
             System.exit(1);
         }
         String clientId = null;
@@ -214,9 +219,6 @@
         {
             _logger.error("Error: " + e, e);
         }
-
-
-
     }
 
 }

Modified: incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java?view=diff&rev=495532&r1=495531&r2=495532
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java (original)
+++ incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/ServiceRequestingClient.java Fri Jan 12 01:43:09 2007
@@ -22,13 +22,14 @@
 
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
-import org.apache.qpid.url.URLSyntaxException;
 import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.message.TestMessageFactory;
 import org.apache.qpid.jms.MessageConsumer;
 import org.apache.qpid.jms.MessageProducer;
 import org.apache.qpid.jms.Session;
+import org.apache.qpid.url.URLSyntaxException;
 
 import javax.jms.*;
 import java.net.InetAddress;
@@ -46,8 +47,8 @@
 {
     private static final Logger _log = Logger.getLogger(ServiceRequestingClient.class);
 
-    private static final String MESSAGE_DATA_BYTES = "jfd ghljgl hjvhlj cvhvjf ldhfsj lhfdsjf hldsjfk hdslkfj hsdflk  ";
-
+    private static final String MESSAGE_IDENTIFIER = "MessageIdentifier";
+    private static int _messageIdentifier = 0;
     private String MESSAGE_DATA;
 
     private AMQConnection _connection;
@@ -68,24 +69,6 @@
 
     private Object _waiter;
 
-    private static String createMessagePayload(int size)
-    {
-        _log.info("Message size set to " + size + " bytes");
-        StringBuffer buf = new StringBuffer(size);
-        int count = 0;
-        while (count < size + MESSAGE_DATA_BYTES.length())
-        {
-            buf.append(MESSAGE_DATA_BYTES);
-            count += MESSAGE_DATA_BYTES.length();
-        }
-        if (count < size)
-        {
-            buf.append(MESSAGE_DATA_BYTES, 0, size - count);
-        }
-
-        return buf.toString();
-    }
-
     private class CallbackHandler implements MessageListener
     {
         private int _expectedMessageCount;
@@ -125,7 +108,11 @@
                         _log.info("Average latency now: " + _averageLatency);
                     }
                 }
-				if(_isTransactional)
+                if (m.propertyExists(MESSAGE_IDENTIFIER))
+                {
+                    _log.info("Received Message Identifier: " + m.getIntProperty(MESSAGE_IDENTIFIER));
+                }
+                if(_isTransactional)
                 {
                     _session.commit();
                 }
@@ -186,7 +173,7 @@
         _log.info("Delivery Mode: " + deliveryMode + "\t isTransactional: " + _isTransactional);
 
         _messageCount = messageCount;
-        MESSAGE_DATA = createMessagePayload(messageDataLength);
+        MESSAGE_DATA = TestMessageFactory.createMessagePayload(messageDataLength);
         try
         {
             createConnection(brokerHosts, clientID, username, password, vpath);
@@ -210,7 +197,7 @@
             //Send first message, then wait a bit to allow the provider to get initialised
             TextMessage first = _session.createTextMessage(MESSAGE_DATA);
             first.setJMSReplyTo(_tempDestination);
-            _producer.send(first);
+            send(first);
 			if(_isTransactional)
             {
                 _producerSession.commit();
@@ -234,6 +221,13 @@
         }
     }
 
+    private void send(TextMessage msg) throws JMSException
+    {
+        msg.setIntProperty(MESSAGE_IDENTIFIER, ++_messageIdentifier);
+        _producer.send(msg);
+        _log.info("Sent Message Identifier: " + _messageIdentifier);
+    }
+
     /**
      * Run the test and notify an object upon receipt of all responses.
      *
@@ -253,7 +247,7 @@
                 long timeNow = System.currentTimeMillis();
                 msg.setLongProperty("timeSent", timeNow);
             }
-            _producer.send(msg);
+            send(msg);
             if(_isTransactional)
             {
                 _producerSession.commit();
@@ -283,8 +277,9 @@
     {
         if (args.length < 9)
         {
-            System.err.println(
-                    "Usage: ServiceRequestingClient <brokerDetails - semicolon separated host:port list> <username> <password> <vpath> <command queue name> <P[ersistent]|N[onPersistent]>  <T[ransacted]|N[onTransacted]> <number of messages> <message size>");
+            System.err.println("Usage: ServiceRequestingClient <brokerDetails - semicolon separated host:port list>" +
+                               " <username> <password> <vpath> <command queue name> <P[ersistent]|N[onPersistent]>" +
+                               " <T[ransacted]|N[onTransacted]> <number of messages> <message size>");
             System.exit(1);
         }
         try
@@ -305,7 +300,6 @@
                     waiter.wait();
                 }
             }
-
         }
         catch (UnknownHostException e)
         {

Modified: incubator/qpid/trunk/qpid/java/perftests/src/main/java/perftests.log4j
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/perftests.log4j?view=diff&rev=495532&r1=495531&r2=495532
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/src/main/java/perftests.log4j (original)
+++ incubator/qpid/trunk/qpid/java/perftests/src/main/java/perftests.log4j Fri Jan 12 01:43:09 2007
@@ -22,10 +22,16 @@
 log4j.logger.org.apache.qpid=${amqj.logging.level}, console
 log4j.additivity.org.apache.qpid=false
 
-log4j.logger.org.apache.qpid.requestreply=${amqj.test.logging.level}
+log4j.logger.org.apache.qpid.requestreply=${amqj.test.logging.level}, fileApp
 log4j.logger.org.apache.qpid.pingpong=${amqj.test.logging.level}
 
 log4j.appender.console=org.apache.log4j.ConsoleAppender
 log4j.appender.console.Threshold=all
 log4j.appender.console.layout=org.apache.log4j.PatternLayout
 log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n
+
+log4j.appender.fileApp=org.apache.log4j.FileAppender
+log4j.appender.fileApp.file=${log.dir}/perftests.volumetest.log
+log4j.appender.fileApp.Threshold=info
+log4j.appender.fileApp.append=false
+log4j.appender.fileApp.layout=org.apache.log4j.PatternLayout