本文整理匯總了Java中org.apache.rocketmq.common.protocol.route.BrokerData.getBrokerAddrs方法的典型用法代碼示例。如果您正苦於以下問題:Java BrokerData.getBrokerAddrs方法的具體用法?Java BrokerData.getBrokerAddrs怎麽用?Java BrokerData.getBrokerAddrs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.rocketmq.common.protocol.route.BrokerData
的用法示例。
在下文中一共展示了BrokerData.getBrokerAddrs方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isBrokerAddrExistInTopicRouteTable
import org.apache.rocketmq.common.protocol.route.BrokerData; //導入方法依賴的package包/類
private boolean isBrokerAddrExistInTopicRouteTable(final String addr) {
Iterator<Entry<String, TopicRouteData>> it = this.topicRouteTable.entrySet().iterator();
while (it.hasNext()) {
Entry<String, TopicRouteData> entry = it.next();
TopicRouteData topicRouteData = entry.getValue();
List<BrokerData> bds = topicRouteData.getBrokerDatas();
for (BrokerData bd : bds) {
if (bd.getBrokerAddrs() != null) {
boolean exist = bd.getBrokerAddrs().containsValue(addr);
if (exist)
return true;
}
}
}
return false;
}
示例2: getSystemTopicList
import org.apache.rocketmq.common.protocol.route.BrokerData; //導入方法依賴的package包/類
public byte[] getSystemTopicList() {
TopicList topicList = new TopicList();
try {
try {
this.lock.readLock().lockInterruptibly();
for (Map.Entry<String, Set<String>> entry : clusterAddrTable.entrySet()) {
topicList.getTopicList().add(entry.getKey());
topicList.getTopicList().addAll(entry.getValue());
}
if (brokerAddrTable != null && !brokerAddrTable.isEmpty()) {
Iterator<String> it = brokerAddrTable.keySet().iterator();
while (it.hasNext()) {
BrokerData bd = brokerAddrTable.get(it.next());
HashMap<Long, String> brokerAddrs = bd.getBrokerAddrs();
if (brokerAddrs != null && !brokerAddrs.isEmpty()) {
Iterator<Long> it2 = brokerAddrs.keySet().iterator();
topicList.setBrokerAddr(brokerAddrs.get(it2.next()));
break;
}
}
}
} finally {
this.lock.readLock().unlock();
}
} catch (Exception e) {
log.error("getAllTopicList Exception", e);
}
return topicList.encode();
}
示例3: fetchMasterAndSlaveDistinguish
import org.apache.rocketmq.common.protocol.route.BrokerData; //導入方法依賴的package包/類
public static Map<String/*master addr*/, List<String>/*slave addr*/> fetchMasterAndSlaveDistinguish(
final MQAdminExt adminExt, final String clusterName)
throws InterruptedException, RemotingConnectException,
RemotingTimeoutException, RemotingSendRequestException,
MQBrokerException {
Map<String, List<String>> masterAndSlaveMap = new HashMap<String, List<String>>(4);
ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
if (brokerNameSet == null) {
System.out
.printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
return masterAndSlaveMap;
}
for (String brokerName : brokerNameSet) {
BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
if (brokerData == null || brokerData.getBrokerAddrs() == null) {
continue;
}
String masterAddr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
masterAndSlaveMap.put(masterAddr, new ArrayList<String>());
for (Long id : brokerData.getBrokerAddrs().keySet()) {
if (brokerData.getBrokerAddrs().get(id) == null
|| id.longValue() == MixAll.MASTER_ID) {
continue;
}
masterAndSlaveMap.get(masterAddr).add(brokerData.getBrokerAddrs().get(id));
}
}
return masterAndSlaveMap;
}