Author: ritchiem
Date: Tue Jan 23 02:55:00 2007
New Revision: 498984

URL: http://svn.apache.org/viewvc?view=rev&rev=498984
Log:
FailOver added flag FAIL_ONCE so that only the first call is stopped for 
failover.. the default.

Updated POM with Failover Tests

Modified:
    incubator/qpid/trunk/qpid/java/perftests/pom.xml
    
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/AbstractPingProducer.java
    
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java
    
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingProducer.java
    
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
    
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
    
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java

Modified: incubator/qpid/trunk/qpid/java/perftests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/pom.xml?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- incubator/qpid/trunk/qpid/java/perftests/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/perftests/pom.xml Tue Jan 23 02:55:00 2007
@@ -165,6 +165,12 @@
                  <!## Failover Tests. ##>
                  <FT-Qpid-1>-n FT-Qpid-1 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 transacted=true 
failover=true</FT-Qpid-1>
                  <FT-Qpid-2>-n FT-Qpid-2 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 transacted=true 
failover=true</FT-Qpid-2>
+                 <FT-Qpid-3>-n FT-Qpid-3 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 
broker="tcp://localhost:5001;tcp://localhost:5002" transacted=true 
FailAfterCommit=true</FT-Qpid-3>
+
+                 <FT-Qpid-4>-n FT-Qpid-4 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 
broker="tcp://localhost:5001;tcp://localhost:5002" transacted=false 
FailBeforeSend=true</FT-Qpid-4>
+                 <FT-Qpid-5>-n FT-Qpid-5 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 
broker="tcp://localhost:5001;tcp://localhost:5002" transacted=false 
FailAfterSend=true</FT-Qpid-5>
+                 <FT-Qpid-6>-n FT-Qpid-6 -s [250000] -o . -t testPingOk 
org.apache.qpid.ping.PingTestPerf messageSize=1024 
broker="tcp://localhost:5001;tcp://localhost:5002" transacted=false 
FailAfterCommit=true</FT-Qpid-6>
+
 
                 </commands>
               </configuration>

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/AbstractPingProducer.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/AbstractPingProducer.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/AbstractPingProducer.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/AbstractPingProducer.java
 Tue Jan 23 02:55:00 2007
@@ -78,6 +78,7 @@
     protected boolean _failAfterCommit = false;
     protected boolean _failBeforeSend = false;
     protected boolean _failAfterSend = false;
+    protected boolean _failOnce = true;
 
     protected int _sentMessages = 0;
     protected int _batchSize = 1;
@@ -257,12 +258,28 @@
     {
         if ((++_sentMessages % _batchSize) == 0)
         {
+            _logger.trace("Batch time reached");
+            if (_failAfterSend)
+            {
+                if (_failOnce)
+                {
+                    _failAfterSend = false;
+                }
+                _logger.trace("Failing After Send");
+                doFailover();
+            }
+
+
             if (session.getTransacted())
             {
                 try
                 {
                     if (_failBeforeCommit)
                     {
+                        if (_failOnce)
+                        {
+                            _failBeforeCommit = false;
+                        }
                         _logger.trace("Failing Before Commit");
                         doFailover();
                     }
@@ -271,6 +288,10 @@
 
                     if (_failAfterCommit)
                     {
+                        if (_failOnce)
+                        {
+                            _failAfterCommit = false;
+                        }
                         _logger.trace("Failing After Commit");
                         doFailover();
                     }
@@ -312,6 +333,10 @@
     {
         if (_failBeforeSend)
         {
+            if (_failOnce)
+            {
+                _failBeforeSend = false;
+            }
             _logger.trace("Failing Before Send");
             doFailover();
         }
@@ -325,11 +350,7 @@
             _producer.send(q, message);
         }
 
-        if (_failAfterSend)
-        {
-            _logger.trace("Failing After Send");
-            doFailover();
-        }
+        commitTx();
     }
 
     protected void doFailover(String broker)

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingItself.java
 Tue Jan 23 02:55:00 2007
@@ -38,6 +38,7 @@
     /**
      * This creates a client for pinging to a Queue. There will be one 
producer and one consumer instance. Consumer
      * listening to the same Queue, producer is sending to
+     *
      * @param brokerDetails
      * @param username
      * @param password
@@ -57,17 +58,18 @@
      */
     public TestPingItself(String brokerDetails, String username, String 
password, String virtualpath, String queueName,
                           String selector, boolean transacted, boolean 
persistent, int messageSize, boolean verbose,
-                          boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend,
+                          boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend, boolean failOnce,
                           int batchSize)
             throws Exception
     {
         super(brokerDetails, username, password, virtualpath, queueName, 
selector, transacted, persistent, messageSize,
-              verbose, afterCommit, beforeCommit, afterSend, beforeSend, 
batchSize, 0);
+              verbose, afterCommit, beforeCommit, afterSend, beforeSend, 
failOnce, batchSize, 0);
     }
 
     /**
      * This creats a client for tests with multiple queues. Creates as many 
consumer instances as there are queues,
      * each listening to a Queue. A producer is created which picks up a queue 
from the list of queues to send message.
+     *
      * @param brokerDetails
      * @param username
      * @param password
@@ -87,12 +89,12 @@
      */
     public TestPingItself(String brokerDetails, String username, String 
password, String virtualpath,
                           String selector, boolean transacted, boolean 
persistent, int messageSize, boolean verbose,
-                          boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend,
+                          boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend, boolean failOnce,
                           int batchSize, int queueCount)
             throws Exception
     {
         super(brokerDetails, username, password, virtualpath, null, null, 
transacted, persistent, messageSize,
-              verbose, afterCommit, beforeCommit, afterSend, beforeSend, 
batchSize, queueCount);
+              verbose, afterCommit, beforeCommit, afterSend, beforeSend, 
failOnce, batchSize, queueCount);
 
         createQueues(queueCount);
 
@@ -117,7 +119,8 @@
     }
 
     /**
-     * Starts a ping-pong loop running from the command line. 
+     * Starts a ping-pong loop running from the command line.
+     *
      * @param args The command line arguments as defined above.
      */
     public static void main(String[] args) throws Exception
@@ -145,6 +148,7 @@
         boolean beforeCommit = false;
         boolean afterSend = false;
         boolean beforeSend = false;
+        boolean failOnce = false;
 
         for (String arg : args)
         {
@@ -165,6 +169,11 @@
                         afterSend = parts[1].equals("after");
                         beforeSend = parts[1].equals("before");
                     }
+                    if (parts[1].equals("once"))
+                    {
+                        failOnce = true;
+                    }
+
                 }
                 else
                 {
@@ -178,18 +187,18 @@
         if (queueCount > 1)
         {
             pingItself = new TestPingItself(brokerDetails, "guest", "guest", 
virtualpath, null,
-                                               transacted, persistent, 
messageSize, verbose,
-                                               afterCommit, beforeCommit, 
afterSend, beforeSend,
-                                               batchSize, queueCount);
+                                            transacted, persistent, 
messageSize, verbose,
+                                            afterCommit, beforeCommit, 
afterSend, beforeSend, failOnce,
+                                            batchSize, queueCount);
         }
         else
         {
             pingItself = new TestPingItself(brokerDetails, "guest", "guest", 
virtualpath, queue, null,
-                                               transacted, persistent, 
messageSize, verbose,
-                                               afterCommit, beforeCommit, 
afterSend, beforeSend,
-                                               batchSize);
+                                            transacted, persistent, 
messageSize, verbose,
+                                            afterCommit, beforeCommit, 
afterSend, beforeSend, failOnce,
+                                            batchSize);
         }
-        
+
         pingItself.getConnection().start();
 
         // Create a shutdown hook to terminate the ping-pong producer.
@@ -225,13 +234,13 @@
     private static void usage()
     {
         System.err.println("Usage: TestPingPublisher \n" +
-                "-host : broker host" +
-                "-port : broker port" +
-                "-transacted : (true/false). Default is false" +
-                "-persistent : (true/false). Default is false" +
-                "-payload    : paylaod size. Default is 0" +
-                "-queues     : no of queues" +
-                "-messages   : no of messages to be sent (if 0, the ping loop 
will run indefinitely)");
+                           "-host : broker host" +
+                           "-port : broker port" +
+                           "-transacted : (true/false). Default is false" +
+                           "-persistent : (true/false). Default is false" +
+                           "-payload    : paylaod size. Default is 0" +
+                           "-queues     : no of queues" +
+                           "-messages   : no of messages to be sent (if 0, the 
ping loop will run indefinitely)");
         System.exit(0);
     }
 }

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingProducer.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingProducer.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingProducer.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/ping/TestPingProducer.java
 Tue Jan 23 02:55:00 2007
@@ -88,7 +88,8 @@
 
     public TestPingProducer(String brokerDetails, String username, String 
password, String virtualpath, String queueName,
                             boolean transacted, boolean persistent, int 
messageSize, boolean verbose, boolean afterCommit,
-                            boolean beforeCommit, boolean afterSend, boolean 
beforeSend,int batchSize) throws Exception
+                            boolean beforeCommit, boolean afterSend, boolean 
beforeSend, boolean failOnce,
+                            int batchSize) throws Exception
     {
         // Create a connection to the broker.
         InetAddress address = InetAddress.getLocalHost();
@@ -115,6 +116,7 @@
         _failBeforeSend = beforeSend;
         _sentMessages = 0;
         _batchSize = batchSize;
+        _failOnce = failOnce;
     }
 
     /**
@@ -129,7 +131,7 @@
         if (args.length < 2)
         {
             System.err.println(
-                    "Usage: TestPingPublisher <brokerDetails> <virtual path> "+
+                    "Usage: TestPingPublisher <brokerDetails> <virtual path> " 
+
                     "[<verbose(true|false)> <transacted(true|false))> 
<persistent(true|false)> <message size in bytes> <batchsize>");
             System.exit(0);
         }
@@ -147,6 +149,7 @@
         boolean beforeCommit = false;
         boolean afterSend = false;
         boolean beforeSend = false;
+        boolean failOnce = false;
 
         for (String arg : args)
         {
@@ -167,6 +170,10 @@
                         afterSend = parts[1].equals("after");
                         beforeSend = parts[1].equals("before");
                     }
+                    if (parts[1].equals("once"))
+                    {
+                        failOnce = true;
+                    }
                 }
                 else
                 {
@@ -178,7 +185,7 @@
         // Create a ping producer to generate the pings.
         _pingProducer = new TestPingProducer(brokerDetails, "guest", "guest", 
virtualpath, PING_QUEUE_NAME,
                                              transacted, persistent, 
messageSize, verbose,
-                                             afterCommit, beforeCommit, 
afterSend, beforeSend,
+                                             afterCommit, beforeCommit, 
afterSend, beforeSend, failOnce,
                                              batchSize);
 
         // Start the connection running.

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
 Tue Jan 23 02:55:00 2007
@@ -145,7 +145,7 @@
 
     private PingPongProducer(String brokerDetails, String username, String 
password, String virtualpath,
                              boolean transacted, boolean persistent, int 
messageSize, boolean verbose,
-                             boolean afterCommit, boolean beforeCommit, 
boolean afterSend, boolean beforeSend,
+                             boolean afterCommit, boolean beforeCommit, 
boolean afterSend, boolean beforeSend, boolean failOnce,
                              int batchSize)
             throws Exception
     {
@@ -168,6 +168,7 @@
         _failBeforeCommit = beforeCommit;
         _failAfterSend = afterSend;
         _failBeforeSend = beforeSend;
+        _failOnce = failOnce;
         _batchSize = batchSize;
         _sentMessages = 0;
     }
@@ -184,12 +185,12 @@
      */
     public PingPongProducer(String brokerDetails, String username, String 
password, String virtualpath, String queueName,
                             String selector, boolean transacted, boolean 
persistent, int messageSize, boolean verbose,
-                            boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend,
+                            boolean afterCommit, boolean beforeCommit, boolean 
afterSend, boolean beforeSend, boolean failOnce,
                             int batchSize, int queueCount)
             throws Exception
     {
         this(brokerDetails, username, password, virtualpath, transacted, 
persistent, messageSize, verbose,
-             afterCommit, beforeCommit, afterSend, beforeSend, batchSize);
+             afterCommit, beforeCommit, afterSend, beforeSend, failOnce, 
batchSize);
 
         if (queueName != null)
         {
@@ -311,16 +312,18 @@
         int messageSize = (args.length >= 6) ? Integer.parseInt(args[5]) : 
DEFAULT_MESSAGE_SIZE;
         int batchSize = (args.length >= 7) ? Integer.parseInt(args[6]) : 1;
 
+
         boolean afterCommit = false;
         boolean beforeCommit = false;
         boolean afterSend = false;
         boolean beforeSend = false;
+        boolean failOnce = false;
 
         for (String arg : args)
         {
             if (arg.startsWith("failover:"))
             {
-                //failover:<before|after>:<send:commit>
+                //failover:<before|after>:<send:commit> | failover:once
                 String[] parts = arg.split(":");
                 if (parts.length == 3)
                 {
@@ -335,6 +338,10 @@
                         afterSend = parts[1].equals("after");
                         beforeSend = parts[1].equals("before");
                     }
+                    if (parts[1].equals("once"))
+                    {
+                        failOnce = true;
+                    }
                 }
                 else
                 {
@@ -346,7 +353,7 @@
         // Create a ping producer to handle the request/wait/reply cycle.
         _pingProducer = new PingPongProducer(brokerDetails, "guest", "guest", 
virtualpath, PING_QUEUE_NAME, null, transacted,
                                              persistent, messageSize, verbose,
-                                             afterCommit, beforeCommit, 
afterSend, beforeSend,
+                                             afterCommit, beforeCommit, 
afterSend, beforeSend, failOnce,
                                              batchSize, 0);
 
         _pingProducer.getConnection().start();
@@ -382,8 +389,6 @@
 
             sendMessage(first);
 
-            commitTx();
-
             try
             {
                 Thread.sleep(100);
@@ -482,10 +487,6 @@
             }
         }
 
-        // Commit the transaction if running in transactional mode. This must 
happen now, rather than at the end of
-        // this method, as the message will not be sent until the transaction 
is committed.
-        commitTx();
-
         // Keep the messageId to correlate with the reply.
         //String messageId = message.getJMSMessageID();
         if (_verbose)
@@ -556,9 +557,6 @@
                 _logger.info(timestampFormatter.format(new Date()) + ": Pinged 
at.");
             }
         }
-
-        // Commit the transaction if running in transactional mode, to force 
the send now.
-        commitTx();
     }
 
     /**

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/ping/PingTestPerf.java
 Tue Jan 23 02:55:00 2007
@@ -122,7 +122,7 @@
     private static final String FAIL_AFTER_SEND = "FailAfterSend";
     private static final String FAIL_BEFORE_SEND = "FailBeforeSend";
     private static final String BATCH_SIZE = "BatchSize";
-
+    private static final String FAIL_ONCE = "FailOnce";
 
 
     /**
@@ -147,6 +147,7 @@
         setSystemPropertyIfNull(FAIL_BEFORE_COMMIT, "false");
         setSystemPropertyIfNull(FAIL_AFTER_SEND, "false");
         setSystemPropertyIfNull(FAIL_BEFORE_SEND, "false");
+        setSystemPropertyIfNull(FAIL_ONCE, "true");
 
         setSystemPropertyIfNull(BATCH_SIZE, 
Integer.toString(BATCH_SIZE_DEFAULT));
         setSystemPropertyIfNull(MESSAGE_SIZE_PROPNAME, 
Integer.toString(MESSAGE_SIZE_DEFAULT));
@@ -156,7 +157,7 @@
         setSystemPropertyIfNull(BROKER_PROPNAME, BROKER_DEFAULT);
         setSystemPropertyIfNull(VIRTUAL_PATH_PROPNAME, VIRTUAL_PATH_DEFAULT);
         setSystemPropertyIfNull(TIMEOUT_PROPNAME, 
Long.toString(TIMEOUT_DEFAULT));
-        setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, 
Integer.toString(1));         
+        setSystemPropertyIfNull(PING_QUEUE_COUNT_PROPNAME, 
Integer.toString(1));
     }
 
     /**
@@ -246,6 +247,7 @@
             boolean beforeCommit = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_COMMIT));
             boolean afterSend = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_SEND));
             boolean beforeSend = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_SEND));
+            boolean failOnce = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_ONCE));
 
             int batchSize = 
Integer.parseInt(testParameters.getProperty(BATCH_SIZE));
 
@@ -256,7 +258,7 @@
                 perThreadSetup._pingItselfClient = new 
TestPingItself(brokerDetails, username, password, virtualpath,
                                                                       
selector, transacted, persistent,
                                                                       
messageSize, verbose,
-                                                                      
afterCommit, beforeCommit, afterSend, beforeSend,
+                                                                      
afterCommit, beforeCommit, afterSend, beforeSend, failOnce,
                                                                       
batchSize, queueCount);
             }
             else
@@ -265,7 +267,7 @@
                 perThreadSetup._pingItselfClient = new 
TestPingItself(brokerDetails, username, password, virtualpath,
                                                                       
queueName, selector, transacted, persistent,
                                                                       
messageSize, verbose,
-                                                                      
afterCommit, beforeCommit, afterSend, beforeSend,
+                                                                      
afterCommit, beforeCommit, afterSend, beforeSend, failOnce,
                                                                       
batchSize);
             }
 

Modified: 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java?view=diff&rev=498984&r1=498983&r2=498984
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/perftests/src/test/java/org/apache/qpid/requestreply/PingPongTestPerf.java
 Tue Jan 23 02:55:00 2007
@@ -136,6 +136,7 @@
     private static final String FAIL_AFTER_SEND = "FailAfterSend";
     private static final String FAIL_BEFORE_SEND = "FailBeforeSend";
     private static final String BATCH_SIZE = "BatchSize";
+    private static final String FAIL_ONCE = "FailOnce";
 
 
     public PingPongTestPerf(String name)
@@ -221,6 +222,7 @@
             boolean afterSend = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_AFTER_SEND));
             boolean beforeSend = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_BEFORE_SEND));
             int batchSize = 
Integer.parseInt(testParameters.getProperty(BATCH_SIZE));
+            Boolean failOnce = 
Boolean.parseBoolean(testParameters.getProperty(FAIL_ONCE));
 
             // Establish a bounce back client on the ping queue to bounce back 
the pings.
             perThreadSetup._testPingBouncer = new 
PingPongBouncer(brokerDetails, username, password, virtualpath, queueName,
@@ -233,7 +235,7 @@
             perThreadSetup._testPingProducer = new 
PingPongProducer(brokerDetails, username, password, virtualpath,
                                                                     queueName, 
selector, transacted, persistent, messageSize,
                                                                     verbose,
-                                                                    
afterCommit, beforeCommit, afterSend, beforeSend,
+                                                                    
afterCommit, beforeCommit, afterSend, beforeSend, failOnce,
                                                                     batchSize, 
0);
 
             perThreadSetup._testPingProducer.getConnection().start();


Reply via email to