Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5de86599
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看板
提交
5de86599
编写于
11月 11, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: adjust head file and sync log
上级
4d0c5c9d
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
28 addition
and
37 deletion
+28
-37
source/libs/sync/inc/syncRaftCfg.h
source/libs/sync/inc/syncRaftCfg.h
+2
-9
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+1
-21
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+0
-3
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+2
-1
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+2
-1
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+2
-2
source/libs/sync/test/sync_test_lib/inc/syncTest.h
source/libs/sync/test/sync_test_lib/inc/syncTest.h
+3
-0
source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c
source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c
+16
-0
未找到文件。
source/libs/sync/inc/syncRaftCfg.h
浏览文件 @
5de86599
...
...
@@ -23,10 +23,8 @@ extern "C" {
#include "syncInt.h"
#define CONFIG_FILE_LEN 2048
#define MAX_CONFIG_INDEX_COUNT 256
// SRaftCfgIndex ------------------------------------------
typedef
struct
SRaftCfgIndex
{
TdFilePtr
pFile
;
char
path
[
TSDB_FILENAME_LEN
*
2
];
...
...
@@ -44,11 +42,8 @@ cJSON *raftCfgIndex2Json(SRaftCfgIndex *pRaftCfgIndex);
char
*
raftCfgIndex2Str
(
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromJson
(
const
cJSON
*
pRoot
,
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexFromStr
(
const
char
*
s
,
SRaftCfgIndex
*
pRaftCfgIndex
);
int32_t
raftCfgIndexCreateFile
(
const
char
*
path
);
// ---------------------------------------------------------
typedef
struct
SRaftCfg
{
SSyncCfg
cfg
;
TdFilePtr
pFile
;
...
...
@@ -68,11 +63,9 @@ int32_t raftCfgClose(SRaftCfg *pRaftCfg);
int32_t
raftCfgPersist
(
SRaftCfg
*
pRaftCfg
);
int32_t
raftCfgAddConfigIndex
(
SRaftCfg
*
pRaftCfg
,
SyncIndex
configIndex
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
void
syncCfg2SimpleStr
(
const
SSyncCfg
*
pCfg
,
char
*
str
,
int32_t
bufLen
);
cJSON
*
syncCfg2Json
(
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
);
char
*
raftCfg2Str
(
SRaftCfg
*
pRaftCfg
);
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
5de86599
...
...
@@ -13,10 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "syncRaftCfg.h"
#include "cJSON.h"
#include "syncEnv.h"
#include "syncUtil.h"
// file must already exist!
SRaftCfgIndex
*
raftCfgIndexOpen
(
const
char
*
path
)
{
...
...
@@ -242,13 +240,6 @@ cJSON *syncCfg2Json(SSyncCfg *pSyncCfg) {
return
pRoot
;
}
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pJson
=
syncCfg2Json
(
pSyncCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
int32_t
syncCfgFromJson
(
const
cJSON
*
pRoot
,
SSyncCfg
*
pSyncCfg
)
{
memset
(
pSyncCfg
,
0
,
sizeof
(
SSyncCfg
));
// cJSON *pJson = cJSON_GetObjectItem(pRoot, "SSyncCfg");
...
...
@@ -283,17 +274,6 @@ int32_t syncCfgFromJson(const cJSON *pRoot, SSyncCfg *pSyncCfg) {
return
0
;
}
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pRoot
=
cJSON_Parse
(
s
);
ASSERT
(
pRoot
!=
NULL
);
int32_t
ret
=
syncCfgFromJson
(
pRoot
,
pSyncCfg
);
ASSERT
(
ret
==
0
);
cJSON_Delete
(
pRoot
);
return
0
;
}
cJSON
*
raftCfg2Json
(
SRaftCfg
*
pRaftCfg
)
{
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pRoot
,
"SSyncCfg"
,
syncCfg2Json
(
&
(
pRaftCfg
->
cfg
)));
...
...
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
5de86599
...
...
@@ -102,7 +102,6 @@ void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg) {
memcpy
(
pRpcMsg
->
pCont
,
pEntry
->
data
,
pRpcMsg
->
contLen
);
}
//-----------------------------------
SRaftEntryHashCache
*
raftCacheCreate
(
SSyncNode
*
pSyncNode
,
int32_t
maxCount
)
{
SRaftEntryHashCache
*
pCache
=
taosMemoryMalloc
(
sizeof
(
SRaftEntryHashCache
));
if
(
pCache
==
NULL
)
{
...
...
@@ -256,8 +255,6 @@ int32_t raftCacheClear(struct SRaftEntryHashCache* pCache) {
return
0
;
}
//-----------------------------------
static
char
*
keyFn
(
const
void
*
pData
)
{
SSyncRaftEntry
*
pEntry
=
(
SSyncRaftEntry
*
)
pData
;
return
(
char
*
)(
&
(
pEntry
->
index
));
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
5de86599
...
...
@@ -143,7 +143,8 @@ 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%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
sTrace
(
"==callback== ==ReConfigCb== flag:0x%"
PRIx64
", index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
PRIu64
,
cbMeta
->
flag
,
cbMeta
->
index
,
cbMeta
->
code
,
cbMeta
->
currentTerm
,
cbMeta
->
term
);
}
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
5de86599
...
...
@@ -73,7 +73,8 @@ int32_t GetSnapshotCb(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==RestoreFinishCb=="
);
}
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
cbMeta
)
{
sTrace
(
"==callback== ==ReConfigCb== flag:0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", term:%"
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/syncTestTool.cpp
浏览文件 @
5de86599
...
...
@@ -148,8 +148,8 @@ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFini
void
ReConfigCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
*
cbMeta
)
{
char
*
s
=
syncCfg2Str
(
&
(
cbMeta
->
newCfg
));
sTrace
(
"==callback== ==ReConfigCb== flag:
0x%lX, index:%"
PRId64
", code:%d, currentTerm:%"
PRIu64
", t
erm:%"
PRIu64
", newCfg:%s"
,
sTrace
(
"==callback== ==ReConfigCb== flag:
%"
PRIx64
", index:%"
PRId64
", code:%d, currentT
erm:%"
PRIu64
",
term:%"
PRIu64
",
newCfg:%s"
,
cbMeta
->
flag
,
cbMeta
->
index
,
cbMeta
->
code
,
cbMeta
->
currentTerm
,
cbMeta
->
term
,
s
);
taosMemoryFree
(
s
);
}
...
...
source/libs/sync/test/sync_test_lib/inc/syncTest.h
浏览文件 @
5de86599
...
...
@@ -49,6 +49,9 @@ void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj);
void
syncEntryLog
(
const
SSyncRaftEntry
*
pObj
);
void
syncEntryLog2
(
char
*
s
,
const
SSyncRaftEntry
*
pObj
);
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
);
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
);
cJSON
*
raftCache2Json
(
SRaftEntryHashCache
*
pObj
);
char
*
raftCache2Str
(
SRaftEntryHashCache
*
pObj
);
void
raftCachePrint
(
SRaftEntryHashCache
*
pObj
);
...
...
source/libs/sync/test/sync_test_lib/src/syncRaftCfgDebug.c
浏览文件 @
5de86599
...
...
@@ -16,4 +16,20 @@
#define _DEFAULT_SOURCE
#include "syncTest.h"
char
*
syncCfg2Str
(
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pJson
=
syncCfg2Json
(
pSyncCfg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
int32_t
syncCfgFromStr
(
const
char
*
s
,
SSyncCfg
*
pSyncCfg
)
{
cJSON
*
pRoot
=
cJSON_Parse
(
s
);
ASSERT
(
pRoot
!=
NULL
);
int32_t
ret
=
syncCfgFromJson
(
pRoot
,
pSyncCfg
);
ASSERT
(
ret
==
0
);
cJSON_Delete
(
pRoot
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录