Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
ad90cc16
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看板
提交
ad90cc16
编写于
12月 08, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish the slave sync logic for topic queue mapping
上级
a9addc3c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
6 deletion
+48
-6
broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
...n/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
+2
-2
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+11
-1
broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
...va/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
+12
-3
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigAndMappingSerializeWrapper.java
.../protocol/body/TopicConfigAndMappingSerializeWrapper.java
+23
-0
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/out/BrokerOuterAPI.java
浏览文件 @
ad90cc16
...
...
@@ -350,7 +350,7 @@ public class BrokerOuterAPI {
return
changedList
;
}
public
TopicConfigSerializeWrapper
getAllTopicConfig
(
public
TopicConfig
AndMapping
SerializeWrapper
getAllTopicConfig
(
final
String
addr
)
throws
RemotingConnectException
,
RemotingSendRequestException
,
RemotingTimeoutException
,
InterruptedException
,
MQBrokerException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
GET_ALL_TOPIC_CONFIG
,
null
);
...
...
@@ -359,7 +359,7 @@ public class BrokerOuterAPI {
assert
response
!=
null
;
switch
(
response
.
getCode
())
{
case
ResponseCode
.
SUCCESS
:
{
return
TopicConfigSerializeWrapper
.
decode
(
response
.
getBody
(),
TopicConfigSerializeWrapper
.
class
);
return
TopicConfigSerializeWrapper
.
decode
(
response
.
getBody
(),
TopicConfig
AndMapping
SerializeWrapper
.
class
);
}
default
:
break
;
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
ad90cc16
...
...
@@ -64,6 +64,7 @@ import org.apache.rocketmq.common.protocol.body.QueryConsumeQueueResponseBody;
import
org.apache.rocketmq.common.protocol.body.QueryConsumeTimeSpanBody
;
import
org.apache.rocketmq.common.protocol.body.QueryCorrectionOffsetBody
;
import
org.apache.rocketmq.common.protocol.body.QueueTimeSpan
;
import
org.apache.rocketmq.common.protocol.body.TopicConfigAndMappingSerializeWrapper
;
import
org.apache.rocketmq.common.protocol.body.TopicList
;
import
org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody
;
import
org.apache.rocketmq.common.protocol.header.CloneGroupOffsetRequestHeader
;
...
...
@@ -545,7 +546,16 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
// final GetAllTopicConfigResponseHeader responseHeader =
// (GetAllTopicConfigResponseHeader) response.readCustomHeader();
String
content
=
this
.
brokerController
.
getTopicConfigManager
().
encode
();
TopicConfigAndMappingSerializeWrapper
topicConfigAndMappingSerializeWrapper
=
new
TopicConfigAndMappingSerializeWrapper
();
topicConfigAndMappingSerializeWrapper
.
setDataVersion
(
this
.
brokerController
.
getTopicConfigManager
().
getDataVersion
());
topicConfigAndMappingSerializeWrapper
.
setTopicConfigTable
(
this
.
brokerController
.
getTopicConfigManager
().
getTopicConfigTable
());
topicConfigAndMappingSerializeWrapper
.
setMappingDataVersion
(
this
.
brokerController
.
getTopicQueueMappingManager
().
getDataVersion
());
topicConfigAndMappingSerializeWrapper
.
setTopicQueueMappingDetailMap
(
this
.
brokerController
.
getTopicQueueMappingManager
().
getTopicQueueMappingTable
());
String
content
=
topicConfigAndMappingSerializeWrapper
.
toJson
();
if
(
content
!=
null
&&
content
.
length
()
>
0
)
{
try
{
response
.
setBody
(
content
.
getBytes
(
MixAll
.
DEFAULT_CHARSET
));
...
...
broker/src/main/java/org/apache/rocketmq/broker/slave/SlaveSynchronize.java
浏览文件 @
ad90cc16
...
...
@@ -21,6 +21,7 @@ import org.apache.rocketmq.broker.BrokerController;
import
org.apache.rocketmq.broker.subscription.SubscriptionGroupManager
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.protocol.body.TopicConfigAndMappingSerializeWrapper
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
import
org.apache.rocketmq.common.protocol.body.ConsumerOffsetSerializeWrapper
;
...
...
@@ -56,7 +57,7 @@ public class SlaveSynchronize {
String
masterAddrBak
=
this
.
masterAddr
;
if
(
masterAddrBak
!=
null
&&
!
masterAddrBak
.
equals
(
brokerController
.
getBrokerAddr
()))
{
try
{
TopicConfigSerializeWrapper
topicWrapper
=
TopicConfig
AndMapping
SerializeWrapper
topicWrapper
=
this
.
brokerController
.
getBrokerOuterAPI
().
getAllTopicConfig
(
masterAddrBak
);
if
(!
this
.
brokerController
.
getTopicConfigManager
().
getDataVersion
()
.
equals
(
topicWrapper
.
getDataVersion
()))
{
...
...
@@ -67,9 +68,17 @@ public class SlaveSynchronize {
this
.
brokerController
.
getTopicConfigManager
().
getTopicConfigTable
()
.
putAll
(
topicWrapper
.
getTopicConfigTable
());
this
.
brokerController
.
getTopicConfigManager
().
persist
();
log
.
info
(
"Update slave topic config from master, {}"
,
masterAddrBak
);
}
if
(
topicWrapper
.
getTopicQueueMappingDetailMap
()
!=
null
&&
!
topicWrapper
.
getMappingDataVersion
().
equals
(
this
.
brokerController
.
getTopicQueueMappingManager
().
getDataVersion
()))
{
this
.
brokerController
.
getTopicQueueMappingManager
().
getDataVersion
()
.
assignNewOne
(
topicWrapper
.
getMappingDataVersion
());
this
.
brokerController
.
getTopicQueueMappingManager
().
getTopicQueueMappingTable
().
clear
();
this
.
brokerController
.
getTopicQueueMappingManager
().
getTopicQueueMappingTable
()
.
putAll
(
topicWrapper
.
getTopicQueueMappingDetailMap
());
this
.
brokerController
.
getTopicQueueMappingManager
().
persist
();
}
log
.
info
(
"Update slave topic config from master, {}"
,
masterAddrBak
);
}
catch
(
Exception
e
)
{
log
.
error
(
"SyncTopicConfig Exception, {}"
,
masterAddrBak
,
e
);
}
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigAndMappingSerializeWrapper.java
浏览文件 @
ad90cc16
...
...
@@ -17,6 +17,8 @@
package
org.apache.rocketmq.common.protocol.body
;
import
org.apache.rocketmq.common.DataVersion
;
import
org.apache.rocketmq.common.statictopic.TopicQueueMappingDetail
;
import
org.apache.rocketmq.common.statictopic.TopicQueueMappingInfo
;
import
java.util.Map
;
...
...
@@ -25,6 +27,11 @@ import java.util.concurrent.ConcurrentHashMap;
public
class
TopicConfigAndMappingSerializeWrapper
extends
TopicConfigSerializeWrapper
{
private
Map
<
String
/* topic */
,
TopicQueueMappingInfo
>
topicQueueMappingInfoMap
=
new
ConcurrentHashMap
<
String
,
TopicQueueMappingInfo
>();
private
Map
<
String
/* topic */
,
TopicQueueMappingDetail
>
topicQueueMappingDetailMap
=
new
ConcurrentHashMap
<
String
,
TopicQueueMappingDetail
>();
private
DataVersion
mappingDataVersion
=
new
DataVersion
();
public
Map
<
String
,
TopicQueueMappingInfo
>
getTopicQueueMappingInfoMap
()
{
return
topicQueueMappingInfoMap
;
}
...
...
@@ -33,6 +40,22 @@ public class TopicConfigAndMappingSerializeWrapper extends TopicConfigSerializeW
this
.
topicQueueMappingInfoMap
=
topicQueueMappingInfoMap
;
}
public
Map
<
String
,
TopicQueueMappingDetail
>
getTopicQueueMappingDetailMap
()
{
return
topicQueueMappingDetailMap
;
}
public
void
setTopicQueueMappingDetailMap
(
Map
<
String
,
TopicQueueMappingDetail
>
topicQueueMappingDetailMap
)
{
this
.
topicQueueMappingDetailMap
=
topicQueueMappingDetailMap
;
}
public
DataVersion
getMappingDataVersion
()
{
return
mappingDataVersion
;
}
public
void
setMappingDataVersion
(
DataVersion
mappingDataVersion
)
{
this
.
mappingDataVersion
=
mappingDataVersion
;
}
public
static
TopicConfigAndMappingSerializeWrapper
from
(
TopicConfigSerializeWrapper
wrapper
)
{
if
(
wrapper
instanceof
TopicConfigAndMappingSerializeWrapper
)
{
return
(
TopicConfigAndMappingSerializeWrapper
)
wrapper
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录