Skip to content

Commit

Permalink
[ROCKETMQ-200]-Cluster name is always missing when fetch ClusterInfo …
Browse files Browse the repository at this point in the history
…from name server closes apache#105
  • Loading branch information
Jaskey authored and dongeforever committed May 27, 2017
1 parent 8c8610f commit c796140
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
* limitations under the License.
*/

/**
* $Id: BrokerData.java 1835 2013-05-16 02:00:50Z [email protected] $
*/

package org.apache.rocketmq.common.protocol.route;

import java.util.HashMap;
Expand All @@ -29,6 +27,16 @@ public class BrokerData implements Comparable<BrokerData> {
private String brokerName;
private HashMap<Long/* brokerId */, String/* broker address */> brokerAddrs;

public BrokerData() {

}

public BrokerData(String cluster, String brokerName, HashMap<Long, String> brokerAddrs) {
this.cluster = cluster;
this.brokerName = brokerName;
this.brokerAddrs = brokerAddrs;
}

public String selectBrokerAddr() {
String value = this.brokerAddrs.get(MixAll.MASTER_ID);
if (null == value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ public RegisterBrokerResult registerBroker(
BrokerData brokerData = this.brokerAddrTable.get(brokerName);
if (null == brokerData) {
registerFirst = true;
brokerData = new BrokerData();
brokerData.setBrokerName(brokerName);
HashMap<Long, String> brokerAddrs = new HashMap<Long, String>();
brokerData.setBrokerAddrs(brokerAddrs);

brokerData = new BrokerData(clusterName, brokerName, new HashMap<Long, String>());
this.brokerAddrTable.put(brokerName, brokerData);
}
String oldAddr = brokerData.getBrokerAddrs().put(brokerId, brokerAddr);
Expand Down Expand Up @@ -381,9 +377,7 @@ public TopicRouteData pickupTopicRouteData(final String topic) {
for (String brokerName : brokerNameSet) {
BrokerData brokerData = this.brokerAddrTable.get(brokerName);
if (null != brokerData) {
BrokerData brokerDataClone = new BrokerData();
brokerDataClone.setBrokerName(brokerData.getBrokerName());
brokerDataClone.setBrokerAddrs((HashMap<Long, String>) brokerData
BrokerData brokerDataClone = new BrokerData(brokerData.getCluster(), brokerData.getBrokerName(), (HashMap<Long, String>) brokerData
.getBrokerAddrs().clone());
brokerDataList.add(brokerDataClone);
foundBrokerData = true;
Expand Down

0 comments on commit c796140

Please sign in to comment.