Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
45a64fd6
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
45a64fd6
编写于
3月 29, 2017
作者:
Z
Zhanhui Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include client IP per message queue of consumer progress command output
上级
ab013861
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
34 addition
and
7 deletion
+34
-7
tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
...mq/tools/command/consumer/ConsumerProgressSubCommand.java
+34
-7
未找到文件。
tools/src/main/java/org/apache/rocketmq/tools/command/consumer/ConsumerProgressSubCommand.java
浏览文件 @
45a64fd6
...
...
@@ -16,10 +16,6 @@
*/
package
org.apache.rocketmq.tools.command.consumer
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.apache.commons.cli.CommandLine
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Options
;
...
...
@@ -30,7 +26,9 @@ import org.apache.rocketmq.common.UtilAll;
import
org.apache.rocketmq.common.admin.ConsumeStats
;
import
org.apache.rocketmq.common.admin.OffsetWrapper
;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.protocol.body.Connection
;
import
org.apache.rocketmq.common.protocol.body.ConsumerConnection
;
import
org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo
;
import
org.apache.rocketmq.common.protocol.body.TopicList
;
import
org.apache.rocketmq.common.protocol.heartbeat.ConsumeType
;
import
org.apache.rocketmq.common.protocol.heartbeat.MessageModel
;
...
...
@@ -40,6 +38,13 @@ import org.apache.rocketmq.tools.command.SubCommand;
import
org.apache.rocketmq.tools.command.SubCommandException
;
import
org.slf4j.Logger
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
public
class
ConsumerProgressSubCommand
implements
SubCommand
{
private
final
Logger
log
=
ClientLogger
.
getLog
();
...
...
@@ -62,6 +67,24 @@ public class ConsumerProgressSubCommand implements SubCommand {
return
options
;
}
private
Map
<
MessageQueue
,
String
>
getMessageQueueAllocationResult
(
DefaultMQAdminExt
defaultMQAdminExt
,
String
groupName
)
{
Map
<
MessageQueue
,
String
>
results
=
new
HashMap
<>();
try
{
ConsumerConnection
consumerConnection
=
defaultMQAdminExt
.
examineConsumerConnectionInfo
(
groupName
);
for
(
Connection
connection
:
consumerConnection
.
getConnectionSet
())
{
String
clientId
=
connection
.
getClientId
();
ConsumerRunningInfo
consumerRunningInfo
=
defaultMQAdminExt
.
getConsumerRunningInfo
(
groupName
,
clientId
,
false
);
for
(
MessageQueue
messageQueue
:
consumerRunningInfo
.
getMqTable
().
keySet
())
{
results
.
put
(
messageQueue
,
clientId
.
split
(
"@"
)[
0
]);
}
}
}
catch
(
Exception
ignore
)
{
}
return
results
;
}
@Override
public
void
execute
(
CommandLine
commandLine
,
Options
options
,
RPCHook
rpcHook
)
throws
SubCommandException
{
DefaultMQAdminExt
defaultMQAdminExt
=
new
DefaultMQAdminExt
(
rpcHook
);
...
...
@@ -75,13 +98,14 @@ public class ConsumerProgressSubCommand implements SubCommand {
List
<
MessageQueue
>
mqList
=
new
LinkedList
<
MessageQueue
>();
mqList
.
addAll
(
consumeStats
.
getOffsetTable
().
keySet
());
Collections
.
sort
(
mqList
);
System
.
out
.
printf
(
"%-32s %-32s %-4s %-20s %-20s %-20s %s%n"
,
Map
<
MessageQueue
,
String
>
messageQueueAllocationResult
=
getMessageQueueAllocationResult
(
defaultMQAdminExt
,
consumerGroup
);
System
.
out
.
printf
(
"%-32s %-32s %-4s %-20s %-20s %-20s
%-20s
%s%n"
,
"#Topic"
,
"#Broker Name"
,
"#QID"
,
"#Broker Offset"
,
"#Consumer Offset"
,
"#Client IP"
,
"#Diff"
,
"#LastTime"
);
...
...
@@ -95,12 +119,15 @@ public class ConsumerProgressSubCommand implements SubCommand {
lastTime
=
UtilAll
.
formatDate
(
new
Date
(
offsetWrapper
.
getLastTimestamp
()),
UtilAll
.
YYYY_MM_DD_HH_MM_SS
);
}
catch
(
Exception
e
)
{
}
System
.
out
.
printf
(
"%-32s %-32s %-4d %-20d %-20d %-20d %s%n"
,
String
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
),
mq
.
getQueueId
(),
offsetWrapper
.
getBrokerOffset
(),
offsetWrapper
.
getConsumerOffset
(),
null
!=
clientIP
?
clientIP
:
"NA"
,
diff
,
lastTime
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录