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; 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.ManagedTransportConnector;
import org.apache.activemq.broker.jmx.ManagementContext; import org.apache.activemq.broker.jmx.ManagementContext;
import org.apache.activemq.broker.region.ConnectorStatistics; import org.apache.activemq.broker.region.ConnectorStatistics;
@ -35,18 +48,6 @@ import org.apache.activemq.util.ServiceSupport;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 * @org.apache.xbean.XBean
* *
@ -413,7 +414,9 @@ public class TransportConnector implements Connector, BrokerServiceAware {
uris.add(brokerService.getDefaultSocketURIString()); uris.add(brokerService.getDefaultSocketURIString());
for (BrokerInfo info: broker.getPeerBrokerInfos()) { for (BrokerInfo info: broker.getPeerBrokerInfos()) {
if (isMatchesClusterFilter(info.getBrokerName())) { if (isMatchesClusterFilter(info.getBrokerName())) {
uris.add(info.getBrokerURL()); if (info.getBrokerURL() != null) {
uris.add(info.getBrokerURL());
}
} }
} }
if (rebalance) { if (rebalance) {

View File

@ -16,6 +16,26 @@
*/ */
package org.apache.activemq.transport.failover; 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.broker.SslContext;
import org.apache.activemq.command.Command; import org.apache.activemq.command.Command;
import org.apache.activemq.command.ConnectionControl; import org.apache.activemq.command.ConnectionControl;
@ -39,26 +59,6 @@ import org.apache.activemq.util.ServiceSupport;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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 * A Transport that is made reliable by being able to fail over to another
* transport when a transport failure is detected. * transport when a transport failure is detected.
@ -889,7 +889,7 @@ public class FailoverTransport implements CompositeTransport {
// If we have a backup already waiting lets try it. // If we have a backup already waiting lets try it.
synchronized (backupMutex) { synchronized (backupMutex) {
if ((priorityBackup || backup) && !backups.isEmpty()) { if ((priorityBackup || backup) && !backups.isEmpty()) {
ArrayList<BackupTransport> l = new ArrayList(backups); ArrayList<BackupTransport> l = new ArrayList<BackupTransport>(backups);
if (randomize) { if (randomize) {
Collections.shuffle(l); Collections.shuffle(l);
} }
@ -1180,7 +1180,7 @@ public class FailoverTransport implements CompositeTransport {
updated.add(uri); 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(); buildBackups();
synchronized (reconnectMutex) { synchronized (reconnectMutex) {
reconnect(rebalance); reconnect(rebalance);