Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
opencurve
Curve
提交
23bd3346
Curve
项目概览
opencurve
/
Curve
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Curve
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
23bd3346
编写于
8月 10, 2022
作者:
C
chenwei
提交者:
SiKu
8月 15, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix topology metric inaccurate when metaserver offline
Signed-off-by:
N
chenwei
<
461432360@qq.com
>
上级
07d3b063
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
0 deletion
+55
-0
curvefs/src/mds/topology/topology_metric.cpp
curvefs/src/mds/topology/topology_metric.cpp
+11
-0
curvefs/test/mds/topology/test_topology_metric.cpp
curvefs/test/mds/topology/test_topology_metric.cpp
+44
-0
未找到文件。
curvefs/src/mds/topology/topology_metric.cpp
浏览文件 @
23bd3346
...
...
@@ -161,6 +161,17 @@ void TopologyMetricService::UpdateTopologyMetrics() {
totalDiskUsed
+=
ix
->
second
->
diskUsed
.
get_value
();
totalMemoryThreshold
+=
ix
->
second
->
memoryThreshold
.
get_value
();
totalMemoryUsed
+=
ix
->
second
->
memoryUsed
.
get_value
();
// process the metric of metaserver which has no copyset
if
(
metaServerMetricInfo
.
find
(
msId
)
==
metaServerMetricInfo
.
end
())
{
auto
ix
=
gMetaServerMetrics
.
find
(
msId
);
if
(
ix
!=
gMetaServerMetrics
.
end
())
{
ix
->
second
->
scatterWidth
.
set_value
(
0
);
ix
->
second
->
copysetNum
.
set_value
(
0
);
ix
->
second
->
leaderNum
.
set_value
(
0
);
ix
->
second
->
partitionNum
.
set_value
(
0
);
}
}
}
it
->
second
->
metaServerNum
.
set_value
(
msIdInPool
.
size
());
...
...
curvefs/test/mds/topology/test_topology_metric.cpp
浏览文件 @
23bd3346
...
...
@@ -123,6 +123,14 @@ class TestTopologyMetric : public ::testing::Test {
<<
"should have PrepareAddPool()"
;
}
void
UpdateCopysetMembers
(
CopySetIdType
copysetId
,
PoolIdType
poolId
,
const
std
::
set
<
MetaServerIdType
>
&
members
)
{
CopySetInfo
cs
(
poolId
,
copysetId
);
cs
.
SetCopySetMembers
(
members
);
TopoStatusCode
ret
=
topology_
->
UpdateCopySetTopo
(
cs
);
ASSERT_EQ
(
TopoStatusCode
::
TOPO_OK
,
ret
);
}
void
PrepareAddPartition
(
PartitionIdType
partitionId
,
CopySetIdType
copysetId
,
PoolIdType
poolId
)
{
Partition
partition
;
...
...
@@ -208,6 +216,42 @@ TEST_F(TestTopologyMetric, TestUpdateTopologyMetricsOnePool) {
ASSERT_EQ
(
30
,
gPoolMetrics
[
poolId
]
->
inodeNum
.
get_value
());
ASSERT_EQ
(
300
,
gPoolMetrics
[
poolId
]
->
dentryNum
.
get_value
());
ASSERT_EQ
(
3
,
gPoolMetrics
[
poolId
]
->
partitionNum
.
get_value
());
// Simulate metaserver offline and migrate data to another metaserver
PrepareAddMetaServer
(
0x44
,
"host4"
,
"token4"
,
0x33
,
"127.0.0.1"
,
8890
);
std
::
set
<
MetaServerIdType
>
replicas2
;
replicas2
.
insert
(
0x41
);
replicas2
.
insert
(
0x42
);
replicas2
.
insert
(
0x44
);
UpdateCopysetMembers
(
copysetId
,
poolId
,
replicas2
);
testObj_
->
UpdateTopologyMetrics
();
ASSERT_EQ
(
0
,
gMetaServerMetrics
[
0x43
]
->
scatterWidth
.
get_value
());
ASSERT_EQ
(
0
,
gMetaServerMetrics
[
0x43
]
->
copysetNum
.
get_value
());
ASSERT_EQ
(
0
,
gMetaServerMetrics
[
0x43
]
->
leaderNum
.
get_value
());
ASSERT_EQ
(
100
*
1024
,
gMetaServerMetrics
[
0x43
]
->
diskThreshold
.
get_value
());
ASSERT_EQ
(
10
*
1024
,
gMetaServerMetrics
[
0x43
]
->
diskUsed
.
get_value
());
ASSERT_EQ
(
20
*
1024
,
gMetaServerMetrics
[
0x43
]
->
memoryUsed
.
get_value
());
ASSERT_EQ
(
0
,
gMetaServerMetrics
[
0x43
]
->
partitionNum
.
get_value
());
ASSERT_EQ
(
2
,
gMetaServerMetrics
[
0x44
]
->
scatterWidth
.
get_value
());
ASSERT_EQ
(
1
,
gMetaServerMetrics
[
0x44
]
->
copysetNum
.
get_value
());
ASSERT_EQ
(
0
,
gMetaServerMetrics
[
0x44
]
->
leaderNum
.
get_value
());
ASSERT_EQ
(
100
*
1024
,
gMetaServerMetrics
[
0x44
]
->
diskThreshold
.
get_value
());
ASSERT_EQ
(
10
*
1024
,
gMetaServerMetrics
[
0x44
]
->
diskUsed
.
get_value
());
ASSERT_EQ
(
20
*
1024
,
gMetaServerMetrics
[
0x44
]
->
memoryUsed
.
get_value
());
ASSERT_EQ
(
3
,
gMetaServerMetrics
[
0x44
]
->
partitionNum
.
get_value
());
ASSERT_EQ
(
1
,
gPoolMetrics
.
size
());
ASSERT_EQ
(
4
,
gPoolMetrics
[
poolId
]
->
metaServerNum
.
get_value
());
ASSERT_EQ
(
1
,
gPoolMetrics
[
poolId
]
->
copysetNum
.
get_value
());
ASSERT_EQ
(
100
*
1024
*
4
,
gPoolMetrics
[
poolId
]
->
diskThreshold
.
get_value
());
ASSERT_EQ
(
10
*
1024
*
4
,
gPoolMetrics
[
poolId
]
->
diskUsed
.
get_value
());
ASSERT_EQ
(
30
,
gPoolMetrics
[
poolId
]
->
inodeNum
.
get_value
());
ASSERT_EQ
(
300
,
gPoolMetrics
[
poolId
]
->
dentryNum
.
get_value
());
ASSERT_EQ
(
3
,
gPoolMetrics
[
poolId
]
->
partitionNum
.
get_value
());
}
}
// namespace topology
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录