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

The following examples show how to use org.apache.rocketmq.common.protocol.body.ClusterInfo#setBrokerAddrTable() . 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: ClusterInfoTest.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
private ClusterInfo buildClusterInfo() throws Exception {
    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<String, BrokerData>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<String, Set<String>>();

    //build brokerData
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("master");
    brokerData.setCluster("DEFAULT_CLUSTER");

    //build brokerAddrs
    HashMap<Long, String> brokerAddrs = new HashMap<Long, String>();
    brokerAddrs.put(MixAll.MASTER_ID, MixAll.getLocalhostByNetworkInterface());

    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("master", brokerData);

    Set<String> brokerNames = new HashSet<String>();
    brokerNames.add("master");

    clusterAddrTable.put("DEFAULT_CLUSTER", brokerNames);

    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    return clusterInfo;
}
 
Example 2
Source File: CommandUtilTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 3
Source File: CommandUtilTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 4
Source File: CommandUtilTest.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 5
Source File: CommandUtilTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 6
Source File: CommandUtilTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 7
Source File: CommandUtilTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 8
Source File: CommandUtilTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 9
Source File: RouteInfoManager.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 获取全部的集群信息
 * @return return 封装的集群的信息
 */
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 10
Source File: CommandUtilTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws MQClientException, NoSuchFieldException, IllegalAccessException, InterruptedException, MQBrokerException, RemotingTimeoutException, RemotingSendRequestException, RemotingConnectException {
    defaultMQAdminExt = mock(DefaultMQAdminExt.class);
    MQClientAPIImpl mQClientAPIImpl = mock(MQClientAPIImpl.class);
    defaultMQAdminExtImpl = new DefaultMQAdminExtImpl(defaultMQAdminExt, 3000);

    Field field = DefaultMQAdminExtImpl.class.getDeclaredField("mqClientInstance");
    field.setAccessible(true);
    field.set(defaultMQAdminExtImpl, mqClientInstance);
    field = MQClientInstance.class.getDeclaredField("mQClientAPIImpl");
    field.setAccessible(true);
    field.set(mqClientInstance, mQClientAPIImpl);

    ClusterInfo clusterInfo = new ClusterInfo();
    HashMap<String, BrokerData> brokerAddrTable = new HashMap<>();
    HashMap<String, Set<String>> clusterAddrTable = new HashMap<>();
    HashMap<Long, String> brokerAddrs = new HashMap<>();
    brokerAddrs.put(1234l, "127.0.0.1:10911");
    BrokerData brokerData = new BrokerData();
    brokerData.setBrokerName("default-broker");
    brokerData.setCluster("default-cluster");
    brokerData.setBrokerAddrs(brokerAddrs);
    brokerAddrTable.put("default-broker", brokerData);
    brokerAddrTable.put("broker-test", new BrokerData());
    Set<String> brokerSet = new HashSet<>();
    brokerSet.add("default-broker");
    brokerSet.add("default-broker-one");
    clusterAddrTable.put("default-cluster", brokerSet);
    clusterInfo.setBrokerAddrTable(brokerAddrTable);
    clusterInfo.setClusterAddrTable(clusterAddrTable);
    when(mQClientAPIImpl.getBrokerClusterInfo(anyLong())).thenReturn(clusterInfo);
    when(mQClientAPIImpl.cleanExpiredConsumeQueue(anyString(), anyLong())).thenReturn(true);
}
 
Example 11
Source File: RouteInfoManager.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
public byte[] getAllClusterInfo() {
        ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
//        broker数据
        clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
//        broker集群
        clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
        return clusterInfoSerializeWrapper.encode();
    }
 
Example 12
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 13
Source File: RouteInfoManager.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 14
Source File: RouteInfoManager.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 15
Source File: RouteInfoManager.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 16
Source File: RouteInfoManager.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}
 
Example 17
Source File: RouteInfoManager.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public byte[] getAllClusterInfo() {
    ClusterInfo clusterInfoSerializeWrapper = new ClusterInfo();
    clusterInfoSerializeWrapper.setBrokerAddrTable(this.brokerAddrTable);
    clusterInfoSerializeWrapper.setClusterAddrTable(this.clusterAddrTable);
    return clusterInfoSerializeWrapper.encode();
}