Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
c673cb73
R
Rocketmq
项目概览
s920243400
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
1
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看板
提交
c673cb73
编写于
11月 17, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use timestamp as the epoch to prevent some unknown problem
上级
a5af2cf5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
13 deletion
+14
-13
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingDetail.java
...a/org/apache/rocketmq/common/TopicQueueMappingDetail.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingInfo.java
...ava/org/apache/rocketmq/common/TopicQueueMappingInfo.java
+4
-4
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingUtils.java
...va/org/apache/rocketmq/common/TopicQueueMappingUtils.java
+4
-4
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigAndMappingSerializeWrapper.java
.../protocol/body/TopicConfigAndMappingSerializeWrapper.java
+1
-1
tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateStaticTopicSubCommand.java
...etmq/tools/command/topic/UpdateStaticTopicSubCommand.java
+4
-3
未找到文件。
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingDetail.java
浏览文件 @
c673cb73
...
...
@@ -29,7 +29,7 @@ public class TopicQueueMappingDetail extends TopicQueueMappingInfo {
// make sure this value is not null
private
ConcurrentMap
<
Integer
/*global id*/
,
ImmutableList
<
LogicQueueMappingItem
>>
hostedQueues
=
new
ConcurrentHashMap
<
Integer
,
ImmutableList
<
LogicQueueMappingItem
>>();
public
TopicQueueMappingDetail
(
String
topic
,
int
totalQueues
,
String
bname
,
int
epoch
)
{
public
TopicQueueMappingDetail
(
String
topic
,
int
totalQueues
,
String
bname
,
long
epoch
)
{
super
(
topic
,
totalQueues
,
bname
,
epoch
);
buildIdMap
();
}
...
...
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingInfo.java
浏览文件 @
c673cb73
...
...
@@ -28,14 +28,14 @@ public class TopicQueueMappingInfo extends RemotingSerializable {
String
topic
;
// redundant field
int
totalQueues
;
String
bname
;
//identify the hosted broker name
int
epoch
;
//important to fence the old dirty data
long
epoch
;
//important to fence the old dirty data
boolean
dirty
;
//indicate if the data is dirty
//register to broker to construct the route
transient
ConcurrentMap
<
Integer
/*logicId*/
,
Integer
/*physicalId*/
>
currIdMap
=
new
ConcurrentHashMap
<
Integer
,
Integer
>();
//register to broker to help detect remapping failure
transient
ConcurrentMap
<
Integer
/*logicId*/
,
Integer
/*physicalId*/
>
prevIdMap
=
new
ConcurrentHashMap
<
Integer
,
Integer
>();
public
TopicQueueMappingInfo
(
String
topic
,
int
totalQueues
,
String
bname
,
int
epoch
)
{
public
TopicQueueMappingInfo
(
String
topic
,
int
totalQueues
,
String
bname
,
long
epoch
)
{
this
.
topic
=
topic
;
this
.
totalQueues
=
totalQueues
;
this
.
bname
=
bname
;
...
...
@@ -64,11 +64,11 @@ public class TopicQueueMappingInfo extends RemotingSerializable {
return
topic
;
}
public
int
getEpoch
()
{
public
long
getEpoch
()
{
return
epoch
;
}
public
void
setEpoch
(
int
epoch
)
{
public
void
setEpoch
(
long
epoch
)
{
this
.
epoch
=
epoch
;
}
...
...
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingUtils.java
浏览文件 @
c673cb73
...
...
@@ -89,8 +89,8 @@ public class TopicQueueMappingUtils {
return
new
MappingAllocator
(
idToBroker
,
brokerNumMap
);
}
public
static
Map
.
Entry
<
Integer
,
Integer
>
findMaxEpochAndQueueNum
(
List
<
TopicQueueMappingDetail
>
mappingDetailList
)
{
int
epoch
=
-
1
;
public
static
Map
.
Entry
<
Long
,
Integer
>
findMaxEpochAndQueueNum
(
List
<
TopicQueueMappingDetail
>
mappingDetailList
)
{
long
epoch
=
-
1
;
int
queueNum
=
0
;
for
(
TopicQueueMappingDetail
mappingDetail
:
mappingDetailList
)
{
if
(
mappingDetail
.
getEpoch
()
>
epoch
)
{
...
...
@@ -100,14 +100,14 @@ public class TopicQueueMappingUtils {
queueNum
=
mappingDetail
.
getTotalQueues
();
}
}
return
new
AbstractMap
.
SimpleImmutableEntry
<
Integer
,
Integer
>(
epoch
,
queueNum
);
return
new
AbstractMap
.
SimpleImmutableEntry
<
Long
,
Integer
>(
epoch
,
queueNum
);
}
public
static
Map
<
Integer
,
ImmutableList
<
LogicQueueMappingItem
>>
buildMappingItems
(
List
<
TopicQueueMappingDetail
>
mappingDetailList
,
boolean
replace
)
{
Collections
.
sort
(
mappingDetailList
,
new
Comparator
<
TopicQueueMappingDetail
>()
{
@Override
public
int
compare
(
TopicQueueMappingDetail
o1
,
TopicQueueMappingDetail
o2
)
{
return
o2
.
getEpoch
()
-
o1
.
getEpoch
(
);
return
(
int
)(
o2
.
getEpoch
()
-
o1
.
getEpoch
()
);
}
});
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigAndMappingSerializeWrapper.java
浏览文件 @
c673cb73
...
...
@@ -35,7 +35,7 @@ public class TopicConfigAndMappingSerializeWrapper extends TopicConfigSerializeW
public
static
TopicConfigAndMappingSerializeWrapper
from
(
TopicConfigSerializeWrapper
wrapper
)
{
if
(
wrapper
instanceof
TopicConfigAndMappingSerializeWrapper
)
{
return
(
TopicConfigAndMappingSerializeWrapper
)
wrapper
;
return
(
TopicConfigAndMappingSerializeWrapper
)
wrapper
;
}
TopicConfigAndMappingSerializeWrapper
mappingSerializeWrapper
=
new
TopicConfigAndMappingSerializeWrapper
();
mappingSerializeWrapper
.
setDataVersion
(
wrapper
.
getDataVersion
());
...
...
tools/src/main/java/org/apache/rocketmq/tools/command/topic/UpdateStaticTopicSubCommand.java
浏览文件 @
c673cb73
...
...
@@ -134,7 +134,7 @@ public class UpdateStaticTopicSubCommand implements SubCommand {
}
}
Map
.
Entry
<
Integer
,
Integer
>
maxEpochAndNum
=
new
AbstractMap
.
SimpleImmutableEntry
<>(-
1
,
queueNum
);
Map
.
Entry
<
Long
,
Integer
>
maxEpochAndNum
=
new
AbstractMap
.
SimpleImmutableEntry
<>(
System
.
currentTimeMillis
()
,
queueNum
);
if
(!
existedTopicConfigMap
.
isEmpty
())
{
//make sure it it not null
existedTopicConfigMap
.
forEach
((
key
,
value
)
->
{
...
...
@@ -155,7 +155,7 @@ public class UpdateStaticTopicSubCommand implements SubCommand {
List
<
TopicQueueMappingDetail
>
detailList
=
existedTopicConfigMap
.
values
().
stream
().
map
(
TopicConfigAndQueueMapping:
:
getMappingDetail
).
collect
(
Collectors
.
toList
());
//check the epoch and qnum
maxEpochAndNum
=
TopicQueueMappingUtils
.
findMaxEpochAndQueueNum
(
detailList
);
final
Map
.
Entry
<
Integer
,
Integer
>
tmpMaxEpochAndNum
=
maxEpochAndNum
;
final
Map
.
Entry
<
Long
,
Integer
>
tmpMaxEpochAndNum
=
maxEpochAndNum
;
detailList
.
forEach
(
mappingDetail
->
{
if
(
tmpMaxEpochAndNum
.
getKey
()
!=
mappingDetail
.
getEpoch
())
{
throw
new
RuntimeException
(
String
.
format
(
"epoch dose not match %d != %d in %s"
,
tmpMaxEpochAndNum
.
getKey
(),
mappingDetail
.
getEpoch
(),
mappingDetail
.
getBname
()));
...
...
@@ -200,7 +200,7 @@ public class UpdateStaticTopicSubCommand implements SubCommand {
Map
<
Integer
,
String
>
newIdToBroker
=
allocator
.
getIdToBroker
();
//construct the topic configAndMapping
int
epoch
=
maxEpochAndNum
.
getKey
()
+
1
;
long
epoch
=
Math
.
max
(
maxEpochAndNum
.
getKey
()
+
1000
,
System
.
currentTimeMillis
())
;
newIdToBroker
.
forEach
(
(
queueId
,
broker
)
->
{
TopicConfigAndQueueMapping
configMapping
;
if
(!
existedTopicConfigMap
.
containsKey
(
broker
))
{
...
...
@@ -218,6 +218,7 @@ public class UpdateStaticTopicSubCommand implements SubCommand {
configMapping
.
getMappingDetail
().
putMappingInfo
(
queueId
,
ImmutableList
.
of
(
mappingItem
));
});
//If some succeed, and others fail, it will cause inconsistent data
for
(
Map
.
Entry
<
String
,
TopicConfigAndQueueMapping
>
entry
:
existedTopicConfigMap
.
entrySet
())
{
String
broker
=
entry
.
getKey
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
broker
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录