com.alibaba.rocketmq.tools.admin.MQAdminExt Java Examples

The following examples show how to use com.alibaba.rocketmq.tools.admin.MQAdminExt. 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: CommandUtil.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
        RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    }
    else {
        System.out
            .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #2
Source File: CommandUtil.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws Exception {
    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
    if (brokerNameSet.isEmpty()) {
        throw new Exception(
            "Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }
    return brokerNameSet;
}
 
Example #3
Source File: CommandUtil.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
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 #4
Source File: MQAdminInstance.java    From rocket-console with Apache License 2.0 5 votes vote down vote up
public static MQAdminExt threadLocalMQAdminExt() {
    DefaultMQAdminExt defaultMQAdminExt = mqAdminExtThreadLocal.get();
    if (defaultMQAdminExt == null) {
        throw new IllegalStateException("defaultMQAdminExt should be init before you get this");
    }
    return defaultMQAdminExt;
}
 
Example #5
Source File: MQAdminInstance.java    From rocket-console with Apache License 2.0 5 votes vote down vote up
public static void destroyMQAdminInstance() {
    Integer nowCount = initCounter.get() - 1;
    if (nowCount > 0) {
        initCounter.set(nowCount);
        return;
    }
    MQAdminExt mqAdminExt = mqAdminExtThreadLocal.get();
    if (mqAdminExt != null) {
        mqAdminExt.shutdown();
        mqAdminExtThreadLocal.remove();
        initCounter.remove();
    }
}
 
Example #6
Source File: CommandUtil.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws InterruptedException, RemotingConnectException, RemotingTimeoutException,
        RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    } else {
        System.out
                .printf("[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #7
Source File: CommandUtil.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt adminExt, final String clusterName)
        throws Exception {
    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
    if (brokerNameSet.isEmpty()) {
        throw new Exception(
                "Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }
    return brokerNameSet;
}
 
Example #8
Source File: CommandUtil.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
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 #9
Source File: CommandUtil.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchMasterAddrByClusterName(final MQAdminExt adminExt,
        final String clusterName) throws InterruptedException, RemotingConnectException,
                RemotingTimeoutException, RemotingSendRequestException, MQBrokerException {
    Set<String> masterSet = new HashSet<String>();

    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();

    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);

    if (brokerNameSet != null) {
        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                String addr = brokerData.getBrokerAddrs().get(MixAll.MASTER_ID);
                if (addr != null) {
                    masterSet.add(addr);
                }
            }
        }
    }
    else {
        System.out.printf(
            "[error] Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }

    return masterSet;
}
 
Example #10
Source File: CommandUtil.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt adminExt,
        final String clusterName) throws Exception {
    ClusterInfo clusterInfoSerializeWrapper = adminExt.examineBrokerClusterInfo();
    Set<String> brokerNameSet = clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
    if (brokerNameSet.isEmpty()) {
        throw new Exception(
            "Make sure the specified clusterName exists or the nameserver which connected is correct.");
    }
    return brokerNameSet;
}
 
Example #11
Source File: CommandUtil.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
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.");
}