You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2012/05/29 13:38:36 UTC

svn commit: r1343677 - in /qpid/trunk/qpid: doc/book/src/programming/ java/client/src/main/java/org/apache/qpid/jms/ java/systests/src/main/java/org/apache/qpid/client/failover/ java/test-profiles/

Author: robbie
Date: Tue May 29 11:38:35 2012
New Revision: 1343677

URL: http://svn.apache.org/viewvc?rev=1343677&view=rev
Log:
QPID-4009: Make failover method invocation timeout configurable for 0-8/0-9/0-9-1 amqp clients

Applied patch from Oleksandr Rudyy <or...@gmail.com>, Philip Harvey <ph...@philharveyonline.com>

Modified:
    qpid/trunk/qpid/doc/book/src/programming/Programming-In-Apache-Qpid-Book.xml
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java
    qpid/trunk/qpid/java/test-profiles/Java010Excludes

Modified: qpid/trunk/qpid/doc/book/src/programming/Programming-In-Apache-Qpid-Book.xml
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/doc/book/src/programming/Programming-In-Apache-Qpid-Book.xml?rev=1343677&r1=1343676&r2=1343677&view=diff
==============================================================================
--- qpid/trunk/qpid/doc/book/src/programming/Programming-In-Apache-Qpid-Book.xml (original)
+++ qpid/trunk/qpid/doc/book/src/programming/Programming-In-Apache-Qpid-Book.xml Tue May 29 11:38:35 2012
@@ -3783,6 +3783,16 @@ spout - -content "$(cat rdu.xml | sed -e
 		  <para>For compatibility with older clients, the synonym <varname>amqj.receiveBufferSize</varname> is supported.</para>
 		</entry>
 	      </row>
+          <row>
+            <entry>qpid.failover_method_timeout</entry>
+            <entry>long</entry>
+            <entry>60000</entry>
+            <entry>
+              <para>During failover, this is the timeout for each attempt to try to re-establish the connection.
+                    If a reconnection attempt exceeds the timeout, the entire failover process is aborted.</para>
+              <para>It is only applicable for AMQP 0-8/0-9/0-9-1 clients.</para>
+            </entry>
+          </row>
 	    </tbody>
 	  </tgroup>
 	</table>

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java?rev=1343677&r1=1343676&r2=1343677&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java (original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java Tue May 29 11:38:35 2012
@@ -35,7 +35,7 @@ public class FailoverPolicy
 
     private static final long MINUTE = 60000L;
 
-    private static final long DEFAULT_METHOD_TIMEOUT = 1 * MINUTE;
+    private final long DEFAULT_METHOD_TIMEOUT = Long.getLong("qpid.failover_method_timeout", 1 * MINUTE);
 
     private FailoverMethod[] _methods = new FailoverMethod[1];
 

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java?rev=1343677&r1=1343676&r2=1343677&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java (original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/client/failover/FailoverBehaviourTest.java Tue May 29 11:38:35 2012
@@ -19,7 +19,10 @@
 package org.apache.qpid.client.failover;
 
 import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQConnectionFactory;
+import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ConnectionListener;
+import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.jms.FailoverPolicy;
 import org.apache.qpid.test.utils.FailoverBaseCase;
 
@@ -36,6 +39,8 @@ import javax.jms.QueueBrowser;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 import javax.jms.TransactionRolledBackException;
+import javax.naming.NamingException;
+
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -760,6 +765,89 @@ public class FailoverBehaviourTest exten
         //got started, before allowing the test to tear down
         awaitForFailoverCompletion(DEFAULT_FAILOVER_TIME);
      }
+
+    /**
+     * This test only tests 0-8/0-9/0-9-1 failover timeout
+     */
+    public void testFailoverHandlerTimeoutExpires() throws Exception
+    {
+        _connection.close();
+        setTestSystemProperty("qpid.failover_method_timeout", "10000");
+        AMQConnection connection = null;
+        try
+        {
+            connection = createConnectionWithFailover();
+
+            // holding failover mutex should prevent the failover from proceeding
+            synchronized(connection.getFailoverMutex())
+            {
+                killBroker();
+                startBroker();
+
+                // sleep interval exceeds failover timeout interval
+                Thread.sleep(11000l);
+            }
+
+            // allows the failover thread to proceed
+            Thread.yield();
+            assertFalse("Unexpected failover", _failoverComplete.await(2000l, TimeUnit.MILLISECONDS));
+            assertTrue("Failover should not succeed due to timeout", connection.isClosed());
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                connection.close();
+            }
+        }
+    }
+
+    public void testFailoverHandlerTimeoutReconnected() throws Exception
+    {
+        _connection.close();
+        setTestSystemProperty("qpid.failover_method_timeout", "10000");
+        AMQConnection connection = null;
+        try
+        {
+            connection = createConnectionWithFailover();
+
+            // holding failover mutex should prevent the failover from proceeding
+            synchronized(connection.getFailoverMutex())
+            {
+                killBroker();
+                startBroker();
+            }
+
+            // allows the failover thread to proceed
+            Thread.yield();
+            awaitForFailoverCompletion(DEFAULT_FAILOVER_TIME);
+            assertFalse("Failover should restore connectivity", connection.isClosed());
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                connection.close();
+            }
+        }
+    }
+
+    private AMQConnection createConnectionWithFailover() throws NamingException, JMSException
+    {
+        AMQConnection connection;
+        AMQConnectionFactory connectionFactory = (AMQConnectionFactory)getConnectionFactory("default");
+        ConnectionURL connectionURL = connectionFactory.getConnectionURL();
+        connectionURL.setOption(ConnectionURL.OPTIONS_FAILOVER, "singlebroker");
+        connectionURL.setOption(ConnectionURL.OPTIONS_FAILOVER_CYCLE, "2");
+        BrokerDetails details = connectionURL.getBrokerDetails(0);
+        details.setProperty(BrokerDetails.OPTIONS_RETRY, "200");
+        details.setProperty(BrokerDetails.OPTIONS_CONNECT_DELAY, "1000");
+
+        connection = (AMQConnection)connectionFactory.createConnection("admin", "admin");
+        connection.setConnectionListener(this);
+        return connection;
+    }
+
     /**
      * Tests {@link Session#close()} for session with given acknowledge mode
      * to ensure that close works after failover.

Modified: qpid/trunk/qpid/java/test-profiles/Java010Excludes
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/test-profiles/Java010Excludes?rev=1343677&r1=1343676&r2=1343677&view=diff
==============================================================================
--- qpid/trunk/qpid/java/test-profiles/Java010Excludes (original)
+++ qpid/trunk/qpid/java/test-profiles/Java010Excludes Tue May 29 11:38:35 2012
@@ -54,6 +54,12 @@ org.apache.qpid.test.client.destination.
 org.apache.qpid.test.client.timeouts.SyncWaitTimeoutDelayTest#*
 org.apache.qpid.test.client.timeouts.SyncWaitDelayTest#*
 
+// These tests test the behaviour of 0-8..-0-9-1 specific system property qpid.failover_method_timeout
+org.apache.qpid.client.failover.FailoverBehaviourTest#testFailoverHandlerTimeoutExpires
+org.apache.qpid.client.failover.FailoverBehaviourTest#testFailoverHandlerTimeoutReconnected
+org.apache.qpid.client.failover.AddressBasedFailoverBehaviourTest#testFailoverHandlerTimeoutExpires
+org.apache.qpid.client.failover.AddressBasedFailoverBehaviourTest#testFailoverHandlerTimeoutReconnected
+
 // QPID-3604: Immediate Prefetch no longer supported by 0-10
 org.apache.qpid.client.AsynchMessageListenerTest#testImmediatePrefetchWithMessageListener
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org