added option to not update clients when broker removed from a cluster

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@924349 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2010-03-17 16:17:26 +00:00
parent 8329c53c21
commit be55d0a661
3 changed files with 38 additions and 5 deletions

View File

@ -52,5 +52,11 @@ public interface Connector extends Service {
* about the connected brokers in the cluster
*/
public void updateClientClusterInfo();
/**
* @return true if clients should be updated when
* a broker is removed from a broker
*/
public boolean isUpdateClusterClientsOnRemove();
}

View File

@ -67,8 +67,9 @@ public class TransportConnector implements Connector, BrokerServiceAware {
private boolean disableAsyncDispatch;
private boolean enableStatusMonitor = false;
private Broker broker;
private boolean updateClusterClients = false;
private boolean updateClusterClients = true;
private boolean rebalanceClusterClients;
private boolean updateClusterClientsOnRemove = false;
private String updateClusterFilter;
public TransportConnector() {
@ -509,7 +510,21 @@ public class TransportConnector implements Connector, BrokerServiceAware {
public void setRebalanceClusterClients(boolean rebalanceClusterClients) {
this.rebalanceClusterClients = rebalanceClusterClients;
}
/**
* @return the updateClusterClientsOnRemove
*/
public boolean isUpdateClusterClientsOnRemove() {
return this.updateClusterClientsOnRemove;
}
/**
* @param updateClusterClientsOnRemove the updateClusterClientsOnRemove to set
*/
public void setUpdateClusterClientsOnRemove(boolean updateClusterClientsOnRemove) {
this.updateClusterClientsOnRemove = updateClusterClientsOnRemove;
}
/**
* @return the updateClusterFilter
*/
@ -524,4 +539,5 @@ public class TransportConnector implements Connector, BrokerServiceAware {
public void setUpdateClusterFilter(String updateClusterFilter) {
this.updateClusterFilter = updateClusterFilter;
}
}

View File

@ -587,14 +587,14 @@ public class RegionBroker extends EmptyBroker {
@Override
public synchronized void addBroker(Connection connection, BrokerInfo info) {
brokerInfos.add(info);
updateClients();
addBrokerInClusterUpdate();
}
@Override
public synchronized void removeBroker(Connection connection, BrokerInfo info) {
if (info != null) {
brokerInfos.remove(info);
updateClients();
removeBrokerInClusterUpdate();
}
}
@ -835,10 +835,21 @@ public class RegionBroker extends EmptyBroker {
}
}
protected void updateClients() {
protected void addBrokerInClusterUpdate() {
List<TransportConnector> connectors = this.brokerService.getTransportConnectors();
for (TransportConnector connector : connectors) {
connector.updateClientClusterInfo();
if (connector.isUpdateClusterClients()) {
connector.updateClientClusterInfo();
}
}
}
protected void removeBrokerInClusterUpdate() {
List<TransportConnector> connectors = this.brokerService.getTransportConnectors();
for (TransportConnector connector : connectors) {
if (connector.isUpdateClusterClients() && connector.isUpdateClusterClientsOnRemove()) {
connector.updateClientClusterInfo();
}
}
}
}