Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
527382e4
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看板
提交
527382e4
编写于
12月 06, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean the items more than second gen
上级
d677d85c
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
78 addition
and
3 deletion
+78
-3
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+3
-2
broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingManager.java
...pache/rocketmq/broker/topic/TopicQueueMappingManager.java
+49
-1
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingDetail.java
.../rocketmq/common/statictopic/TopicQueueMappingDetail.java
+13
-0
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingInfo.java
...he/rocketmq/common/statictopic/TopicQueueMappingInfo.java
+12
-0
namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
...g/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
+1
-0
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
527382e4
...
...
@@ -353,13 +353,14 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
}
this
.
brokerController
.
getTopicConfigManager
().
deleteTopicConfig
(
topic
);
this
.
brokerController
.
getTopicQueueMappingManager
().
delete
(
topic
);
this
.
brokerController
.
getMessageStore
()
.
cleanUnusedTopic
(
this
.
brokerController
.
getTopicConfigManager
().
getTopicConfigTable
().
keySet
());
if
(
this
.
brokerController
.
getBrokerConfig
().
isAutoDeleteUnusedStats
())
{
this
.
brokerController
.
getBrokerStatsManager
().
onTopicDeleted
(
requestHeader
.
getTopic
());
}
//TODO delete the topic route
//this.brokerController.getTopicQueueMappingManager()
response
.
setCode
(
ResponseCode
.
SUCCESS
);
response
.
setRemark
(
null
);
return
response
;
...
...
broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingManager.java
浏览文件 @
527382e4
...
...
@@ -33,7 +33,9 @@ import org.apache.rocketmq.logging.InternalLoggerFactory;
import
org.apache.rocketmq.common.rpc.TopicQueueRequestHeader
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -61,6 +63,7 @@ public class TopicQueueMappingManager extends ConfigManager {
public
void
updateTopicQueueMapping
(
TopicQueueMappingDetail
newDetail
,
boolean
force
)
throws
Exception
{
boolean
locked
=
false
;
boolean
updated
=
false
;
TopicQueueMappingDetail
oldDetail
=
null
;
try
{
if
(
lock
.
tryLock
(
LOCK_TIMEOUT_MILLIS
,
TimeUnit
.
MILLISECONDS
))
{
locked
=
true
;
...
...
@@ -74,7 +77,7 @@ public class TopicQueueMappingManager extends ConfigManager {
TopicQueueMappingUtils
.
checkLogicQueueMappingItemOffset
(
items
);
});
TopicQueueMappingDetail
oldDetail
=
topicQueueMappingTable
.
get
(
newDetail
.
getTopic
());
oldDetail
=
topicQueueMappingTable
.
get
(
newDetail
.
getTopic
());
if
(
oldDetail
==
null
)
{
topicQueueMappingTable
.
put
(
newDetail
.
getTopic
(),
newDetail
);
updated
=
true
;
...
...
@@ -115,11 +118,23 @@ public class TopicQueueMappingManager extends ConfigManager {
}
if
(
updated
)
{
this
.
persist
();
log
.
info
(
"Update topic queue mapping from [{}] to [{}], force {}"
,
oldDetail
,
newDetail
,
force
);
}
}
}
public
void
delete
(
final
String
topic
)
{
TopicQueueMappingDetail
old
=
this
.
topicQueueMappingTable
.
remove
(
topic
);
if
(
old
!=
null
)
{
log
.
info
(
"delete topic queue mapping OK, topic queue mapping: {}"
,
old
);
this
.
dataVersion
.
nextVersion
();
this
.
persist
();
}
else
{
log
.
warn
(
"delete topic queue mapping failed, topic: {} not exists"
,
topic
);
}
}
public
TopicQueueMappingDetail
getTopicQueueMapping
(
String
topic
)
{
return
topicQueueMappingTable
.
get
(
topic
);
}
...
...
@@ -177,6 +192,9 @@ public class TopicQueueMappingManager extends ConfigManager {
//it is not static topic
return
new
TopicQueueMappingContext
(
requestHeader
.
getTopic
(),
requestHeader
.
getQueueId
(),
null
,
null
,
null
);
}
assert
mappingDetail
.
getBname
().
equals
(
this
.
brokerController
.
getBrokerConfig
().
getBrokerName
());
//If not find mappingItem, it encounters some errors
Integer
globalId
=
requestHeader
.
getQueueId
();
if
(
globalId
<
0
&&
!
selectOneWhenMiss
)
{
...
...
@@ -224,4 +242,34 @@ public class TopicQueueMappingManager extends ConfigManager {
}
public
void
cleanItemListMoreThanSecondGen
()
{
for
(
String
topic
:
topicQueueMappingTable
.
keySet
())
{
TopicQueueMappingDetail
mappingDetail
=
topicQueueMappingTable
.
get
(
topic
);
if
(
mappingDetail
==
null
||
mappingDetail
.
getHostedQueues
().
isEmpty
())
{
continue
;
}
if
(!
mappingDetail
.
getBname
().
equals
(
this
.
brokerController
.
getBrokerConfig
().
getBrokerName
()))
{
log
.
warn
(
"The TopicQueueMappingDetail [{}] should not exist in this broker"
,
mappingDetail
);
continue
;
}
Iterator
<
Map
.
Entry
<
Integer
,
List
<
LogicQueueMappingItem
>>>
it
=
mappingDetail
.
getHostedQueues
().
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
Map
.
Entry
<
Integer
,
List
<
LogicQueueMappingItem
>>
entry
=
it
.
next
();
Integer
queueId
=
entry
.
getKey
();
List
<
LogicQueueMappingItem
>
items
=
entry
.
getValue
();
if
(
items
.
size
()
<=
2
)
{
continue
;
}
LogicQueueMappingItem
leaderItem
=
items
.
get
(
items
.
size
()
-
1
);
LogicQueueMappingItem
secLeaderItem
=
items
.
get
(
items
.
size
()
-
2
);
if
(!
leaderItem
.
getBname
().
equals
(
mappingDetail
.
getBname
())
&&
!
secLeaderItem
.
getBname
().
equals
(
mappingDetail
.
getBname
()))
{
it
.
remove
();
log
.
info
(
"The topic queue {} {} is expired with items {}"
,
mappingDetail
.
getTopic
(),
queueId
,
items
);
}
}
}
}
}
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingDetail.java
浏览文件 @
527382e4
...
...
@@ -128,4 +128,17 @@ public class TopicQueueMappingDetail extends TopicQueueMappingInfo {
.
append
(
hostedQueues
)
.
toHashCode
();
}
@Override
public
String
toString
()
{
return
"TopicQueueMappingDetail{"
+
"hostedQueues="
+
hostedQueues
+
", topic='"
+
topic
+
'\''
+
", totalQueues="
+
totalQueues
+
", bname='"
+
bname
+
'\''
+
", epoch="
+
epoch
+
", dirty="
+
dirty
+
", currIdMap="
+
currIdMap
+
'}'
;
}
}
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingInfo.java
浏览文件 @
527382e4
...
...
@@ -124,4 +124,16 @@ public class TopicQueueMappingInfo extends RemotingSerializable {
.
append
(
currIdMap
)
.
toHashCode
();
}
@Override
public
String
toString
()
{
return
"TopicQueueMappingInfo{"
+
"topic='"
+
topic
+
'\''
+
", totalQueues="
+
totalQueues
+
", bname='"
+
bname
+
'\''
+
", epoch="
+
epoch
+
", dirty="
+
dirty
+
", currIdMap="
+
currIdMap
+
'}'
;
}
}
namesrv/src/main/java/org/apache/rocketmq/namesrv/routeinfo/RouteInfoManager.java
浏览文件 @
527382e4
...
...
@@ -169,6 +169,7 @@ public class RouteInfoManager {
topicQueueMappingInfoTable
.
put
(
entry
.
getKey
(),
new
HashMap
<
String
,
TopicQueueMappingInfo
>());
}
//Note asset brokerName equal entry.getValue().getBname()
//here use the mappingDetail.bname
topicQueueMappingInfoTable
.
get
(
entry
.
getKey
()).
put
(
entry
.
getValue
().
getBname
(),
entry
.
getValue
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录