Java Code Examples for org.apache.rocketmq.common.protocol.body.ClusterInfo#getClusterAddrTable()

The following examples show how to use org.apache.rocketmq.common.protocol.body.ClusterInfo#getClusterAddrTable() . 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 DDMQ with Apache License 2.0 6 votes vote down vote up
@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: DefaultMQAdminExtTest.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: DeFiBusProducerImpl.java    From DeFiBus with Apache License 2.0 6 votes vote down vote up
private void updateLocalBrokers(ClusterInfo clusterInfo) {
    if (clusterInfo != null) {
        String clusterPrefix = deFiBusProducer.getDeFiBusClientConfig().getClusterPrefix();
        HashMap<String, Set<String>> clusterAddrTable = clusterInfo.getClusterAddrTable();
        Set<String> currentBrokers = new HashSet<String>();
        for (Map.Entry<String, Set<String>> entry : clusterAddrTable.entrySet()) {
            String clusterName = entry.getKey();
            String clusterIdc = StringUtils.split(clusterName, DeFiBusConstant.IDC_SEPERATER)[0];
            if (StringUtils.isNotEmpty(clusterPrefix) && StringUtils.equalsIgnoreCase(clusterIdc, clusterPrefix)) {
                currentBrokers.addAll(entry.getValue());
            }
        }
        if (!currentBrokers.equals(messageQueueSelector.getLocalBrokers())) {
            messageQueueSelector.setLocalBrokers(currentBrokers);
            LOGGER.info("localBrokers updated:  {} , clusterPrefix :{} ", currentBrokers, clusterPrefix);
        }
    }
}
 
Example 4
Source File: DefaultMQAdminExtTest.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
@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: DefaultMQAdminExtTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: DefaultMQAdminExtTest.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: DefaultMQAdminExtTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
@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 8
Source File: DefaultMQAdminExtTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@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);
}