activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1241426 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/transport/failover/FailoverTransport.java test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
Date Tue, 07 Feb 2012 11:24:49 GMT
Author: dejanb
Date: Tue Feb  7 11:24:49 2012
New Revision: 1241426

URL: http://svn.apache.org/viewvc?rev=1241426&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3685 - a few more fixes for failover cluster update
... handle well original broker restarting and avoid deadlock

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java?rev=1241426&r1=1241425&r2=1241426&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
Tue Feb  7 11:24:49 2012
@@ -705,7 +705,11 @@ public class FailoverTransport implement
 
     private List<URI> getConnectList() {
         ArrayList<URI> l = new ArrayList<URI>(uris);
-        l.addAll(updated);
+        for (URI uri : updated) {
+            if (!l.contains(uri)) {
+                l.add(uri);
+            }
+        }
         boolean removed = false;
         if (failedConnectTransportURI != null) {
             removed = l.remove(failedConnectTransportURI);
@@ -1167,13 +1171,13 @@ public class FailoverTransport implement
             updated.clear();
             if (updatedURIs != null && updatedURIs.length > 0) {
                 for (URI uri : updatedURIs) {
-                    if (uri != null && !uris.contains(uri)) {
+                    if (uri != null && !updated.contains(uri)) {
                         updated.add(uri);
                     }
                 }
-                synchronized (reconnectMutex) {
-                    if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(updated))
{
-                        buildBackups();
+                if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(updated))
{
+                    buildBackups();
+                    synchronized (reconnectMutex) {
                         reconnect(rebalance);
                     }
                 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java?rev=1241426&r1=1241425&r2=1241426&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
Tue Feb  7 11:24:49 2012
@@ -72,6 +72,7 @@ public class FailoverComplexClusterTest 
         Thread.sleep(2000);
         setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS
+ ")");
         createClients();
+        Thread.sleep(2000);
 
         runTests(false);
     }
@@ -84,10 +85,37 @@ public class FailoverComplexClusterTest 
 
         setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS
+ ")");
         createClients();
+        Thread.sleep(2000);
 
         runTests(true);
     }
 
+    public void testOriginalBrokerRestart() throws Exception {
+        initSingleTcBroker("", null);
+
+        Thread.sleep(2000);
+
+        setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS
+ ")");
+        createClients();
+        Thread.sleep(2000);
+
+        assertClientsConnectedToThreeBrokers();
+
+        getBroker(BROKER_A_NAME).stop();
+        getBroker(BROKER_A_NAME).waitUntilStopped();
+        removeBroker(BROKER_A_NAME);
+
+        Thread.sleep(5000);
+
+        assertClientsConnectedToTwoBrokers();
+
+        createBrokerA(false, "", null);
+        getBroker(BROKER_A_NAME).waitUntilStarted();
+        Thread.sleep(5000);
+
+        assertClientsConnectedToThreeBrokers();
+    }
+
 
     /**
      * Runs a 3 tests: <br/>



Mime
View raw message