You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2019/10/08 08:27:17 UTC

[GitHub] [rocketmq] duhenglucky commented on a change in pull request #1430: [ISSUE #1429]Update Broker's Topic Read or Write Perm failed.

duhenglucky commented on a change in pull request #1430: [ISSUE #1429]Update Broker's Topic Read or Write Perm failed.
URL: https://github.com/apache/rocketmq/pull/1430#discussion_r332387027
 
 

 ##########
 File path: tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateTopicPermSubCommand.java
 ##########
 @@ -67,46 +71,91 @@ public Options buildCommandlineOptions(Options options) {
     @Override
     public void execute(final CommandLine commandLine, final Options options,
         RPCHook rpcHook) throws SubCommandException {
+
         DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook);
         defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis()));
+
         try {
             defaultMQAdminExt.start();
-            TopicConfig topicConfig = new TopicConfig();
 
-            String topic = commandLine.getOptionValue('t').trim();
+            TopicConfig topicConfig = new TopicConfig();
+            String topic;
+            if (commandLine.hasOption('t')) {
+                topic = commandLine.getOptionValue('t').trim();
+            } else {
+                System.out.printf("topic paramter value must be need.%n");
+                return;
+            }
             TopicRouteData topicRouteData = defaultMQAdminExt.examineTopicRouteInfo(topic);
             assert topicRouteData != null;
             List<QueueData> queueDatas = topicRouteData.getQueueDatas();
             assert queueDatas != null && queueDatas.size() > 0;
-
             QueueData queueData = queueDatas.get(0);
             topicConfig.setTopicName(topic);
             topicConfig.setWriteQueueNums(queueData.getWriteQueueNums());
             topicConfig.setReadQueueNums(queueData.getReadQueueNums());
-            topicConfig.setPerm(queueData.getPerm());
             topicConfig.setTopicSysFlag(queueData.getTopicSynFlag());
-
             //new perm
-            int perm = Integer.parseInt(commandLine.getOptionValue('p').trim());
-            int oldPerm = topicConfig.getPerm();
-            if (perm == oldPerm) {
-                System.out.printf("new perm equals to the old one!%n");
+            int perm;
+            if (commandLine.hasOption('p')) {
+                perm = Integer.parseInt(commandLine.getOptionValue('p').trim());
+            } else {
+                System.out.printf("perm paramter value must be need.%n");
                 return;
             }
             topicConfig.setPerm(perm);
             if (commandLine.hasOption('b')) {
-                String addr = commandLine.getOptionValue('b').trim();
-                defaultMQAdminExt.createAndUpdateTopicConfig(addr, topicConfig);
-                System.out.printf("update topic perm from %s to %s in %s success.%n", oldPerm, perm, addr);
-                System.out.printf("%s%n", topicConfig);
-                return;
+                String brokerAddr = commandLine.getOptionValue('b').trim();
+                List<BrokerData> brokerDatas = topicRouteData.getBrokerDatas();
+                boolean isBrokerLegal = false;
 
 Review comment:
   Does it really need the isBrokerLegal variable here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services