You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2015/05/20 14:43:32 UTC
[3/8] activemq git commit: fix sync on failover updated urls -
intermittent failure on FailoverComplexClusterTest
fix sync on failover updated urls - intermittent failure on FailoverComplexClusterTest
Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/2536c031
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/2536c031
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/2536c031
Branch: refs/heads/master
Commit: 2536c03125e17c4d21d50489df8c01a1f0ba4bc0
Parents: 27e11a3
Author: gtully <ga...@gmail.com>
Authored: Tue May 19 11:41:49 2015 +0100
Committer: gtully <ga...@gmail.com>
Committed: Wed May 20 09:57:05 2015 +0100
----------------------------------------------------------------------
.../transport/failover/FailoverTransport.java | 25 ++++++++++----------
.../failover/FailoverComplexClusterTest.java | 3 +++
2 files changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq/blob/2536c031/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
index 728d4b7..95c5d21 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
@@ -1284,21 +1284,22 @@ public class FailoverTransport implements CompositeTransport {
@Override
public void updateURIs(boolean rebalance, URI[] updatedURIs) throws IOException {
if (isUpdateURIsSupported()) {
- HashSet<URI> copy = new HashSet<URI>(this.updated);
- updated.clear();
- if (updatedURIs != null && updatedURIs.length > 0) {
- for (URI uri : updatedURIs) {
- if (uri != null && !updated.contains(uri)) {
- updated.add(uri);
- }
- }
- if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(new HashSet<URI>(updated))) {
- buildBackups();
- synchronized (reconnectMutex) {
- reconnect(rebalance);
+ HashSet<URI> copy = new HashSet<URI>();
+ synchronized (reconnectMutex) {
+ copy.addAll(this.updated);
+ updated.clear();
+ if (updatedURIs != null && updatedURIs.length > 0) {
+ for (URI uri : updatedURIs) {
+ if (uri != null && !updated.contains(uri)) {
+ updated.add(uri);
+ }
}
}
}
+ if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(new HashSet<URI>(updated))) {
+ buildBackups();
+ reconnect(rebalance);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/activemq/blob/2536c031/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
index fab2da5..74fc0b5 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/transport/failover/FailoverComplexClusterTest.java
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
* broker is removed and then show 3 after the 3rd broker is reintroduced.
*/
public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
+ protected final Logger LOG = LoggerFactory.getLogger(FailoverComplexClusterTest.class);
private static final String BROKER_A_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61616";
private static final String BROKER_B_CLIENT_TC_ADDRESS = "tcp://127.0.0.1:61617";
@@ -258,6 +259,7 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
private void runTests(boolean multi, String tcParams, String clusterFilter, String destinationFilter) throws Exception, InterruptedException {
assertClientsConnectedToThreeBrokers();
+ LOG.info("Stopping BrokerC in prep for restart");
getBroker(BROKER_C_NAME).stop();
getBroker(BROKER_C_NAME).waitUntilStopped();
removeBroker(BROKER_C_NAME);
@@ -266,6 +268,7 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
assertClientsConnectedToTwoBrokers();
+ LOG.info("Recreating BrokerC after stop");
createBrokerC(multi, tcParams, clusterFilter, destinationFilter);
getBroker(BROKER_C_NAME).waitUntilStarted();
Thread.sleep(5000);