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 2022/01/07 04:33:17 UTC

[GitHub] [rocketmq] zhangjidi2016 opened a new pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

zhangjidi2016 opened a new pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723


   **Make sure set the target branch to `develop`**
   
   ## What is the purpose of the change
   
   #3709
   When there are multiple brokers in the cluster, export the metadata file using -c, prefixed with the broker name.
   ![image](https://user-images.githubusercontent.com/18254437/148491993-8f9472a4-524e-4ca0-bb6e-6ff19c461dec.png)
   
   
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in [test module](https://github.com/apache/rocketmq/tree/master/test).
   - [x] Run `mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle` to make sure basic checks pass. Run `mvn clean install -DskipITs` to make sure unit-test pass. Run `mvn clean test-compile failsafe:integration-test`  to make sure integration-test pass.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] zhangjidi2016 commented on a change in pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
zhangjidi2016 commented on a change in pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#discussion_r780133667



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -126,18 +127,19 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
 
                     SubscriptionGroupWrapper subscriptionGroupWrapper = defaultMQAdminExt.getUserSubscriptionGroup(
                         addr, 10000);
+                    String brokerName = CommandUtil.fetchBrokerNameByAddr(defaultMQAdminExt, addr);
 
                     if (commandLine.hasOption('t')) {
-                        filePath = filePath + "/topic.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(topicConfigSerializeWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else if (commandLine.hasOption('g')) {
-                        filePath = filePath + "/subscriptionGroup.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(subscriptionGroupWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else {
+                        String exportFilePath = filePath + "/" + brokerName + "/topic.json";

Review comment:
       The issue is resolving by this pr(#3727),I will close it.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] yuz10 commented on a change in pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
yuz10 commented on a change in pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#discussion_r780068847



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -165,11 +167,10 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
                         result.put("rocketmqVersion", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
                         result.put("exportTime", System.currentTimeMillis());
 
-                        filePath = filePath + "/metadata.json";

Review comment:
       note that topicConfigMap is not new for current broker, it accumulates the previous broker queue numbers.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] coveralls edited a comment on pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#issuecomment-1007139361


   
   [![Coverage Status](https://coveralls.io/builds/45443272/badge)](https://coveralls.io/builds/45443272)
   
   Coverage decreased (-0.04%) to 53.229% when pulling **4b76cbea84e7e93fc1db78e2149ffa46ecabfa6b on zhangjidi2016:fix_exportMetadata** into **ed5f4e4eac71849bc479aee2db7cc931d262a184 on apache:develop**.
   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] yuz10 commented on a change in pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
yuz10 commented on a change in pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#discussion_r780063305



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -126,18 +127,19 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
 
                     SubscriptionGroupWrapper subscriptionGroupWrapper = defaultMQAdminExt.getUserSubscriptionGroup(
                         addr, 10000);
+                    String brokerName = CommandUtil.fetchBrokerNameByAddr(defaultMQAdminExt, addr);
 
                     if (commandLine.hasOption('t')) {
-                        filePath = filePath + "/topic.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(topicConfigSerializeWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else if (commandLine.hasOption('g')) {
-                        filePath = filePath + "/subscriptionGroup.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(subscriptionGroupWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else {
+                        String exportFilePath = filePath + "/" + brokerName + "/topic.json";

Review comment:
       should escape the special charactors in brokername to avoid invalid file path




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] zhangjidi2016 closed pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
zhangjidi2016 closed pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723


   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] coveralls commented on pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
coveralls commented on pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#issuecomment-1007139361


   
   [![Coverage Status](https://coveralls.io/builds/45442093/badge)](https://coveralls.io/builds/45442093)
   
   Coverage decreased (-0.04%) to 53.229% when pulling **7cda63f9ec091f0b491fc0a19bf0b4bc4698c804 on zhangjidi2016:fix_exportMetadata** into **ed5f4e4eac71849bc479aee2db7cc931d262a184 on apache:develop**.
   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] zhangjidi2016 commented on a change in pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
zhangjidi2016 commented on a change in pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#discussion_r780133667



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -126,18 +127,19 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
 
                     SubscriptionGroupWrapper subscriptionGroupWrapper = defaultMQAdminExt.getUserSubscriptionGroup(
                         addr, 10000);
+                    String brokerName = CommandUtil.fetchBrokerNameByAddr(defaultMQAdminExt, addr);
 
                     if (commandLine.hasOption('t')) {
-                        filePath = filePath + "/topic.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(topicConfigSerializeWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else if (commandLine.hasOption('g')) {
-                        filePath = filePath + "/subscriptionGroup.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(subscriptionGroupWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else {
+                        String exportFilePath = filePath + "/" + brokerName + "/topic.json";

Review comment:
       The issue is resolving by this pr(#3727),I will close it.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] yuz10 commented on a change in pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
yuz10 commented on a change in pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#discussion_r780063305



##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -126,18 +127,19 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
 
                     SubscriptionGroupWrapper subscriptionGroupWrapper = defaultMQAdminExt.getUserSubscriptionGroup(
                         addr, 10000);
+                    String brokerName = CommandUtil.fetchBrokerNameByAddr(defaultMQAdminExt, addr);
 
                     if (commandLine.hasOption('t')) {
-                        filePath = filePath + "/topic.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(topicConfigSerializeWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else if (commandLine.hasOption('g')) {
-                        filePath = filePath + "/subscriptionGroup.json";
-                        MixAll.string2FileNotSafe(JSON.toJSONString(subscriptionGroupWrapper, true), filePath);
-                        System.out.printf("export %s success", filePath);
-                        return;
-                    } else {
+                        String exportFilePath = filePath + "/" + brokerName + "/topic.json";

Review comment:
       should escape the special charactors in brokername to avoid invalid file path

##########
File path: tools/src/main/java/org/apache/rocketmq/tools/command/export/ExportMetadataCommand.java
##########
@@ -165,11 +167,10 @@ public void execute(CommandLine commandLine, Options options, RPCHook rpcHook)
                         result.put("rocketmqVersion", MQVersion.getVersionDesc(MQVersion.CURRENT_VERSION));
                         result.put("exportTime", System.currentTimeMillis());
 
-                        filePath = filePath + "/metadata.json";

Review comment:
       note that topicConfigMap is not new for current broker, it accumulates the previous broker queue numbers.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] coveralls edited a comment on pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
coveralls edited a comment on pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723#issuecomment-1007139361


   
   [![Coverage Status](https://coveralls.io/builds/45443272/badge)](https://coveralls.io/builds/45443272)
   
   Coverage decreased (-0.04%) to 53.229% when pulling **4b76cbea84e7e93fc1db78e2149ffa46ecabfa6b on zhangjidi2016:fix_exportMetadata** into **ed5f4e4eac71849bc479aee2db7cc931d262a184 on apache:develop**.
   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [rocketmq] zhangjidi2016 closed pull request #3723: [ISSUE #3709]Resolve export metadata errors while multiple brokers.

Posted by GitBox <gi...@apache.org>.
zhangjidi2016 closed pull request #3723:
URL: https://github.com/apache/rocketmq/pull/3723


   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org