Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b6399528
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
b6399528
编写于
2月 25, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add raft store
上级
296d9abe
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
112 addition
and
26 deletion
+112
-26
include/libs/sync/sync.h
include/libs/sync/sync.h
+10
-10
source/libs/sync/inc/syncElection.h
source/libs/sync/inc/syncElection.h
+1
-1
source/libs/sync/inc/syncRaft.h
source/libs/sync/inc/syncRaft.h
+3
-3
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+1
-1
source/libs/sync/inc/syncTimeout.h
source/libs/sync/inc/syncTimeout.h
+1
-1
source/libs/sync/inc/syncVoteMgr.h
source/libs/sync/inc/syncVoteMgr.h
+2
-3
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncEnvTest.cpp
source/libs/sync/test/syncEnvTest.cpp
+23
-7
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+57
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
b6399528
...
...
@@ -34,23 +34,23 @@ typedef enum {
TAOS_SYNC_STATE_LEADER
=
2
,
}
ESyncState
;
typedef
struct
{
typedef
struct
SSyncBuffer
{
void
*
data
;
size_t
len
;
}
SSyncBuffer
;
typedef
struct
{
SyncNodeId
nodeId
;
uint16_t
nodePort
;
// node sync Port
char
nodeFqdn
[
TSDB_FQDN_LEN
];
// node FQDN
typedef
struct
SNodeInfo
{
uint16_t
nodePort
;
// node sync Port
char
nodeFqdn
[
TSDB_FQDN_LEN
];
// node FQDN
}
SNodeInfo
;
typedef
struct
{
typedef
struct
SSyncCfg
{
int32_t
replicaNum
;
int32_t
myIndex
;
SNodeInfo
nodeInfo
[
TSDB_MAX_REPLICA
];
}
SSyncCfg
;
typedef
struct
{
typedef
struct
SNodesRole
{
int32_t
replicaNum
;
SNodeInfo
nodeInfo
[
TSDB_MAX_REPLICA
];
ESyncState
role
[
TSDB_MAX_REPLICA
];
...
...
@@ -128,9 +128,9 @@ typedef struct SStateMgr {
}
SStateMgr
;
typedef
struct
{
SyncGroupId
vgId
;
SSyncCfg
syncCfg
;
typedef
struct
SSyncInfo
{
SyncGroupId
vgId
;
SSyncCfg
syncCfg
;
}
SSyncInfo
;
struct
SSyncNode
;
...
...
source/libs/sync/inc/syncElection.h
浏览文件 @
b6399528
...
...
@@ -23,8 +23,8 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "taosdef.h"
#include "syncInt.h"
#include "taosdef.h"
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncRaft.h
浏览文件 @
b6399528
...
...
@@ -35,9 +35,9 @@ typedef struct SRaftId {
typedef
struct
SRaft
{
SRaftId
id
;
SSyncLogStore
*
logStore
;
SStateMgr
*
stateManager
;
SSyncFSM
*
syncFsm
;
SSyncLogStore
*
logStore
;
SStateMgr
*
stateManager
;
SSyncFSM
*
syncFsm
;
}
SRaft
;
...
...
source/libs/sync/inc/syncReplication.h
浏览文件 @
b6399528
...
...
@@ -23,8 +23,8 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "taosdef.h"
#include "syncInt.h"
#include "taosdef.h"
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncTimeout.h
浏览文件 @
b6399528
...
...
@@ -23,10 +23,10 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "syncInt.h"
#include "syncMessage.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "syncInt.h"
void
onTimeout
(
SRaft
*
pRaft
,
void
*
pMsg
);
...
...
source/libs/sync/inc/syncVoteMgr.h
浏览文件 @
b6399528
...
...
@@ -20,12 +20,11 @@
extern
"C"
{
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "taosdef.h"
#include "syncInt.h"
#include "taosdef.h"
#ifdef __cplusplus
}
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
b6399528
add_executable
(
syncTest
""
)
add_executable
(
syncEnvTest
""
)
add_executable
(
syncPingTest
""
)
target_sources
(
syncTest
...
...
@@ -10,6 +11,10 @@ target_sources(syncEnvTest
PRIVATE
"syncEnvTest.cpp"
)
target_sources
(
syncPingTest
PRIVATE
"syncPingTest.cpp"
)
target_include_directories
(
syncTest
...
...
@@ -22,6 +27,11 @@ target_include_directories(syncEnvTest
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncPingTest
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
syncTest
...
...
@@ -32,6 +42,10 @@ target_link_libraries(syncEnvTest
sync
gtest_main
)
target_link_libraries
(
syncPingTest
sync
gtest_main
)
enable_testing
()
...
...
source/libs/sync/test/syncEnvTest.cpp
浏览文件 @
b6399528
...
...
@@ -13,6 +13,26 @@ void logTest() {
sFatal
(
"--- sync log test: fatal"
);
}
void
doSync
()
{
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
replicaNum
=
3
;
pCfg
->
nodeInfo
[
0
].
nodePort
=
7010
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
0
].
nodeFqdn
);
pCfg
->
nodeInfo
[
1
].
nodePort
=
7110
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
1
].
nodeFqdn
);
pCfg
->
nodeInfo
[
2
].
nodePort
=
7210
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
2
].
nodeFqdn
);
SSyncNode
*
pSyncNode
=
syncNodeStart
(
&
syncInfo
);
assert
(
pSyncNode
!=
NULL
);
}
int
main
()
{
taosInitLog
((
char
*
)
"syncEnvTest.log"
,
100000
,
10
);
tsAsyncLog
=
0
;
...
...
@@ -20,17 +40,13 @@ int main() {
logTest
();
int32_t
ret
=
sync
Env
Start
();
int32_t
ret
=
sync
IO
Start
();
assert
(
ret
==
0
);
ret
=
sync
IO
Start
();
ret
=
sync
Env
Start
();
assert
(
ret
==
0
);
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
SSyncNode
*
pSyncNode
=
syncNodeStart
(
&
syncInfo
);
assert
(
pSyncNode
!=
NULL
);
doSync
();
while
(
1
)
{
taosMsleep
(
1000
);
...
...
source/libs/sync/test/syncPingTest.cpp
0 → 100644
浏览文件 @
b6399528
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncRaftStore.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
void
doSync
()
{
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
0
;
pCfg
->
replicaNum
=
3
;
pCfg
->
nodeInfo
[
0
].
nodePort
=
7010
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
0
].
nodeFqdn
);
pCfg
->
nodeInfo
[
1
].
nodePort
=
7110
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
1
].
nodeFqdn
);
pCfg
->
nodeInfo
[
2
].
nodePort
=
7210
;
taosGetFqdn
(
pCfg
->
nodeInfo
[
2
].
nodeFqdn
);
SSyncNode
*
pSyncNode
=
syncNodeStart
(
&
syncInfo
);
assert
(
pSyncNode
!=
NULL
);
}
int
main
()
{
taosInitLog
((
char
*
)
"syncPingTest.log"
,
100000
,
10
);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
logTest
();
int32_t
ret
=
syncIOStart
();
assert
(
ret
==
0
);
ret
=
syncEnvStart
();
assert
(
ret
==
0
);
doSync
();
while
(
1
)
{
taosMsleep
(
1000
);
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录