https://issues.apache.org/jira/browse/AMQ-3685 - a few more fixes for failover cluster update ... handle well original broker restarting and avoid deadlock

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1241426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2012-02-07 11:24:49 +00:00
parent b567bd478b
commit 19cb932816
2 changed files with 37 additions and 5 deletions

View File

@ -705,7 +705,11 @@ public class FailoverTransport implements CompositeTransport {
private List<URI> getConnectList() { private List<URI> getConnectList() {
ArrayList<URI> l = new ArrayList<URI>(uris); ArrayList<URI> l = new ArrayList<URI>(uris);
l.addAll(updated); for (URI uri : updated) {
if (!l.contains(uri)) {
l.add(uri);
}
}
boolean removed = false; boolean removed = false;
if (failedConnectTransportURI != null) { if (failedConnectTransportURI != null) {
removed = l.remove(failedConnectTransportURI); removed = l.remove(failedConnectTransportURI);
@ -1167,13 +1171,13 @@ public class FailoverTransport implements CompositeTransport {
updated.clear(); updated.clear();
if (updatedURIs != null && updatedURIs.length > 0) { if (updatedURIs != null && updatedURIs.length > 0) {
for (URI uri : updatedURIs) { for (URI uri : updatedURIs) {
if (uri != null && !uris.contains(uri)) { if (uri != null && !updated.contains(uri)) {
updated.add(uri); updated.add(uri);
} }
} }
synchronized (reconnectMutex) { if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(updated)) {
if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(updated)) { buildBackups();
buildBackups(); synchronized (reconnectMutex) {
reconnect(rebalance); reconnect(rebalance);
} }
} }

View File

@ -72,6 +72,7 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
Thread.sleep(2000); Thread.sleep(2000);
setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")"); setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
createClients(); createClients();
Thread.sleep(2000);
runTests(false); runTests(false);
} }
@ -84,10 +85,37 @@ public class FailoverComplexClusterTest extends FailoverClusterTestSupport {
setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")"); setClientUrl("failover://(" + BROKER_A_CLIENT_TC_ADDRESS + "," + BROKER_B_CLIENT_TC_ADDRESS + ")");
createClients(); createClients();
Thread.sleep(2000);
runTests(true); 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/> * Runs a 3 tests: <br/>