Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
8c793c09
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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看板
提交
8c793c09
编写于
3月 29, 2017
作者:
Z
Zhanhui Li
提交者:
dongeforever
6月 06, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include client IP per message queue of consumer progress command output
上级
34012960
变更
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
浏览文件 @
8c793c09
...
@@ -16,10 +16,6 @@
...
@@ -16,10 +16,6 @@
*/
*/
package
org.apache.rocketmq.tools.command.consumer
;
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.CommandLine
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Option
;
import
org.apache.commons.cli.Options
;
import
org.apache.commons.cli.Options
;
...
@@ -30,7 +26,9 @@ import org.apache.rocketmq.common.UtilAll;
...
@@ -30,7 +26,9 @@ import org.apache.rocketmq.common.UtilAll;
import
org.apache.rocketmq.common.admin.ConsumeStats
;
import
org.apache.rocketmq.common.admin.ConsumeStats
;
import
org.apache.rocketmq.common.admin.OffsetWrapper
;
import
org.apache.rocketmq.common.admin.OffsetWrapper
;
import
org.apache.rocketmq.common.message.MessageQueue
;
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.ConsumerConnection
;
import
org.apache.rocketmq.common.protocol.body.ConsumerRunningInfo
;
import
org.apache.rocketmq.common.protocol.body.TopicList
;
import
org.apache.rocketmq.common.protocol.body.TopicList
;
import
org.apache.rocketmq.common.protocol.heartbeat.ConsumeType
;
import
org.apache.rocketmq.common.protocol.heartbeat.ConsumeType
;
import
org.apache.rocketmq.common.protocol.heartbeat.MessageModel
;
import
org.apache.rocketmq.common.protocol.heartbeat.MessageModel
;
...
@@ -40,6 +38,13 @@ import org.apache.rocketmq.tools.command.SubCommand;
...
@@ -40,6 +38,13 @@ import org.apache.rocketmq.tools.command.SubCommand;
import
org.apache.rocketmq.tools.command.SubCommandException
;
import
org.apache.rocketmq.tools.command.SubCommandException
;
import
org.slf4j.Logger
;
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
{
public
class
ConsumerProgressSubCommand
implements
SubCommand
{
private
final
Logger
log
=
ClientLogger
.
getLog
();
private
final
Logger
log
=
ClientLogger
.
getLog
();
...
@@ -62,6 +67,24 @@ public class ConsumerProgressSubCommand implements SubCommand {
...
@@ -62,6 +67,24 @@ public class ConsumerProgressSubCommand implements SubCommand {
return
options
;
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
@Override
public
void
execute
(
CommandLine
commandLine
,
Options
options
,
RPCHook
rpcHook
)
throws
SubCommandException
{
public
void
execute
(
CommandLine
commandLine
,
Options
options
,
RPCHook
rpcHook
)
throws
SubCommandException
{
DefaultMQAdminExt
defaultMQAdminExt
=
new
DefaultMQAdminExt
(
rpcHook
);
DefaultMQAdminExt
defaultMQAdminExt
=
new
DefaultMQAdminExt
(
rpcHook
);
...
@@ -75,13 +98,14 @@ public class ConsumerProgressSubCommand implements SubCommand {
...
@@ -75,13 +98,14 @@ public class ConsumerProgressSubCommand implements SubCommand {
List
<
MessageQueue
>
mqList
=
new
LinkedList
<
MessageQueue
>();
List
<
MessageQueue
>
mqList
=
new
LinkedList
<
MessageQueue
>();
mqList
.
addAll
(
consumeStats
.
getOffsetTable
().
keySet
());
mqList
.
addAll
(
consumeStats
.
getOffsetTable
().
keySet
());
Collections
.
sort
(
mqList
);
Collections
.
sort
(
mqList
);
Map
<
MessageQueue
,
String
>
messageQueueAllocationResult
=
getMessageQueueAllocationResult
(
defaultMQAdminExt
,
consumerGroup
);
System
.
out
.
printf
(
"%-32s %-32s %-4s %-20s %-20s %-20s %s%n"
,
System
.
out
.
printf
(
"%-32s %-32s %-4s %-20s %-20s %-20s
%-20s
%s%n"
,
"#Topic"
,
"#Topic"
,
"#Broker Name"
,
"#Broker Name"
,
"#QID"
,
"#QID"
,
"#Broker Offset"
,
"#Broker Offset"
,
"#Consumer Offset"
,
"#Consumer Offset"
,
"#Client IP"
,
"#Diff"
,
"#Diff"
,
"#LastTime"
);
"#LastTime"
);
...
@@ -95,12 +119,15 @@ public class ConsumerProgressSubCommand implements SubCommand {
...
@@ -95,12 +119,15 @@ public class ConsumerProgressSubCommand implements SubCommand {
lastTime
=
UtilAll
.
formatDate
(
new
Date
(
offsetWrapper
.
getLastTimestamp
()),
UtilAll
.
YYYY_MM_DD_HH_MM_SS
);
lastTime
=
UtilAll
.
formatDate
(
new
Date
(
offsetWrapper
.
getLastTimestamp
()),
UtilAll
.
YYYY_MM_DD_HH_MM_SS
);
}
catch
(
Exception
e
)
{
}
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
.
getTopic
(),
32
),
UtilAll
.
frontStringAtLeast
(
mq
.
getBrokerName
(),
32
),
UtilAll
.
frontStringAtLeast
(
mq
.
getBrokerName
(),
32
),
mq
.
getQueueId
(),
mq
.
getQueueId
(),
offsetWrapper
.
getBrokerOffset
(),
offsetWrapper
.
getBrokerOffset
(),
offsetWrapper
.
getConsumerOffset
(),
offsetWrapper
.
getConsumerOffset
(),
null
!=
clientIP
?
clientIP
:
"NA"
,
diff
,
diff
,
lastTime
lastTime
);
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录