當前位置: 首頁>>代碼示例>>Java>>正文


Java BrokerData.getBrokerAddrs方法代碼示例

本文整理匯總了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;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:18,代碼來源:MQClientInstance.java

示例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();
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:32,代碼來源:RouteInfoManager.java

示例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;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:39,代碼來源:CommandUtil.java


注:本文中的org.apache.rocketmq.common.protocol.route.BrokerData.getBrokerAddrs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。