Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4afcb438
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4afcb438
编写于
2月 27, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add sync io
上级
b55cf2bc
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
32 addition
and
12 deletion
+32
-12
include/libs/sync/sync.h
include/libs/sync/sync.h
+3
-0
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+10
-4
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-2
source/libs/sync/inc/syncRaftStore.h
source/libs/sync/inc/syncRaftStore.h
+0
-1
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+7
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+2
-2
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+8
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
4afcb438
...
...
@@ -21,7 +21,9 @@ extern "C" {
#endif
#include <stdint.h>
#include <tep.h>
#include "taosdef.h"
#include "trpc.h"
typedef
uint64_t
SyncNodeId
;
typedef
int32_t
SyncGroupId
;
...
...
@@ -133,6 +135,7 @@ typedef struct SSyncInfo {
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
SSyncFSM
*
pFsm
;
int32_t
(
*
FpSendMsg
)(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
...
...
source/libs/sync/inc/syncIO.h
浏览文件 @
4afcb438
...
...
@@ -45,20 +45,26 @@ typedef struct SSyncIO {
int32_t
(
*
start
)(
struct
SSyncIO
*
ths
);
int32_t
(
*
stop
)(
struct
SSyncIO
*
ths
);
int32_t
(
*
ping
)(
struct
SSyncIO
*
ths
);
int32_t
(
*
onMessage
)(
struct
SSyncIO
*
ths
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
int32_t
(
*
onMsg
)(
struct
SSyncIO
*
ths
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
int32_t
(
*
destroy
)(
struct
SSyncIO
*
ths
);
void
*
pSyncNode
;
int32_t
(
*
FpOnPing
)(
struct
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
}
SSyncIO
;
extern
SSyncIO
*
gSyncIO
;
int32_t
syncIOStart
();
int32_t
syncIOStop
();
int32_t
syncIOSendMsg
(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
SSyncIO
*
syncIOCreate
();
static
int32_t
doSyncIOStart
(
SSyncIO
*
io
);
static
int32_t
doSyncIOStop
(
SSyncIO
*
io
);
static
int32_t
doSyncIOPing
(
SSyncIO
*
io
);
static
int32_t
doSyncIOOnM
essage
(
struct
SSyncIO
*
io
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
int32_t
doSyncIOOnM
sg
(
struct
SSyncIO
*
io
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
int32_t
doSyncIODestroy
(
SSyncIO
*
io
);
#ifdef __cplusplus
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
4afcb438
...
...
@@ -115,6 +115,8 @@ typedef struct SSyncNode {
int32_t
(
*
FpOnAppendEntriesReply
)(
struct
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpSendMsg
)(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
}
SSyncNode
;
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
);
...
...
@@ -139,8 +141,6 @@ static int32_t onSyncNodeAppendEntries(struct SSyncNode* ths, SyncAppendEntries*
static
int32_t
onSyncNodeAppendEntriesReply
(
struct
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncRaftStore.h
浏览文件 @
4afcb438
...
...
@@ -54,7 +54,6 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len);
void
raftStorePrint
(
SRaftStore
*
pRaftStore
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
4afcb438
...
...
@@ -20,6 +20,10 @@
#include "ttimer.h"
#include "tutil.h"
SSyncIO
*
gSyncIO
=
NULL
;
int32_t
syncIOSendMsg
(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
)
{
return
0
;
}
int32_t
syncIOStart
()
{
return
0
;
}
int32_t
syncIOStop
()
{
return
0
;
}
...
...
@@ -121,7 +125,7 @@ SSyncIO *syncIOCreate() {
io
->
start
=
doSyncIOStart
;
io
->
stop
=
doSyncIOStop
;
io
->
ping
=
doSyncIOPing
;
io
->
onM
essage
=
doSyncIOOnMessage
;
io
->
onM
sg
=
doSyncIOOnMsg
;
io
->
destroy
=
doSyncIODestroy
;
return
io
;
...
...
@@ -215,7 +219,7 @@ static int32_t doSyncIOPing(SSyncIO *io) {
return
0
;
}
static
int32_t
doSyncIOOnM
essage
(
struct
SSyncIO
*
io
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
0
;
}
static
int32_t
doSyncIOOnM
sg
(
struct
SSyncIO
*
io
,
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
return
0
;
}
static
int32_t
doSyncIODestroy
(
SSyncIO
*
io
)
{
int8_t
start
=
atomic_load_8
(
&
io
->
isStart
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
4afcb438
...
...
@@ -38,11 +38,12 @@ ESyncState syncGetMyRole(int64_t rid) { return TAOS_SYNC_STATE_LEADER; }
void
syncGetNodesRole
(
int64_t
rid
,
SNodesRole
*
pNodeRole
)
{}
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
malloc
(
sizeof
(
SSyncNode
));
assert
(
pSyncNode
!=
NULL
);
pSyncNode
->
FpSendMsg
=
pSyncInfo
->
FpSendMsg
;
pSyncNode
->
FpPing
=
doSyncNodePing
;
pSyncNode
->
FpOnPing
=
onSyncNodePing
;
pSyncNode
->
FpOnPingReply
=
onSyncNodePingReply
;
...
...
@@ -56,7 +57,6 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
return
pSyncNode
;
}
void
syncNodeClose
(
SSyncNode
*
pSyncNode
)
{
assert
(
pSyncNode
!=
NULL
);
raftClose
(
pSyncNode
->
pRaft
);
...
...
source/libs/sync/test/syncPingTest.cpp
浏览文件 @
4afcb438
...
...
@@ -14,8 +14,13 @@ void logTest() {
}
void
doSync
()
{
SSyncFSM
*
pFsm
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./test_sync_ping"
);
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
0
;
...
...
@@ -32,6 +37,9 @@ void doSync() {
SSyncNode
*
pSyncNode
=
syncNodeOpen
(
&
syncInfo
);
assert
(
pSyncNode
!=
NULL
);
gSyncIO
->
FpOnPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
}
int
main
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录