Java Code Examples for org.apache.rocketmq.common.protocol.body.ClusterInfo#getBrokerAddrTable()
The following examples show how to use
org.apache.rocketmq.common.protocol.body.ClusterInfo#getBrokerAddrTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultMQAdminExtTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: MQAdmin.java From DDMQ with Apache License 2.0 | 6 votes |
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; }
Example 3
Source File: DefaultMQAdminExtTest.java From DDMQ with Apache License 2.0 | 6 votes |
@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); }
Example 4
Source File: DefaultMQAdminExtTest.java From rocketmq with Apache License 2.0 | 6 votes |
@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); }
Example 5
Source File: MQAdmin.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: MQAdmin.java From rocketmq with Apache License 2.0 | 6 votes |
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; }
Example 7
Source File: MQAdmin.java From rocketmq-read with Apache License 2.0 | 6 votes |
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; }
Example 8
Source File: MQAdmin.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
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; }
Example 9
Source File: DefaultMQAdminExtTest.java From rocketmq with Apache License 2.0 | 6 votes |
@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); }
Example 10
Source File: MQAdmin.java From rocketmq with Apache License 2.0 | 6 votes |
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; }
Example 11
Source File: CommandUtil.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
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."); }
Example 12
Source File: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 5 votes |
public Collection<BrokerData> getBrokers() { try { ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo(); Map<String, BrokerData> brokerAddrTable = clusterInfo.getBrokerAddrTable(); return brokerAddrTable.values(); } catch (Exception e) { LOGGER.error("GetBrokers Exception", e); } return Collections.emptyList(); }
Example 13
Source File: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 5 votes |
public Collection<BrokerData> getBrokers() { try { ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo(); Map<String, BrokerData> brokerAddrTable = clusterInfo.getBrokerAddrTable(); return brokerAddrTable.values(); } catch (Exception e) { LOGGER.error("GetBrokers Exception", e); } return CollectionUtils.emptyCollection(); }
Example 14
Source File: CommandUtil.java From DDMQ with Apache License 2.0 | 5 votes |
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."); }
Example 15
Source File: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 5 votes |
public Collection<BrokerData> getBrokers() { try { ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo(); Map<String, BrokerData> brokerAddrTable = clusterInfo.getBrokerAddrTable(); return brokerAddrTable.values(); } catch (Exception e) { LOGGER.error("GetBrokers Exception", e); } return Collections.emptyList(); }
Example 16
Source File: CommandUtil.java From rocketmq-read with Apache License 2.0 | 5 votes |
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(ERROR_MESSAGE); }
Example 17
Source File: CommandUtil.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
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(ERROR_MESSAGE); }
Example 18
Source File: RocketMQProduceOffsetFetcher.java From DDMQ with Apache License 2.0 | 5 votes |
public Collection<BrokerData> getBrokers() { try { ClusterInfo clusterInfo = defaultMQAdminExt.examineBrokerClusterInfo(); Map<String, BrokerData> brokerAddrTable = clusterInfo.getBrokerAddrTable(); return brokerAddrTable.values(); } catch (Exception e) { LOGGER.error("GetBrokers Exception", e); } return CollectionUtils.emptyCollection(); }
Example 19
Source File: CommandUtil.java From rocketmq with Apache License 2.0 | 5 votes |
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(ERROR_MESSAGE); }
Example 20
Source File: CommandUtil.java From DDMQ with Apache License 2.0 | 5 votes |
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."); }