Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
4e9b0974
R
Rocketmq
项目概览
小五666\n哈哈
/
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看板
提交
4e9b0974
编写于
11月 19, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check the correctness of logic items
上级
f05cfb92
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
1 deletion
+68
-1
common/src/main/java/org/apache/rocketmq/common/statictopic/LogicQueueMappingItem.java
...he/rocketmq/common/statictopic/LogicQueueMappingItem.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingUtils.java
...e/rocketmq/common/statictopic/TopicQueueMappingUtils.java
+67
-0
未找到文件。
common/src/main/java/org/apache/rocketmq/common/statictopic/LogicQueueMappingItem.java
浏览文件 @
4e9b0974
...
...
@@ -7,7 +7,7 @@ public class LogicQueueMappingItem {
private
String
bname
;
private
long
logicOffset
;
// the start of the logic offset
private
long
startOffset
;
// the start of the physical offset, included
private
long
endOffset
;
// the end of the physical offset, excluded
private
long
endOffset
=
-
1
;
// the end of the physical offset, excluded
private
long
timeOfStart
=
-
1
;
// mutable
private
long
timeOfEnd
=
-
1
;
// mutable
...
...
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingUtils.java
浏览文件 @
4e9b0974
...
...
@@ -162,6 +162,72 @@ public class TopicQueueMappingUtils {
return
new
AbstractMap
.
SimpleEntry
<
Long
,
Integer
>(
maxEpoch
,
maxNum
);
}
public
static
void
checkLogicQueueMappingItemOffset
(
ImmutableList
<
LogicQueueMappingItem
>
oldItems
,
ImmutableList
<
LogicQueueMappingItem
>
newItems
)
{
if
(
oldItems
==
null
||
oldItems
.
isEmpty
())
{
return
;
}
if
(
newItems
==
null
||
newItems
.
isEmpty
()
||
newItems
.
size
()
<
oldItems
.
size
())
{
throw
new
RuntimeException
(
"The new item list is smaller than old ones"
);
}
int
iold
=
0
,
inew
=
0
;
while
(
iold
<
oldItems
.
size
()
&&
inew
<
newItems
.
size
())
{
LogicQueueMappingItem
newItem
=
newItems
.
get
(
inew
);
LogicQueueMappingItem
oldItem
=
oldItems
.
get
(
iold
);
if
(
newItem
.
getGen
()
<
oldItem
.
getGen
())
{
inew
++;
continue
;
}
else
if
(
oldItem
.
getGen
()
<
newItem
.
getGen
()){
throw
new
RuntimeException
(
"The gen is not correct for old item"
);
}
else
{
assert
oldItem
.
getBname
().
equals
(
newItem
.
getBname
());
assert
oldItem
.
getQueueId
()
==
newItem
.
getQueueId
();
assert
oldItem
.
getStartOffset
()
==
newItem
.
getStartOffset
();
if
(
oldItem
.
getLogicOffset
()
!=
-
1
)
{
assert
oldItem
.
getLogicOffset
()
==
newItem
.
getLogicOffset
();
}
iold
++;
inew
++;
}
}
}
public
static
void
checkLogicQueueMappingItemOffset
(
ImmutableList
<
LogicQueueMappingItem
>
items
)
{
if
(
items
==
null
||
items
.
isEmpty
())
{
return
;
}
int
lastGen
=
-
1
;
long
lastOffset
=
-
1
;
for
(
int
i
=
items
.
size
()
-
1
;
i
>=
0
;
i
--)
{
LogicQueueMappingItem
item
=
items
.
get
(
i
);
if
(
item
.
getStartOffset
()
<
0
||
item
.
getGen
()
<
0
||
item
.
getQueueId
()
<
0
)
{
throw
new
RuntimeException
(
"The field is illegal, should not be negative"
);
}
if
(
lastGen
!=
-
1
&&
item
.
getGen
()
>=
lastGen
)
{
throw
new
RuntimeException
(
"The gen dose not increase monotonically"
);
}
if
(
item
.
getEndOffset
()
!=
-
1
&&
item
.
getEndOffset
()
<
item
.
getStartOffset
())
{
throw
new
RuntimeException
(
"The endOffset is smaller than the start offset"
);
}
if
(
lastOffset
!=
-
1
&&
item
.
getLogicOffset
()
!=
-
1
)
{
if
(
item
.
getLogicOffset
()
>=
lastOffset
)
{
throw
new
RuntimeException
(
"The base logic offset dose not increase monotonically"
);
}
if
(
item
.
computeMaxStaticQueueOffset
()
>=
lastOffset
)
{
throw
new
RuntimeException
(
"The max logic offset dose not increase monotonically"
);
}
}
lastGen
=
item
.
getGen
();
lastOffset
=
item
.
getLogicOffset
();
}
}
public
static
Map
<
Integer
,
TopicQueueMappingOne
>
checkAndBuildMappingItems
(
List
<
TopicQueueMappingDetail
>
mappingDetailList
,
boolean
replace
,
boolean
checkConsistence
)
{
Collections
.
sort
(
mappingDetailList
,
new
Comparator
<
TopicQueueMappingDetail
>()
{
@Override
...
...
@@ -178,6 +244,7 @@ public class TopicQueueMappingUtils {
}
for
(
Map
.
Entry
<
Integer
,
ImmutableList
<
LogicQueueMappingItem
>>
entry
:
mappingDetail
.
getHostedQueues
().
entrySet
())
{
Integer
globalid
=
entry
.
getKey
();
checkLogicQueueMappingItemOffset
(
entry
.
getValue
());
String
leaderBrokerName
=
getLeaderBroker
(
entry
.
getValue
());
if
(!
leaderBrokerName
.
equals
(
mappingDetail
.
getBname
()))
{
//not the leader
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录