Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01209614
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看板
提交
01209614
编写于
12月 30, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: compatiable for pre version
上级
469dfb9d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
16 deletion
+38
-16
include/util/tjson.h
include/util/tjson.h
+21
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+2
-1
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+15
-15
未找到文件。
include/util/tjson.h
浏览文件 @
01209614
...
@@ -30,6 +30,27 @@ extern "C" {
...
@@ -30,6 +30,27 @@ extern "C" {
val = _tmp; \
val = _tmp; \
} while (0)
} while (0)
#define tjsonGetInt32ValueFromDouble(pJson, pName, val, code) \
do { \
double _tmp = 0; \
code = tjsonGetDoubleValue(pJson, pName, &_tmp); \
val = (int32_t)_tmp; \
} while (0)
#define tjsonGetInt8ValueFromDouble(pJson, pName, val, code) \
do { \
double _tmp = 0; \
code = tjsonGetDoubleValue(pJson, pName, &_tmp); \
val = (int8_t)_tmp; \
} while (0)
#define tjsonGetUInt16ValueFromDouble(pJson, pName, val, code) \
do { \
double _tmp = 0; \
code = tjsonGetDoubleValue(pJson, pName, &_tmp); \
val = (uint16_t)_tmp; \
} while (0)
typedef
void
SJson
;
typedef
void
SJson
;
SJson
*
tjsonCreateObject
();
SJson
*
tjsonCreateObject
();
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
01209614
...
@@ -885,10 +885,11 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
...
@@ -885,10 +885,11 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
// init by SSyncInfo
// init by SSyncInfo
pSyncNode
->
vgId
=
pSyncInfo
->
vgId
;
pSyncNode
->
vgId
=
pSyncInfo
->
vgId
;
SSyncCfg
*
pCfg
=
&
pSync
Info
->
syncC
fg
;
SSyncCfg
*
pCfg
=
&
pSync
Node
->
raftCfg
.
c
fg
;
sInfo
(
"vgId:%d, start to open sync node, replica:%d selfIndex:%d"
,
pSyncNode
->
vgId
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
sInfo
(
"vgId:%d, start to open sync node, replica:%d selfIndex:%d"
,
pSyncNode
->
vgId
,
pCfg
->
replicaNum
,
pCfg
->
myIndex
);
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
SNodeInfo
*
pNode
=
&
pCfg
->
nodeInfo
[
i
];
(
void
)
tmsgUpdateDnodeInfo
(
&
pNode
->
nodeId
,
&
pNode
->
clusterId
,
pNode
->
nodeFqdn
,
&
pNode
->
nodePort
);
sInfo
(
"vgId:%d, index:%d ep:%s:%u dnode:%d cluster:%"
PRId64
,
pSyncNode
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
sInfo
(
"vgId:%d, index:%d ep:%s:%u dnode:%d cluster:%"
PRId64
,
pSyncNode
->
vgId
,
i
,
pNode
->
nodeFqdn
,
pNode
->
nodePort
,
pNode
->
nodeId
,
pNode
->
clusterId
);
pNode
->
nodeId
,
pNode
->
clusterId
);
}
}
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
01209614
...
@@ -20,8 +20,8 @@
...
@@ -20,8 +20,8 @@
static
int32_t
syncEncodeSyncCfg
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
syncEncodeSyncCfg
(
const
void
*
pObj
,
SJson
*
pJson
)
{
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
)
<
0
)
return
-
1
;
SJson
*
nodeInfo
=
tjsonCreateArray
();
SJson
*
nodeInfo
=
tjsonCreateArray
();
if
(
nodeInfo
==
NULL
)
return
-
1
;
if
(
nodeInfo
==
NULL
)
return
-
1
;
...
@@ -29,7 +29,7 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
...
@@ -29,7 +29,7 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
SJson
*
info
=
tjsonCreateObject
();
SJson
*
info
=
tjsonCreateObject
();
if
(
info
==
NULL
)
return
-
1
;
if
(
info
==
NULL
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
info
,
"nodePort"
,
pCfg
->
nodeInfo
[
i
].
nodePort
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
info
,
"nodePort"
,
pCfg
->
nodeInfo
[
i
].
nodePort
)
<
0
)
return
-
1
;
if
(
tjsonAddStringToObject
(
info
,
"nodeFqdn"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
)
<
0
)
return
-
1
;
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
,
"nodeId"
,
pCfg
->
nodeInfo
[
i
].
nodeId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
)
<
0
)
return
-
1
;
...
@@ -42,11 +42,11 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
...
@@ -42,11 +42,11 @@ static int32_t syncEncodeSyncCfg(const void *pObj, SJson *pJson) {
static
int32_t
syncEncodeRaftCfg
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
syncEncodeRaftCfg
(
const
void
*
pObj
,
SJson
*
pJson
)
{
SRaftCfg
*
pCfg
=
(
SRaftCfg
*
)
pObj
;
SRaftCfg
*
pCfg
=
(
SRaftCfg
*
)
pObj
;
if
(
tjsonAddObject
(
pJson
,
"SSyncCfg"
,
syncEncodeSyncCfg
,
(
void
*
)
&
pCfg
->
cfg
)
<
0
)
return
-
1
;
if
(
tjsonAddObject
(
pJson
,
"SSyncCfg"
,
syncEncodeSyncCfg
,
(
void
*
)
&
pCfg
->
cfg
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"isStandBy"
,
pCfg
->
isStandBy
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"isStandBy"
,
pCfg
->
isStandBy
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"snapshotStrategy"
,
pCfg
->
snapshotStrategy
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"snapshotStrategy"
,
pCfg
->
snapshotStrategy
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"batchSize"
,
pCfg
->
batchSize
)
<
0
)
return
-
1
;
if
(
tjsonAddIntegerToObject
(
pJson
,
"batchSize"
,
pCfg
->
batchSize
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"lastConfigIndex"
,
pCfg
->
lastConfigIndex
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"lastConfigIndex"
,
pCfg
->
lastConfigIndex
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Integer
ToObject
(
pJson
,
"configIndexCount"
,
pCfg
->
configIndexCount
)
<
0
)
return
-
1
;
if
(
tjsonAdd
Double
ToObject
(
pJson
,
"configIndexCount"
,
pCfg
->
configIndexCount
)
<
0
)
return
-
1
;
SJson
*
configIndexArr
=
tjsonCreateArray
();
SJson
*
configIndexArr
=
tjsonCreateArray
();
if
(
configIndexArr
==
NULL
)
return
-
1
;
if
(
configIndexArr
==
NULL
)
return
-
1
;
...
@@ -115,9 +115,9 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
...
@@ -115,9 +115,9 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
SSyncCfg
*
pCfg
=
(
SSyncCfg
*
)
pObj
;
int32_t
code
=
0
;
int32_t
code
=
0
;
tjsonGet
NumberValu
e
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
,
code
);
tjsonGet
Int32ValueFromDoubl
e
(
pJson
,
"replicaNum"
,
pCfg
->
replicaNum
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGet
NumberValu
e
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
,
code
);
tjsonGet
Int32ValueFromDoubl
e
(
pJson
,
"myIndex"
,
pCfg
->
myIndex
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
SJson
*
nodeInfo
=
tjsonGetObjectItem
(
pJson
,
"nodeInfo"
);
SJson
*
nodeInfo
=
tjsonGetObjectItem
(
pJson
,
"nodeInfo"
);
...
@@ -127,9 +127,9 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
...
@@ -127,9 +127,9 @@ static int32_t syncDecodeSyncCfg(const SJson *pJson, void *pObj) {
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pCfg
->
replicaNum
;
++
i
)
{
SJson
*
info
=
tjsonGetArrayItem
(
nodeInfo
,
i
);
SJson
*
info
=
tjsonGetArrayItem
(
nodeInfo
,
i
);
if
(
info
==
NULL
)
return
-
1
;
if
(
info
==
NULL
)
return
-
1
;
tjsonGet
NumberValu
e
(
info
,
"nodePort"
,
pCfg
->
nodeInfo
[
i
].
nodePort
,
code
);
tjsonGet
UInt16ValueFromDoubl
e
(
info
,
"nodePort"
,
pCfg
->
nodeInfo
[
i
].
nodePort
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetStringValue
(
info
,
"nodeFqdn"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
);
code
=
tjsonGetStringValue
(
info
,
"nodeFqdn"
,
pCfg
->
nodeInfo
[
i
].
nodeFqdn
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
info
,
"nodeId"
,
pCfg
->
nodeInfo
[
i
].
nodeId
,
code
);
tjsonGetNumberValue
(
info
,
"nodeId"
,
pCfg
->
nodeInfo
[
i
].
nodeId
,
code
);
tjsonGetNumberValue
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
,
code
);
tjsonGetNumberValue
(
info
,
"clusterId"
,
pCfg
->
nodeInfo
[
i
].
clusterId
,
code
);
...
@@ -144,15 +144,15 @@ static int32_t syncDecodeRaftCfg(const SJson *pJson, void *pObj) {
...
@@ -144,15 +144,15 @@ static int32_t syncDecodeRaftCfg(const SJson *pJson, void *pObj) {
if
(
tjsonToObject
(
pJson
,
"SSyncCfg"
,
syncDecodeSyncCfg
,
(
void
*
)
&
pCfg
->
cfg
)
<
0
)
return
-
1
;
if
(
tjsonToObject
(
pJson
,
"SSyncCfg"
,
syncDecodeSyncCfg
,
(
void
*
)
&
pCfg
->
cfg
)
<
0
)
return
-
1
;
tjsonGet
NumberValu
e
(
pJson
,
"isStandBy"
,
pCfg
->
isStandBy
,
code
);
tjsonGet
Int8ValueFromDoubl
e
(
pJson
,
"isStandBy"
,
pCfg
->
isStandBy
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGet
NumberValu
e
(
pJson
,
"snapshotStrategy"
,
pCfg
->
snapshotStrategy
,
code
);
tjsonGet
Int8ValueFromDoubl
e
(
pJson
,
"snapshotStrategy"
,
pCfg
->
snapshotStrategy
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGet
NumberValu
e
(
pJson
,
"batchSize"
,
pCfg
->
batchSize
,
code
);
tjsonGet
Int32ValueFromDoubl
e
(
pJson
,
"batchSize"
,
pCfg
->
batchSize
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGetNumberValue
(
pJson
,
"lastConfigIndex"
,
pCfg
->
lastConfigIndex
,
code
);
tjsonGetNumberValue
(
pJson
,
"lastConfigIndex"
,
pCfg
->
lastConfigIndex
,
code
);
if
(
code
<
0
)
return
-
1
;
if
(
code
<
0
)
return
-
1
;
tjsonGet
NumberValu
e
(
pJson
,
"configIndexCount"
,
pCfg
->
configIndexCount
,
code
);
tjsonGet
Int32ValueFromDoubl
e
(
pJson
,
"configIndexCount"
,
pCfg
->
configIndexCount
,
code
);
SJson
*
configIndexArr
=
tjsonGetObjectItem
(
pJson
,
"configIndexArr"
);
SJson
*
configIndexArr
=
tjsonGetObjectItem
(
pJson
,
"configIndexArr"
);
if
(
configIndexArr
==
NULL
)
return
-
1
;
if
(
configIndexArr
==
NULL
)
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录