Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b4f8e454
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看板
提交
b4f8e454
编写于
11月 11, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: adjust head file and sync log
上级
5de86599
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
121 addition
and
155 deletion
+121
-155
source/libs/sync/inc/syncAppendEntries.h
source/libs/sync/inc/syncAppendEntries.h
+0
-1
source/libs/sync/inc/syncAppendEntriesReply.h
source/libs/sync/inc/syncAppendEntriesReply.h
+0
-1
source/libs/sync/inc/syncIndexMgr.h
source/libs/sync/inc/syncIndexMgr.h
+6
-15
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+0
-41
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+1
-6
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+1
-5
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+1
-2
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+0
-1
source/libs/sync/src/syncEnv.c
source/libs/sync/src/syncEnv.c
+2
-0
source/libs/sync/src/syncIndexMgr.c
source/libs/sync/src/syncIndexMgr.c
+2
-81
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+1
-1
source/libs/sync/test/sync_test_lib/inc/syncTest.h
source/libs/sync/test/sync_test_lib/inc/syncTest.h
+14
-1
source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c
source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c
+93
-0
未找到文件。
source/libs/sync/inc/syncAppendEntries.h
浏览文件 @
b4f8e454
...
...
@@ -21,7 +21,6 @@ extern "C" {
#endif
#include "syncInt.h"
#include "syncMessage.h"
// TLA+ Spec
// HandleAppendEntriesRequest(i, j, m) ==
...
...
source/libs/sync/inc/syncAppendEntriesReply.h
浏览文件 @
b4f8e454
...
...
@@ -21,7 +21,6 @@ extern "C" {
#endif
#include "syncInt.h"
#include "syncMessage.h"
// TLA+ Spec
// HandleAppendEntriesResponse(i, j, m) ==
...
...
source/libs/sync/inc/syncIndexMgr.h
浏览文件 @
b4f8e454
...
...
@@ -41,22 +41,13 @@ void syncIndexMgrDestroy(SSyncIndexMgr *pSyncIndexMgr);
void
syncIndexMgrClear
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrSetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncIndex
index
);
SyncIndex
syncIndexMgrGetIndex
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
);
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrSetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
startTime
);
int64_t
syncIndexMgrGetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
void
syncIndexMgrSetRecvTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
recvTime
);
int64_t
syncIndexMgrGetRecvTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
// void syncIndexMgrSetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, SyncTerm term);
// SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId);
// for debug -------------------
void
syncIndexMgrPrint
(
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrPrint2
(
char
*
s
,
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrLog
(
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrLog2
(
char
*
s
,
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrSetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
startTime
);
int64_t
syncIndexMgrGetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
void
syncIndexMgrSetRecvTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
recvTime
);
int64_t
syncIndexMgrGetRecvTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
void
syncIndexMgrSetTerm
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncTerm
term
);
SyncTerm
syncIndexMgrGetTerm
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
);
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncMessage.h
已删除
100644 → 0
浏览文件 @
5de86599
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_LIBS_SYNC_MESSAGE_H
#define _TD_LIBS_SYNC_MESSAGE_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "syncInt.h"
// ---------------------------------------------
cJSON
*
syncRpcMsg2Json
(
SRpcMsg
*
pRpcMsg
);
cJSON
*
syncRpcUnknownMsg2Json
();
char
*
syncRpcMsg2Str
(
SRpcMsg
*
pRpcMsg
);
// for debug ----------------------
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
void
syncRpcMsgLog
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgLog2
(
char
*
s
,
SRpcMsg
*
pMsg
);
// ---------------------------------------------
#ifdef __cplusplus
}
#endif
#endif
/*_TD_LIBS_SYNC_MESSAGE_H*/
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
b4f8e454
...
...
@@ -13,15 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncAppendEntries.h"
#include "syncInt.h"
#include "syncRaftCfg.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncSnapshot.h"
#include "syncUtil.h"
#include "syncVoteMgr.h"
#include "wal.h"
// TLA+ Spec
// HandleAppendEntriesRequest(i, j, m) ==
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
b4f8e454
...
...
@@ -13,17 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncAppendEntriesReply.h"
#include "syncCommit.h"
#include "syncIndexMgr.h"
#include "syncInt.h"
#include "syncRaftCfg.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncReplication.h"
#include "syncSnapshot.h"
#include "syncUtil.h"
#include "syncVoteMgr.h"
// TLA+ Spec
// HandleAppendEntriesResponse(i, j, m) ==
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
b4f8e454
...
...
@@ -13,10 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncCommit.h"
#include "syncIndexMgr.h"
#include "syncInt.h"
#include "syncRaftCfg.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
...
...
source/libs/sync/src/syncElection.c
浏览文件 @
b4f8e454
...
...
@@ -15,7 +15,6 @@
#define _DEFAULT_SOURCE
#include "syncElection.h"
#include "syncMessage.h"
#include "syncRaftCfg.h"
#include "syncRaftStore.h"
#include "syncVoteMgr.h"
...
...
source/libs/sync/src/syncEnv.c
浏览文件 @
b4f8e454
...
...
@@ -105,6 +105,7 @@ void syncEnvStopTimer() {
#endif
static
void
syncEnvTick
(
void
*
param
,
void
*
tmrId
)
{
#if 0
SSyncEnv *pSyncEnv = param;
if (atomic_load_64(&gSyncEnv.envTickTimerLogicClockUser) <= atomic_load_64(&gSyncEnv.envTickTimerLogicClock)) {
gSyncEnv.envTickTimerCounter++;
...
...
@@ -121,4 +122,5 @@ static void syncEnvTick(void *param, void *tmrId) {
gSyncEnv.envTickTimerLogicClockUser, gSyncEnv.envTickTimerLogicClock, gSyncEnv.envTickTimerCounter,
gSyncEnv.envTickTimerMS, tmrId);
}
#endif
}
source/libs/sync/src/syncIndexMgr.c
浏览文件 @
b4f8e454
...
...
@@ -13,18 +13,16 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncIndexMgr.h"
#include "syncUtil.h"
// SMatchIndex -----------------------------
SSyncIndexMgr
*
syncIndexMgrCreate
(
SSyncNode
*
pSyncNode
)
{
SSyncIndexMgr
*
pSyncIndexMgr
=
taosMemory
Malloc
(
sizeof
(
SSyncIndexMgr
));
SSyncIndexMgr
*
pSyncIndexMgr
=
taosMemory
Calloc
(
1
,
sizeof
(
SSyncIndexMgr
));
if
(
pSyncIndexMgr
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
memset
(
pSyncIndexMgr
,
0
,
sizeof
(
SSyncIndexMgr
));
pSyncIndexMgr
->
replicas
=
&
(
pSyncNode
->
replicasId
);
pSyncIndexMgr
->
replicaNum
=
pSyncNode
->
replicaNum
;
...
...
@@ -97,54 +95,6 @@ SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaf
return
SYNC_INDEX_INVALID
;
}
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pSyncIndexMgr
!=
NULL
)
{
cJSON_AddNumberToObject
(
pRoot
,
"replicaNum"
,
pSyncIndexMgr
->
replicaNum
);
cJSON
*
pReplicas
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
pRoot
,
"replicas"
,
pReplicas
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
cJSON_AddItemToArray
(
pReplicas
,
syncUtilRaftId2Json
(
&
(
*
(
pSyncIndexMgr
->
replicas
))[
i
]));
}
{
int
*
arr
=
(
int
*
)
taosMemoryMalloc
(
sizeof
(
int
)
*
pSyncIndexMgr
->
replicaNum
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
arr
[
i
]
=
pSyncIndexMgr
->
index
[
i
];
}
cJSON
*
pIndex
=
cJSON_CreateIntArray
(
arr
,
pSyncIndexMgr
->
replicaNum
);
taosMemoryFree
(
arr
);
cJSON_AddItemToObject
(
pRoot
,
"index"
,
pIndex
);
}
{
int
*
arr
=
(
int
*
)
taosMemoryMalloc
(
sizeof
(
int
)
*
pSyncIndexMgr
->
replicaNum
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
arr
[
i
]
=
pSyncIndexMgr
->
privateTerm
[
i
];
}
cJSON
*
pIndex
=
cJSON_CreateIntArray
(
arr
,
pSyncIndexMgr
->
replicaNum
);
taosMemoryFree
(
arr
);
cJSON_AddItemToObject
(
pRoot
,
"privateTerm"
,
pIndex
);
}
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncIndexMgr
->
pSyncNode
);
cJSON_AddStringToObject
(
pRoot
,
"pSyncNode"
,
u64buf
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"pSyncIndexMgr"
,
pRoot
);
return
pJson
;
}
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
cJSON
*
pJson
=
syncIndexMgr2Json
(
pSyncIndexMgr
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
void
syncIndexMgrSetStartTime
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
int64_t
startTime
)
{
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
if
(
syncUtilSameId
(
&
((
*
(
pSyncIndexMgr
->
replicas
))[
i
]),
pRaftId
))
{
...
...
@@ -201,35 +151,6 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa
return
-
1
;
}
// for debug -------------------
void
syncIndexMgrPrint
(
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
printf
(
"syncIndexMgrPrint | len:%"
PRIu64
" | %s
\n
"
,
(
uint64_t
)
strlen
(
serialized
),
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrPrint2
(
char
*
s
,
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
printf
(
"syncIndexMgrPrint2 | len:%"
PRIu64
" | %s | %s
\n
"
,
(
uint64_t
)
strlen
(
serialized
),
s
,
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrLog
(
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog | len:%"
PRIu64
" | %s"
,
(
uint64_t
)
strlen
(
serialized
),
serialized
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrLog2
(
char
*
s
,
SSyncIndexMgr
*
pObj
)
{
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog2 | len:%"
PRIu64
" | %s | %s"
,
(
uint64_t
)
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
void
syncIndexMgrSetTerm
(
SSyncIndexMgr
*
pSyncIndexMgr
,
const
SRaftId
*
pRaftId
,
SyncTerm
term
)
{
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
if
(
syncUtilSameId
(
&
((
*
(
pSyncIndexMgr
->
replicas
))[
i
]),
pRaftId
))
{
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
b4f8e454
...
...
@@ -143,7 +143,7 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
cbMeta
)
{
sTrace
(
"==callback== ==ReConfigCb== flag:
0x
%"
PRIx64
", index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
sTrace
(
"==callback== ==ReConfigCb== flag:%"
PRIx64
", index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
->
flag
,
cbMeta
->
index
,
cbMeta
->
code
,
cbMeta
->
currentTerm
,
cbMeta
->
term
);
}
...
...
source/libs/sync/test/sync_test_lib/inc/syncTest.h
浏览文件 @
b4f8e454
...
...
@@ -110,7 +110,20 @@ char* snapshotSender2Str(SSyncSnapshotSender* pSender);
cJSON
*
snapshotReceiver2Json
(
SSyncSnapshotReceiver
*
pReceiver
);
char
*
snapshotReceiver2Str
(
SSyncSnapshotReceiver
*
pReceiver
);
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
);
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
);
void
syncIndexMgrPrint
(
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrPrint2
(
char
*
s
,
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrLog
(
SSyncIndexMgr
*
pObj
);
void
syncIndexMgrLog2
(
char
*
s
,
SSyncIndexMgr
*
pObj
);
cJSON
*
syncRpcMsg2Json
(
SRpcMsg
*
pRpcMsg
);
cJSON
*
syncRpcUnknownMsg2Json
();
char
*
syncRpcMsg2Str
(
SRpcMsg
*
pRpcMsg
);
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
void
syncRpcMsgLog
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgLog2
(
char
*
s
,
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/libs/sync/test/sync_test_lib/src/syncIndexMgrDebug.c
0 → 100644
浏览文件 @
b4f8e454
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncTest.h"
void
syncIndexMgrPrint
(
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
printf
(
"syncIndexMgrPrint | len:%"
PRIu64
" | %s
\n
"
,
(
uint64_t
)
strlen
(
serialized
),
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrPrint2
(
char
*
s
,
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
printf
(
"syncIndexMgrPrint2 | len:%"
PRIu64
" | %s | %s
\n
"
,
(
uint64_t
)
strlen
(
serialized
),
s
,
serialized
);
fflush
(
NULL
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrLog
(
SSyncIndexMgr
*
pObj
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog | len:%"
PRIu64
" | %s"
,
(
uint64_t
)
strlen
(
serialized
),
serialized
);
taosMemoryFree
(
serialized
);
}
void
syncIndexMgrLog2
(
char
*
s
,
SSyncIndexMgr
*
pObj
)
{
if
(
gRaftDetailLog
)
{
char
*
serialized
=
syncIndexMgr2Str
(
pObj
);
sTrace
(
"syncIndexMgrLog2 | len:%"
PRIu64
" | %s | %s"
,
(
uint64_t
)
strlen
(
serialized
),
s
,
serialized
);
taosMemoryFree
(
serialized
);
}
}
cJSON
*
syncIndexMgr2Json
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pSyncIndexMgr
!=
NULL
)
{
cJSON_AddNumberToObject
(
pRoot
,
"replicaNum"
,
pSyncIndexMgr
->
replicaNum
);
cJSON
*
pReplicas
=
cJSON_CreateArray
();
cJSON_AddItemToObject
(
pRoot
,
"replicas"
,
pReplicas
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
cJSON_AddItemToArray
(
pReplicas
,
syncUtilRaftId2Json
(
&
(
*
(
pSyncIndexMgr
->
replicas
))[
i
]));
}
{
int
*
arr
=
(
int
*
)
taosMemoryMalloc
(
sizeof
(
int
)
*
pSyncIndexMgr
->
replicaNum
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
arr
[
i
]
=
pSyncIndexMgr
->
index
[
i
];
}
cJSON
*
pIndex
=
cJSON_CreateIntArray
(
arr
,
pSyncIndexMgr
->
replicaNum
);
taosMemoryFree
(
arr
);
cJSON_AddItemToObject
(
pRoot
,
"index"
,
pIndex
);
}
{
int
*
arr
=
(
int
*
)
taosMemoryMalloc
(
sizeof
(
int
)
*
pSyncIndexMgr
->
replicaNum
);
for
(
int
i
=
0
;
i
<
pSyncIndexMgr
->
replicaNum
;
++
i
)
{
arr
[
i
]
=
pSyncIndexMgr
->
privateTerm
[
i
];
}
cJSON
*
pIndex
=
cJSON_CreateIntArray
(
arr
,
pSyncIndexMgr
->
replicaNum
);
taosMemoryFree
(
arr
);
cJSON_AddItemToObject
(
pRoot
,
"privateTerm"
,
pIndex
);
}
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncIndexMgr
->
pSyncNode
);
cJSON_AddStringToObject
(
pRoot
,
"pSyncNode"
,
u64buf
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"pSyncIndexMgr"
,
pRoot
);
return
pJson
;
}
char
*
syncIndexMgr2Str
(
SSyncIndexMgr
*
pSyncIndexMgr
)
{
cJSON
*
pJson
=
syncIndexMgr2Json
(
pSyncIndexMgr
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录