This is an automated email from the ASF dual-hosted git repository.

lizhanhui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2047f94  [BugFix] When deleting topics, instruct both master and slave 
nodes to delete it such that consume queues are all deleted
2047f94 is described below

commit 2047f94d81fe4b70006c950b72f814c8eb5ba112
Author: Li Zhanhui <[email protected]>
AuthorDate: Mon May 28 16:38:13 2018 +0800

    [BugFix] When deleting topics, instruct both master and slave nodes to 
delete it such that consume queues are all deleted
---
 .../apache/rocketmq/tools/command/CommandUtil.java | 36 +++++++++-------------
 .../tools/command/topic/DeleteTopicSubCommand.java |  4 +--
 2 files changed, 17 insertions(+), 23 deletions(-)

diff --git 
a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java 
b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
index edc9144..2e65f98 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/CommandUtil.java
@@ -35,6 +35,9 @@ import org.apache.rocketmq.tools.admin.MQAdminExt;
 
 public class CommandUtil {
 
+    private static final String ERROR_MESSAGE = "Make sure the specified 
clusterName exists or the name server " +
+        "connected to is correct.";
+
     public static Map<String/*master addr*/, List<String>/*slave addr*/> 
fetchMasterAndSlaveDistinguish(
         final MQAdminExt adminExt, final String clusterName)
         throws InterruptedException, RemotingConnectException,
@@ -46,8 +49,7 @@ public class CommandUtil {
         Set<String> brokerNameSet = 
clusterInfoSerializeWrapper.getClusterAddrTable().get(clusterName);
 
         if (brokerNameSet == null) {
-            System.out
-                .printf("[error] Make sure the specified clusterName exists or 
the nameserver which connected is correct.");
+            System.out.printf("[error] %s", ERROR_MESSAGE);
             return masterAndSlaveMap;
         }
 
@@ -62,8 +64,7 @@ public class CommandUtil {
             masterAndSlaveMap.put(masterAddr, new ArrayList<String>());
 
             for (Long id : brokerData.getBrokerAddrs().keySet()) {
-                if (brokerData.getBrokerAddrs().get(id) == null
-                    || id.longValue() == MixAll.MASTER_ID) {
+                if (brokerData.getBrokerAddrs().get(id) == null || id == 
MixAll.MASTER_ID) {
                     continue;
                 }
 
@@ -95,8 +96,7 @@ public class CommandUtil {
                 }
             }
         } else {
-            System.out
-                .printf("[error] Make sure the specified clusterName exists or 
the nameserver which connected is correct.");
+            System.out.printf("[error] %s", ERROR_MESSAGE);
         }
 
         return masterSet;
@@ -105,26 +105,22 @@ public class CommandUtil {
     public static Set<String> fetchMasterAndSlaveAddrByClusterName(final 
MQAdminExt adminExt, final String clusterName)
         throws InterruptedException, RemotingConnectException, 
RemotingTimeoutException,
         RemotingSendRequestException, MQBrokerException {
-        Set<String> masterSet = new HashSet<String>();
-
+        Set<String> brokerAddressSet = 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) {
                     final Collection<String> addrs = 
brokerData.getBrokerAddrs().values();
-                    masterSet.addAll(addrs);
+                    brokerAddressSet.addAll(addrs);
                 }
             }
         } else {
-            System.out
-                .printf("[error] Make sure the specified clusterName exists or 
the nameserver which connected is correct.");
+            System.out.printf("[error] %s", ERROR_MESSAGE);
         }
 
-        return masterSet;
+        return brokerAddressSet;
     }
 
     public static Set<String> fetchBrokerNameByClusterName(final MQAdminExt 
adminExt, final String clusterName)
@@ -132,25 +128,23 @@ public class CommandUtil {
         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.");
+            throw new Exception(ERROR_MESSAGE);
         }
         return brokerNameSet;
     }
 
     public static String fetchBrokerNameByAddr(final MQAdminExt adminExt, 
final String addr) throws Exception {
         ClusterInfo clusterInfoSerializeWrapper = 
adminExt.examineBrokerClusterInfo();
-        HashMap<String/* brokerName */, BrokerData> brokerAddrTable =
-            clusterInfoSerializeWrapper.getBrokerAddrTable();
+        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))
+            if (brokerAddrs.containsValue(addr)) {
                 return entry.getKey();
+            }
         }
-        throw new Exception(
-            "Make sure the specified broker addr exists or the nameserver 
which connected is correct.");
+        throw new Exception(ERROR_MESSAGE);
     }
 
 }
diff --git 
a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
 
b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
index 25d36ce..6cb3f18 100644
--- 
a/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
+++ 
b/tools/src/main/java/org/apache/rocketmq/tools/command/topic/DeleteTopicSubCommand.java
@@ -38,8 +38,8 @@ public class DeleteTopicSubCommand implements SubCommand {
         final String topic
     ) throws InterruptedException, MQBrokerException, RemotingException, 
MQClientException {
 
-        Set<String> masterSet = 
CommandUtil.fetchMasterAddrByClusterName(adminExt, clusterName);
-        adminExt.deleteTopicInBroker(masterSet, topic);
+        Set<String> brokerAddressSet = 
CommandUtil.fetchMasterAndSlaveAddrByClusterName(adminExt, clusterName);
+        adminExt.deleteTopicInBroker(brokerAddressSet, topic);
         System.out.printf("delete topic [%s] from cluster [%s] success.%n", 
topic, clusterName);
 
         Set<String> nameServerSet = null;

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to