You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2018/05/23 06:21:36 UTC
[rocketmq] 03/04: Show client IP only when required
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
commit 0499586eb0c78c35099dfe9842d691ed27e791c2
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Tue May 22 20:02:41 2018 +0800
Show client IP only when required
---
.../consumer/ConsumerProgressSubCommand.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
index 67a9197..7529601 100644
--- a/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
+++ b/tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
@@ -64,6 +64,10 @@ public class ConsumerProgressSubCommand implements SubCommand {
opt.setRequired(false);
options.addOption(opt);
+ Option optionShowClientIP = new Option("s", "showClientIP", true, "Show Client IP per Queue");
+ optionShowClientIP.setRequired(false);
+ options.addOption(optionShowClientIP);
+
return options;
}
@@ -92,13 +96,22 @@ public class ConsumerProgressSubCommand implements SubCommand {
try {
defaultMQAdminExt.start();
+
+ boolean showClientIP = commandLine.hasOption('s')
+ && "true".equalsIgnoreCase(commandLine.getOptionValue('s'));
+
if (commandLine.hasOption('g')) {
String consumerGroup = commandLine.getOptionValue('g').trim();
ConsumeStats consumeStats = defaultMQAdminExt.examineConsumeStats(consumerGroup);
List<MessageQueue> mqList = new LinkedList<MessageQueue>();
mqList.addAll(consumeStats.getOffsetTable().keySet());
Collections.sort(mqList);
- Map<MessageQueue, String> messageQueueAllocationResult = getMessageQueueAllocationResult(defaultMQAdminExt, consumerGroup);
+
+ Map<MessageQueue, String> messageQueueAllocationResult = null;
+ if (showClientIP) {
+ messageQueueAllocationResult = getMessageQueueAllocationResult(defaultMQAdminExt, consumerGroup);
+ }
+
System.out.printf("%-32s %-32s %-4s %-20s %-20s %-20s %-20s %s%n",
"#Topic",
"#Broker Name",
@@ -120,7 +133,11 @@ public class ConsumerProgressSubCommand implements SubCommand {
} catch (Exception e) {
}
- String clientIP = messageQueueAllocationResult.get(mq);
+ String clientIP = null;
+ if (showClientIP) {
+ clientIP = messageQueueAllocationResult.get(mq);
+ }
+
System.out.printf("%-32s %-32s %-4d %-20d %-20d %-20s %-20d %s%n",
UtilAll.frontStringAtLeast(mq.getTopic(), 32),
UtilAll.frontStringAtLeast(mq.getBrokerName(), 32),
--
To stop receiving notification emails like this one, please contact
lizhanhui@apache.org.