Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cd2e8fe7
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看板
提交
cd2e8fe7
编写于
5月 29, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(sync): add SSnapshot callback: reader, writer
上级
3327a069
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
35 deletion
+33
-35
include/libs/sync/sync.h
include/libs/sync/sync.h
+14
-20
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+2
-2
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+1
-2
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+7
-4
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+5
-5
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+3
-2
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+1
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
cd2e8fe7
...
...
@@ -66,12 +66,6 @@ typedef struct SSyncCfg {
SNodeInfo
nodeInfo
[
TSDB_MAX_REPLICA
];
}
SSyncCfg
;
typedef
struct
SSnapshot
{
void
*
data
;
SyncIndex
lastApplyIndex
;
SyncTerm
lastApplyTerm
;
}
SSnapshot
;
typedef
struct
SFsmCbMeta
{
SyncIndex
index
;
bool
isWeak
;
...
...
@@ -93,6 +87,12 @@ typedef struct SReConfigCbMeta {
uint64_t
flag
;
}
SReConfigCbMeta
;
typedef
struct
SSnapshot
{
void
*
data
;
SyncIndex
lastApplyIndex
;
SyncTerm
lastApplyTerm
;
}
SSnapshot
;
typedef
struct
SSyncFSM
{
void
*
data
;
...
...
@@ -101,23 +101,17 @@ typedef struct SSyncFSM {
void
(
*
FpRollBackCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpRestoreFinishCb
)(
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
// if (*ppIter == NULL)
// *ppIter = new iter;
// else
// *ppIter.next();
//
// if success, return 0. else return error code
int32_t
(
*
FpSnapshotRead
)(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
pSnapshot
,
void
**
ppIter
,
char
**
ppBuf
,
int32_t
*
len
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
SSyncCfg
newCfg
,
SReConfigCbMeta
cbMeta
);
// apply data into fsm
int32_t
(
*
FpSnapshotApply
)(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
pSnapshot
,
char
*
pBuf
,
int32_t
len
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
SSyncCfg
newCfg
,
SReConfigCbMeta
cbMeta
);
int32_t
(
*
FpSnapshotStartRead
)(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
);
int32_t
(
*
FpSnapshotStopRead
)(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
);
int32_t
(
*
FpSnapshotDoRead
)(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
,
void
**
ppBuf
,
int32_t
*
len
);
// int32_t (*FpRestoreSnapshot)(struct SSyncFSM* pFsm, const SSnapshot* snapshot);
int32_t
(
*
FpSnapshotStartWrite
)(
struct
SSyncFSM
*
pFsm
,
void
**
ppWriter
);
int32_t
(
*
FpSnapshotStopWrite
)(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
bool
isApply
);
int32_t
(
*
FpSnapshotDoWrite
)(
struct
SSyncFSM
*
pFsm
,
void
*
pWriter
,
void
*
pBuf
,
int32_t
len
);
}
SSyncFSM
;
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
cd2e8fe7
...
...
@@ -105,6 +105,8 @@ void mndReConfig(struct SSyncFSM *pFsm, SSyncCfg newCfg, SReConfigCbMeta cbMeta)
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
pFsm
->
data
=
pMnode
;
pFsm
->
FpCommitCb
=
mndSyncCommitMsg
;
...
...
@@ -113,8 +115,6 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpSnapshotRead
=
mndSnapshotRead
;
pFsm
->
FpSnapshotApply
=
mndSnapshotApply
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
return
pFsm
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
cd2e8fe7
...
...
@@ -142,14 +142,13 @@ void vnodeSyncRollBackMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
pFsm
->
data
=
pVnode
;
pFsm
->
FpCommitCb
=
vnodeSyncCommitMsg
;
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpGetSnapshot
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
NULL
;
pFsm
->
FpSnapshotRead
=
NULL
;
pFsm
->
FpSnapshotApply
=
NULL
;
pFsm
->
FpReConfigCb
=
NULL
;
return
pFsm
;
...
...
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
cd2e8fe7
...
...
@@ -28,10 +28,12 @@ extern "C" {
#include "taosdef.h"
typedef
struct
SSyncSnapshotSender
{
bool
isStart
;
int32_t
progressIndex
;
int32_t
sending
;
int32_t
received
;
bool
finish
;
void
*
pCurrentBlock
;
int32_t
len
;
int32_t
blockLen
;
int64_t
sendingMS
;
SSnapshot
*
pSnapshot
;
SSyncNode
*
pSyncNode
;
}
SSyncSnapshotSender
;
...
...
@@ -43,7 +45,8 @@ cJSON * snapshotSender2Json(SSyncSnapshotSender *pSender);
char
*
snapshotSender2Str
(
SSyncSnapshotSender
*
pSender
);
typedef
struct
SSyncSnapshotReceiver
{
bool
isStart
;
bool
start
;
int32_t
received
;
int32_t
progressIndex
;
void
*
pCurrentBlock
;
int32_t
len
;
...
...
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
cd2e8fe7
...
...
@@ -58,8 +58,8 @@ int32_t raftCfgPersist(SRaftCfg *pRaftCfg) {
int64_t
ret
=
taosWriteFile
(
pRaftCfg
->
pFile
,
buf
,
sizeof
(
buf
));
assert
(
ret
==
sizeof
(
buf
));
//int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1);
//assert(ret == strlen(s) + 1);
//
int64_t ret = taosWriteFile(pRaftCfg->pFile, s, strlen(s) + 1);
//
assert(ret == strlen(s) + 1);
taosMemoryFree
(
s
);
taosFsyncFile
(
pRaftCfg
->
pFile
);
...
...
@@ -170,7 +170,7 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) {
SRaftCfg
raftCfg
;
raftCfg
.
cfg
=
*
pCfg
;
raftCfg
.
isStandBy
=
isStandBy
;
char
*
s
=
raftCfg2Str
(
&
raftCfg
);
char
*
s
=
raftCfg2Str
(
&
raftCfg
);
char
buf
[
CONFIG_FILE_LEN
];
memset
(
buf
,
0
,
sizeof
(
buf
));
...
...
@@ -179,8 +179,8 @@ int32_t raftCfgCreateFile(SSyncCfg *pCfg, int8_t isStandBy, const char *path) {
int64_t
ret
=
taosWriteFile
(
pFile
,
buf
,
sizeof
(
buf
));
assert
(
ret
==
sizeof
(
buf
));
//int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1);
//assert(ret == strlen(s) + 1);
//
int64_t ret = taosWriteFile(pFile, s, strlen(s) + 1);
//
assert(ret == strlen(s) + 1);
taosMemoryFree
(
s
);
taosCloseFile
(
&
pFile
);
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
cd2e8fe7
...
...
@@ -84,14 +84,15 @@ void ReConfigCb(struct SSyncFSM* pFsm, SSyncCfg newCfg, SReConfigCbMeta cbMeta)
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpRestoreFinishCb
=
RestoreFinishCb
;
pFsm
->
FpSnapshotApply
=
NULL
;
pFsm
->
FpSnapshotRead
=
NULL
;
pFsm
->
FpReConfigCb
=
ReConfigCb
;
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
cd2e8fe7
...
...
@@ -75,6 +75,7 @@ int32_t GetSnapshotCb(struct SSyncFSM *pFsm, SSnapshot *pSnapshot) {
void
initFsm
()
{
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
memset
(
pFsm
,
0
,
sizeof
(
*
pFsm
));
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录