当前位置: 首页>>代码示例>>Java>>正文


Java ClusterInfo.getBrokerAddrTable方法代码示例

本文整理汇总了Java中org.apache.rocketmq.common.protocol.body.ClusterInfo.getBrokerAddrTable方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterInfo.getBrokerAddrTable方法的具体用法?Java ClusterInfo.getBrokerAddrTable怎么用?Java ClusterInfo.getBrokerAddrTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.rocketmq.common.protocol.body.ClusterInfo的用法示例。


在下文中一共展示了ClusterInfo.getBrokerAddrTable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testExamineBrokerClusterInfo

import org.apache.rocketmq.common.protocol.body.ClusterInfo; //导入方法依赖的package包/类
@Test
public void testExamineBrokerClusterInfo() throws InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo();
    HashMap<String, BrokerData> brokerList = clusterInfo.getBrokerAddrTable();
    assertThat(brokerList.get("default-broker").getBrokerName()).isEqualTo("default-broker");
    assertThat(brokerList.containsKey("broker-test")).isTrue();

    HashMap<String, Set<String>> clusterMap = new HashMap<>();
    Set<String> brokers = new HashSet<>();
    brokers.add("default-broker");
    brokers.add("broker-test");
    clusterMap.put("default-cluster", brokers);
    ClusterInfo cInfo = mock(ClusterInfo.class);
    when(cInfo.getClusterAddrTable()).thenReturn(clusterMap);
    HashMap<String, Set<String>> clusterAddress = cInfo.getClusterAddrTable();
    assertThat(clusterAddress.containsKey("default-cluster")).isTrue();
    assertThat(clusterAddress.get("default-cluster").size()).isEqualTo(2);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:19,代码来源:DefaultMQAdminExtTest.java

示例2: isBrokerExist

import org.apache.rocketmq.common.protocol.body.ClusterInfo; //导入方法依赖的package包/类
public static boolean isBrokerExist(String ns, String ip) {
    ClusterInfo clusterInfo = getCluster(ns);
    if (clusterInfo == null) {
        return false;
    } else {
        HashMap<String, BrokerData> brokers = clusterInfo.getBrokerAddrTable();
        for (String brokerName : brokers.keySet()) {
            HashMap<Long, String> brokerIps = brokers.get(brokerName).getBrokerAddrs();
            for (long brokerId : brokerIps.keySet()) {
                if (brokerIps.get(brokerId).contains(ip))
                    return true;
            }
        }
    }

    return false;
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:18,代码来源:MQAdmin.java

示例3: fetchBrokerNameByAddr

import org.apache.rocketmq.common.protocol.body.ClusterInfo; //导入方法依赖的package包/类
public static String fetchBrokerNameByAddr(final MQAdminExt adminExt, final String addr) throws Exception {
    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
    HashMap<String/* brokerName */, BrokerData> brokerAddrTable =
        clusterInfoSerializeWrapper.getBrokerAddrTable();
    Iterator<Map.Entry<String, BrokerData>> it = brokerAddrTable.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<String, BrokerData> entry = it.next();
        HashMap<Long, String> brokerAddrs = entry.getValue().getBrokerAddrs();
        if (brokerAddrs.containsValue(addr))
            return entry.getKey();
    }
    throw new Exception(
        "Make sure the specified broker addr exists or the nameserver which connected is correct.");
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:15,代码来源:CommandUtil.java


注:本文中的org.apache.rocketmq.common.protocol.body.ClusterInfo.getBrokerAddrTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。