Don't send a URI to the client that equals "null" when the BrokerInfo has no set Broker URI, that sends the failover transport into an infinite reconnect cycle.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1244221 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-02-14 21:36:04 +00:00
parent 8bff980ec2
commit a3060e79d9
2 changed files with 42 additions and 39 deletions

View File

@ -16,6 +16,19 @@
*/
package org.apache.activemq.broker;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Pattern;
import javax.management.ObjectName;
import org.apache.activemq.broker.jmx.ManagedTransportConnector;
import org.apache.activemq.broker.jmx.ManagementContext;
import org.apache.activemq.broker.region.ConnectorStatistics;
@ -35,18 +48,6 @@ import org.apache.activemq.util.ServiceSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.management.ObjectName;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Pattern;
/**
* @org.apache.xbean.XBean
*
@ -262,7 +263,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
LOG.info("Connector " + getName() + " Started");
}
public String getPublishableConnectString() throws Exception {
return getPublishableConnectString(getConnectUri());
}
@ -413,7 +414,9 @@ public class TransportConnector implements Connector, BrokerServiceAware {
uris.add(brokerService.getDefaultSocketURIString());
for (BrokerInfo info: broker.getPeerBrokerInfos()) {
if (isMatchesClusterFilter(info.getBrokerName())) {
uris.add(info.getBrokerURL());
if (info.getBrokerURL() != null) {
uris.add(info.getBrokerURL());
}
}
}
if (rebalance) {
@ -423,7 +426,7 @@ public class TransportConnector implements Connector, BrokerServiceAware {
connectedBrokers += separator + uri;
separator = ",";
}
}
ConnectionControl control = new ConnectionControl();
control.setConnectedBrokers(connectedBrokers);

View File

@ -16,6 +16,26 @@
*/
package org.apache.activemq.transport.failover;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.broker.SslContext;
import org.apache.activemq.command.Command;
import org.apache.activemq.command.ConnectionControl;
@ -39,26 +59,6 @@ import org.apache.activemq.util.ServiceSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicReference;
/**
* A Transport that is made reliable by being able to fail over to another
* transport when a transport failure is detected.
@ -711,7 +711,7 @@ public class FailoverTransport implements CompositeTransport {
if (removed) {
updated.add(failedConnectTransportURI);
}
}
}
return updated;
}
ArrayList<URI> l = new ArrayList<URI>(uris);
@ -889,7 +889,7 @@ public class FailoverTransport implements CompositeTransport {
// If we have a backup already waiting lets try it.
synchronized (backupMutex) {
if ((priorityBackup || backup) && !backups.isEmpty()) {
ArrayList<BackupTransport> l = new ArrayList(backups);
ArrayList<BackupTransport> l = new ArrayList<BackupTransport>(backups);
if (randomize) {
Collections.shuffle(l);
}
@ -1134,7 +1134,7 @@ public class FailoverTransport implements CompositeTransport {
}
return false;
}
protected boolean isPriority(URI uri) {
if (!priorityList.isEmpty()) {
return priorityList.contains(uri);
@ -1180,7 +1180,7 @@ public class FailoverTransport implements CompositeTransport {
updated.add(uri);
}
}
if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(new HashSet(updated))) {
if (!(copy.isEmpty() && updated.isEmpty()) && !copy.equals(new HashSet<URI>(updated))) {
buildBackups();
synchronized (reconnectMutex) {
reconnect(rebalance);