Repository: qpid-jms
Updated Branches:
  refs/heads/master 05e4db558 -> 3bc46d032


Fix the reset of reconnect delay after a successful connection, clean up
the test and reduce wait time for some of the tests.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/3bc46d03
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/3bc46d03
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/3bc46d03

Branch: refs/heads/master
Commit: 3bc46d0328c4813527a64aea3705b9a409f0a10f
Parents: 05e4db5
Author: Timothy Bish <[email protected]>
Authored: Thu Feb 5 10:21:05 2015 -0500
Committer: Timothy Bish <[email protected]>
Committed: Thu Feb 5 10:21:05 2015 -0500

----------------------------------------------------------------------
 .../jms/provider/failover/FailoverProvider.java | 21 +++++++++++---------
 .../qpid/jms/failover/JmsFailoverTest.java      | 17 +++++++++-------
 2 files changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/3bc46d03/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
index ce73d8f..a729eb3 100644
--- 
a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
+++ 
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java
@@ -89,6 +89,7 @@ public class FailoverProvider extends DefaultProviderListener 
implements Provide
     // Current state of connection / reconnection
     private boolean firstConnection = true;
     private long reconnectAttempts;
+    private long nextReconnectDelay = -1;
     private IOException failureCause;
     private URI connectedURI;
 
@@ -98,8 +99,6 @@ public class FailoverProvider extends DefaultProviderListener 
implements Provide
     private long sendTimeout =  JmsConnectionInfo.DEFAULT_SEND_TIMEOUT;
     private long requestTimeout = JmsConnectionInfo.DEFAULT_REQUEST_TIMEOUT;
 
-    // TODO - Need a current reconnect delay that is reset to default on 
connect
-
     // Configuration values.
     private long initialReconnectDelay = DEFAULT_INITIAL_RECONNECT_DELAY;
     private long reconnectDelay = DEFAULT_RECONNECT_DELAY;
@@ -368,7 +367,6 @@ public class FailoverProvider extends 
DefaultProviderListener implements Provide
         serializer.execute(pending);
     }
 
-
     @Override
     public void recover(final JmsSessionId sessionId, final AsyncResult 
request) throws IOException, UnsupportedOperationException {
         checkClosed();
@@ -503,7 +501,7 @@ public class FailoverProvider extends 
DefaultProviderListener implements Provide
                             request.run();
                         }
 
-                        reconnectDelay = initialReconnectDelay;
+                        nextReconnectDelay = reconnectDelay;
                         reconnectAttempts = 0;
                         connectedURI = provider.getRemoteURI();
                         uris.connected();
@@ -603,15 +601,20 @@ public class FailoverProvider extends 
DefaultProviderListener implements Provide
     }
 
     private long nextReconnectDelay() {
-        if (isUseReconnectBackOff()) {
+
+        if (nextReconnectDelay == -1) {
+            nextReconnectDelay = reconnectDelay;
+        }
+
+        if (isUseReconnectBackOff() && reconnectAttempts > 1) {
             // Exponential increment of reconnect delay.
-            reconnectDelay *= getReconnectBackOffMultiplier();
-            if (reconnectDelay > maxReconnectDelay) {
-                reconnectDelay = maxReconnectDelay;
+            nextReconnectDelay *= getReconnectBackOffMultiplier();
+            if (nextReconnectDelay > maxReconnectDelay) {
+                nextReconnectDelay = maxReconnectDelay;
             }
         }
 
-        return reconnectDelay;
+        return nextReconnectDelay;
     }
 
     protected void checkClosed() throws IOException {

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/3bc46d03/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java
----------------------------------------------------------------------
diff --git 
a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java
 
b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java
index 3885106..80483da 100644
--- 
a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java
+++ 
b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java
@@ -63,7 +63,7 @@ public class JmsFailoverTest extends AmqpTestSupport {
     @Test(timeout=60000)
     public void testFailoverConnectsWithMultipleURIs() throws Exception {
         URI brokerURI = new 
URI("failover://(amqp://127.0.0.1:61616,amqp://localhost:5777," +
-                                getBrokerAmqpConnectionURI() + ")");
+                                getBrokerAmqpConnectionURI() + 
")?failover.useReconnectBackOff=false");
         Connection connection = createAmqpConnection(brokerURI);
         connection.start();
         connection.close();
@@ -71,7 +71,9 @@ public class JmsFailoverTest extends AmqpTestSupport {
 
     @Test(timeout=60000)
     public void testStartupReconnectAttempts() throws Exception {
-        URI brokerURI = new 
URI("failover://(amqp://localhost:61616)?failover.startupMaxReconnectAttempts=5");
+        URI brokerURI = new URI("failover://(amqp://localhost:61616)" +
+                                "?failover.startupMaxReconnectAttempts=5" +
+                                "&failover.useReconnectBackOff=false");
         JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI);
         Connection connection = factory.createConnection();
         try {
@@ -88,7 +90,8 @@ public class JmsFailoverTest extends AmqpTestSupport {
     @Test(timeout=60000)
     public void testStartupReconnectAttemptsMultipleHosts() throws Exception {
         URI brokerURI = new 
URI("failover://(amqp://localhost:61616,amqp://localhost:61617)" +
-                                "?failover.startupMaxReconnectAttempts=6");
+                                "?failover.startupMaxReconnectAttempts=6" +
+                                "&failover.useReconnectBackOff=false");
         JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI);
         Connection connection = factory.createConnection();
         try {
@@ -105,7 +108,8 @@ public class JmsFailoverTest extends AmqpTestSupport {
     @Test(timeout=60000)
     public void testStartFailureWithAsyncExceptionListener() throws Exception {
         URI brokerURI = new URI(getAmqpFailoverURI() +
-            "?failover.reconnectDelay=20&failover.maxReconnectAttempts=5");
+            "?failover.maxReconnectAttempts=5" +
+            "&failover.useReconnectBackOff=false");
 
         final CountDownLatch failed = new CountDownLatch(1);
         JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI);
@@ -211,8 +215,7 @@ public class JmsFailoverTest extends AmqpTestSupport {
 
     @Test(timeout=90000)
     public void testBadFirstURIConnectsAndProducerWorks() throws Exception {
-        URI brokerURI = new URI("failover://(amqp://localhost:61616," +
-            getBrokerAmqpConnectionURI() + ")?failover.reconnectDelay=50");
+        URI brokerURI = new URI("failover://(amqp://localhost:61616," + 
getBrokerAmqpConnectionURI() + ")");
 
         connection = createAmqpConnection(brokerURI);
         connection.start();
@@ -245,7 +248,7 @@ public class JmsFailoverTest extends AmqpTestSupport {
 
     @Test(timeout=90000)
     public void testNonTxProducerRecoversAfterFailover() throws Exception {
-        URI brokerURI = new URI("failover://("+ getBrokerAmqpConnectionURI() 
+")?failover.reconnectDelay=50");
+        URI brokerURI = new URI(getAmqpFailoverURI());
 
         connection = createAmqpConnection(brokerURI);
         connection.start();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to