Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
46459426
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看板
未验证
提交
46459426
编写于
3月 24, 2021
作者:
P
panzhi
提交者:
GitHub
3月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE #2748] Fix deleteSubscriptionGroup not remove consumer offset
上级
735ecaa8
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
61 addition
and
4 deletion
+61
-4
broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
.../apache/rocketmq/broker/offset/ConsumerOffsetManager.java
+16
-0
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+4
-0
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+2
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
...protocol/header/DeleteSubscriptionGroupRequestHeader.java
+10
-0
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
...va/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
+7
-0
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
...rg/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+8
-1
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
...main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
+3
-0
tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
...ools/command/consumer/DeleteSubscriptionGroupCommand.java
+11
-2
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java
浏览文件 @
46459426
...
...
@@ -232,4 +232,20 @@ public class ConsumerOffsetManager extends ConfigManager {
}
}
public
void
removeOffset
(
final
String
group
)
{
Iterator
<
Entry
<
String
,
ConcurrentMap
<
Integer
,
Long
>>>
it
=
this
.
offsetTable
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Entry
<
String
,
ConcurrentMap
<
Integer
,
Long
>>
next
=
it
.
next
();
String
topicAtGroup
=
next
.
getKey
();
if
(
topicAtGroup
.
contains
(
group
))
{
String
[]
arrays
=
topicAtGroup
.
split
(
TOPIC_GROUP_SEPARATOR
);
if
(
arrays
.
length
==
2
&&
group
.
equals
(
arrays
[
1
]))
{
it
.
remove
();
log
.
warn
(
"clean group offset {}"
,
topicAtGroup
);
}
}
}
}
}
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
46459426
...
...
@@ -714,6 +714,10 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
this
.
brokerController
.
getSubscriptionGroupManager
().
deleteSubscriptionGroupConfig
(
requestHeader
.
getGroupName
());
if
(
requestHeader
.
isRemoveOffset
())
{
this
.
brokerController
.
getConsumerOffsetManager
().
removeOffset
(
requestHeader
.
getGroupName
());
}
if
(
this
.
brokerController
.
getBrokerConfig
().
isAutoDeleteUnusedStats
())
{
this
.
brokerController
.
getBrokerStatsManager
().
onGroupDeleted
(
requestHeader
.
getGroupName
());
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
46459426
...
...
@@ -1467,10 +1467,11 @@ public class MQClientAPIImpl {
throw
new
MQClientException
(
response
.
getCode
(),
response
.
getRemark
());
}
public
void
deleteSubscriptionGroup
(
final
String
addr
,
final
String
groupName
,
final
long
timeoutMillis
)
public
void
deleteSubscriptionGroup
(
final
String
addr
,
final
String
groupName
,
final
boolean
removeOffset
,
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
DeleteSubscriptionGroupRequestHeader
requestHeader
=
new
DeleteSubscriptionGroupRequestHeader
();
requestHeader
.
setGroupName
(
groupName
);
requestHeader
.
setRemoveOffset
(
removeOffset
);
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
DELETE_SUBSCRIPTIONGROUP
,
requestHeader
);
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
MixAll
.
brokerVIPChannel
(
this
.
clientConfig
.
isVipChannelEnabled
(),
addr
),
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/DeleteSubscriptionGroupRequestHeader.java
浏览文件 @
46459426
...
...
@@ -25,6 +25,8 @@ public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader
@CFNotNull
private
String
groupName
;
private
boolean
removeOffset
;
@Override
public
void
checkFields
()
throws
RemotingCommandException
{
}
...
...
@@ -36,4 +38,12 @@ public class DeleteSubscriptionGroupRequestHeader implements CommandCustomHeader
public
void
setGroupName
(
String
groupName
)
{
this
.
groupName
=
groupName
;
}
public
boolean
isRemoveOffset
()
{
return
removeOffset
;
}
public
void
setRemoveOffset
(
boolean
removeOffset
)
{
this
.
removeOffset
=
removeOffset
;
}
}
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
浏览文件 @
46459426
...
...
@@ -320,6 +320,13 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
defaultMQAdminExtImpl
.
deleteSubscriptionGroup
(
addr
,
groupName
);
}
@Override
public
void
deleteSubscriptionGroup
(
String
addr
,
String
groupName
,
boolean
removeOffset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
defaultMQAdminExtImpl
.
deleteSubscriptionGroup
(
addr
,
groupName
,
removeOffset
);
}
@Override
public
void
createAndUpdateKvConfig
(
String
namespace
,
String
key
,
String
value
)
throws
RemotingException
,
MQBrokerException
,
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
浏览文件 @
46459426
...
...
@@ -424,7 +424,14 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
public
void
deleteSubscriptionGroup
(
String
addr
,
String
groupName
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
mqClientInstance
.
getMQClientAPIImpl
().
deleteSubscriptionGroup
(
addr
,
groupName
,
timeoutMillis
);
this
.
mqClientInstance
.
getMQClientAPIImpl
().
deleteSubscriptionGroup
(
addr
,
groupName
,
false
,
timeoutMillis
);
}
@Override
public
void
deleteSubscriptionGroup
(
String
addr
,
String
groupName
,
boolean
removeOffset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
mqClientInstance
.
getMQClientAPIImpl
().
deleteSubscriptionGroup
(
addr
,
groupName
,
removeOffset
,
timeoutMillis
);
}
@Override
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
浏览文件 @
46459426
...
...
@@ -152,6 +152,9 @@ public interface MQAdminExt extends MQAdmin {
void
deleteSubscriptionGroup
(
final
String
addr
,
String
groupName
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
void
deleteSubscriptionGroup
(
final
String
addr
,
String
groupName
,
boolean
removeOffset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
void
createAndUpdateKvConfig
(
String
namespace
,
String
key
,
String
value
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
...
...
tools/src/main/java/org/apache/rocketmq/tools/command/consumer/DeleteSubscriptionGroupCommand.java
浏览文件 @
46459426
...
...
@@ -54,6 +54,10 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
opt
.
setRequired
(
true
);
options
.
addOption
(
opt
);
opt
=
new
Option
(
"r"
,
"removeOffset"
,
true
,
"remove offset"
);
opt
.
setRequired
(
false
);
options
.
addOption
(
opt
);
return
options
;
}
...
...
@@ -65,11 +69,16 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
// groupName
String
groupName
=
commandLine
.
getOptionValue
(
'g'
).
trim
();
boolean
removeOffset
=
false
;
if
(
commandLine
.
hasOption
(
'r'
))
{
removeOffset
=
Boolean
.
valueOf
(
commandLine
.
getOptionValue
(
"r"
).
trim
());
}
if
(
commandLine
.
hasOption
(
'b'
))
{
String
addr
=
commandLine
.
getOptionValue
(
'b'
).
trim
();
adminExt
.
start
();
adminExt
.
deleteSubscriptionGroup
(
addr
,
groupName
);
adminExt
.
deleteSubscriptionGroup
(
addr
,
groupName
,
removeOffset
);
System
.
out
.
printf
(
"delete subscription group [%s] from broker [%s] success.%n"
,
groupName
,
addr
);
...
...
@@ -80,7 +89,7 @@ public class DeleteSubscriptionGroupCommand implements SubCommand {
Set
<
String
>
masterSet
=
CommandUtil
.
fetchMasterAddrByClusterName
(
adminExt
,
clusterName
);
for
(
String
master
:
masterSet
)
{
adminExt
.
deleteSubscriptionGroup
(
master
,
groupName
);
adminExt
.
deleteSubscriptionGroup
(
master
,
groupName
,
removeOffset
);
System
.
out
.
printf
(
"delete subscription group [%s] from broker [%s] in cluster [%s] success.%n"
,
groupName
,
master
,
clusterName
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录