Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
90b3f009
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
90b3f009
编写于
4月 25, 2023
作者:
X
Xiaoyu Wang
提交者:
GitHub
4月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21069 from taosdata/fix/change-learner-config-format
change learner config format
上级
d3a53f17
2fd9640a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
21 deletion
+13
-21
source/dnode/vnode/src/vnd/vnodeCfg.c
source/dnode/vnode/src/vnd/vnodeCfg.c
+7
-13
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+6
-8
未找到文件。
source/dnode/vnode/src/vnd/vnodeCfg.c
浏览文件 @
90b3f009
...
...
@@ -60,19 +60,19 @@ int vnodeCheckCfg(const SVnodeCfg *pCfg) {
const
char
*
vnodeRoleToStr
(
ESyncRole
role
)
{
switch
(
role
)
{
case
TAOS_SYNC_ROLE_VOTER
:
return
"
voter
"
;
return
"
true
"
;
case
TAOS_SYNC_ROLE_LEARNER
:
return
"
learner
"
;
return
"
false
"
;
default:
return
"unknown"
;
}
}
const
ESyncRole
vnodeStrToRole
(
char
*
str
)
{
if
(
strcmp
(
str
,
"
voter
"
)
==
0
){
if
(
strcmp
(
str
,
"
true
"
)
==
0
){
return
TAOS_SYNC_ROLE_VOTER
;
}
if
(
strcmp
(
str
,
"
learner
"
)
==
0
){
if
(
strcmp
(
str
,
"
false
"
)
==
0
){
return
TAOS_SYNC_ROLE_LEARNER
;
}
...
...
@@ -139,7 +139,6 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
if
(
tjsonAddIntegerToObject
(
pJson
,
"hashSuffix"
,
pCfg
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"syncCfg.replicaNum"
,
pCfg
->
syncCfg
.
replicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"syncCfg.totalReplicaNum"
,
pCfg
->
syncCfg
.
totalReplicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"syncCfg.myIndex"
,
pCfg
->
syncCfg
.
myIndex
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"vndStats.stables"
,
pCfg
->
vndStats
.
numOfSTables
)
<
0
)
return
-
1
;
...
...
@@ -161,7 +160,7 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
if
(
tjsonAddStringToObject
(
info
,
"nodeFqdn"
,
pNode
->
nodeFqdn
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodeId"
,
pNode
->
nodeId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
pNode
->
clusterId
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"
nodeRole
"
,
vnodeRoleToStr
(
pNode
->
nodeRole
))
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"
isReplica
"
,
vnodeRoleToStr
(
pNode
->
nodeRole
))
<
0
)
return
-
1
;
if
(
tjsonAddItemToArray
(
nodeInfo
,
info
)
<
0
)
return
-
1
;
vDebug
(
"vgId:%d, encode config, replica:%d ep:%s:%u dnode:%d"
,
pCfg
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
pNode
->
nodeId
);
...
...
@@ -259,8 +258,6 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue
(
pJson
,
"syncCfg.replicaNum"
,
pCfg
->
syncCfg
.
replicaNum
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"syncCfg.totalReplicaNum"
,
pCfg
->
syncCfg
.
totalReplicaNum
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"syncCfg.myIndex"
,
pCfg
->
syncCfg
.
myIndex
,
code
);
if
(
code
<
0
)
return
-
1
;
...
...
@@ -277,10 +274,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
SJson
*
nodeInfo
=
tjsonGetObjectItem
(
pJson
,
"syncCfg.nodeInfo"
);
int
arraySize
=
tjsonGetArraySize
(
nodeInfo
);
if
(
pCfg
->
syncCfg
.
totalReplicaNum
==
0
&&
pCfg
->
syncCfg
.
replicaNum
>
0
){
pCfg
->
syncCfg
.
totalReplicaNum
=
pCfg
->
syncCfg
.
replicaNum
;
}
if
(
arraySize
!=
pCfg
->
syncCfg
.
totalReplicaNum
)
return
-
1
;
pCfg
->
syncCfg
.
totalReplicaNum
=
arraySize
;
vDebug
(
"vgId:%d, decode config, replicas:%d totalReplicas:%d selfIndex:%d"
,
pCfg
->
vgId
,
pCfg
->
syncCfg
.
replicaNum
,
pCfg
->
syncCfg
.
totalReplicaNum
,
pCfg
->
syncCfg
.
myIndex
);
...
...
@@ -296,7 +290,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue
(
info
,
"clusterId"
,
pNode
->
clusterId
,
code
);
if
(
code
<
0
)
return
-
1
;
char
role
[
10
]
=
{
0
};
code
=
tjsonGetStringValue
(
info
,
"
nodeRole
"
,
role
);
code
=
tjsonGetStringValue
(
info
,
"
isReplica
"
,
role
);
if
(
code
<
0
)
return
-
1
;
if
(
strlen
(
role
)
!=
0
){
pNode
->
nodeRole
=
vnodeStrToRole
(
role
);
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
90b3f009
...
...
@@ -21,19 +21,19 @@
const
char
*
syncRoleToStr
(
ESyncRole
role
)
{
switch
(
role
)
{
case
TAOS_SYNC_ROLE_VOTER
:
return
"
voter
"
;
return
"
true
"
;
case
TAOS_SYNC_ROLE_LEARNER
:
return
"
learner
"
;
return
"
false
"
;
default:
return
"unknown"
;
}
}
const
ESyncRole
syncStrToRole
(
char
*
str
)
{
if
(
strcmp
(
str
,
"
voter
"
)
==
0
){
if
(
strcmp
(
str
,
"
true
"
)
==
0
){
return
TAOS_SYNC_ROLE_VOTER
;
}
if
(
strcmp
(
str
,
"
learner
"
)
==
0
){
if
(
strcmp
(
str
,
"
false
"
)
==
0
){
return
TAOS_SYNC_ROLE_LEARNER
;
}
...
...
@@ -42,7 +42,6 @@ const ESyncRole syncStrToRole(char* str) {
static
int32_t
syncEncodeSyncCfg
(
const
void
*
pObj
,
SJson
*
pJson
)
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
if
(
tjsonAddDoubleToObject
(
pJson
,
"totalReplicaNum"
,
pCfg
->
totalReplicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAddDoubleToObject
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAddDoubleToObject
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
)
<
0
)
return
-
1
;
...
...
@@ -56,7 +55,7 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
if
(
tjsonAddStringToObject
(
info
,
"nodeFqdn"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"nodeId"
,
pCfg
->
nodeInfo
[
i
].
nodeId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"
nodeRole
"
,
syncRoleToStr
(
pCfg
->
nodeInfo
[
i
].
nodeRole
))
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"
isReplica
"
,
syncRoleToStr
(
pCfg
->
nodeInfo
[
i
].
nodeRole
))
<
0
)
return
-
1
;
if
(
tjsonAddItemToArray
(
nodeInfo
,
info
)
<
0
)
return
-
1
;
}
...
...
@@ -133,7 +132,6 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
int32_t
code
=
0
;
tjsonGetInt32ValueFromDouble
(
pJson
,
"totalReplicaNum"
,
pCfg
->
totalReplicaNum
,
code
);
tjsonGetInt32ValueFromDouble
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
,
code
);
if
(
code
<
0
)
return
-
1
;
tjsonGetInt32ValueFromDouble
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
,
code
);
...
...
@@ -153,7 +151,7 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
tjsonGetNumberValue
(
info
,
"nodeId"
,
pCfg
->
nodeInfo
[
i
].
nodeId
,
code
);
tjsonGetNumberValue
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
,
code
);
char
role
[
10
]
=
{
0
};
code
=
tjsonGetStringValue
(
info
,
"
nodeRole
"
,
role
);
code
=
tjsonGetStringValue
(
info
,
"
isReplica
"
,
role
);
if
(
code
<
0
)
return
-
1
;
if
(
strlen
(
role
)
!=
0
){
pCfg
->
nodeInfo
[
i
].
nodeRole
=
syncStrToRole
(
role
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录