Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa857815
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看板
提交
aa857815
编写于
5月 24, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(sync): add mndSnapshotRead mndSnapshotApply
上级
800ef42a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
58 addition
and
12 deletion
+58
-12
include/libs/sync/sync.h
include/libs/sync/sync.h
+14
-3
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+33
-2
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+5
-1
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-2
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+2
-2
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+2
-2
未找到文件。
include/libs/sync/sync.h
浏览文件 @
aa857815
...
...
@@ -82,18 +82,29 @@ typedef struct SFsmCbMeta {
SyncTerm
currentTerm
;
}
SFsmCbMeta
;
typedef
struct
SReConfigCbMeta
{
int32_t
code
;
SyncIndex
index
;
SyncTerm
term
;
SyncTerm
currentTerm
;
}
SReConfigCbMeta
;
typedef
struct
SSyncFSM
{
void
*
data
;
void
(
*
FpCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpPreCommitCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpRollBackCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpRestoreFinish
)(
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpRestoreSnapshot
)(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
snapshot
);
void
(
*
FpRestoreFinishCb
)(
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
void
*
(
*
FpSnapshotRead
)(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
snapshot
,
void
*
iter
,
char
**
ppBuf
,
int32_t
*
len
);
int32_t
(
*
FpSnapshotApply
)(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
snapshot
,
char
*
pBuf
,
int32_t
len
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
SSyncCfg
newCfg
,
SReConfigCbMeta
cbMeta
);
// int32_t (*FpRestoreSnapshot)(struct SSyncFSM* pFsm, const SSnapshot* snapshot);
}
SSyncFSM
;
// abstract definition of log store in raft
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
aa857815
...
...
@@ -49,15 +49,46 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) {
pMnode
->
syncMgmt
.
restored
=
true
;
}
void
*
mndSnapshotRead
(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
snapshot
,
void
*
iter
,
char
**
ppBuf
,
int32_t
*
len
)
{
/*
SMnode *pMnode = pFsm->data;
SSdbIter *pIter;
if (iter == NULL) {
pIter = sdbIterInit(pMnode->sdb)
} else {
pIter = iter;
}
pIter = sdbIterRead(pIter);
return pIter;
*/
return
NULL
;
}
int32_t
mndSnapshotApply
(
struct
SSyncFSM
*
pFsm
,
const
SSnapshot
*
snapshot
,
char
*
pBuf
,
int32_t
len
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
sdbWrite
(
pMnode
->
pSdb
,
(
SSdbRaw
*
)
pBuf
);
return
0
;
}
void
mndReConfig
(
struct
SSyncFSM
*
pFsm
,
SSyncCfg
newCfg
,
SReConfigCbMeta
cbMeta
)
{
}
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pMnode
;
pFsm
->
FpCommitCb
=
mndSyncCommitMsg
;
pFsm
->
FpPreCommitCb
=
NULL
;
pFsm
->
FpRollBackCb
=
NULL
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpRestoreFinish
=
mndRestoreFinish
;
pFsm
->
FpRestoreSnapshot
=
NULL
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpSnapshotRead
=
mndSnapshotRead
;
pFsm
->
FpSnapshotApply
=
mndSnapshotApply
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
return
pFsm
;
}
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
aa857815
...
...
@@ -147,6 +147,10 @@ SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpGetSnapshot
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinish
=
NULL
;
pFsm
->
FpRestoreFinishCb
=
NULL
;
pFsm
->
FpSnapshotRead
=
NULL
;
pFsm
->
FpSnapshotApply
=
NULL
;
pFsm
->
FpReConfigCb
=
NULL
;
return
pFsm
;
}
\ No newline at end of file
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
aa857815
...
...
@@ -362,8 +362,8 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
// restore finish
if
(
pEntry
->
index
==
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
))
{
if
(
ths
->
restoreFinish
==
false
)
{
if
(
ths
->
pFsm
->
FpRestoreFinish
!=
NULL
)
{
ths
->
pFsm
->
FpRestoreFinish
(
ths
->
pFsm
);
if
(
ths
->
pFsm
->
FpRestoreFinish
Cb
!=
NULL
)
{
ths
->
pFsm
->
FpRestoreFinish
Cb
(
ths
->
pFsm
);
}
ths
->
restoreFinish
=
true
;
sInfo
(
"==syncNodeOnAppendEntriesCb== restoreFinish set true %p vgId:%d"
,
ths
,
ths
->
vgId
);
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
aa857815
...
...
@@ -139,8 +139,8 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
// restore finish
if
(
pEntry
->
index
==
pSyncNode
->
pLogStore
->
getLastIndex
(
pSyncNode
->
pLogStore
))
{
if
(
pSyncNode
->
restoreFinish
==
false
)
{
if
(
pSyncNode
->
pFsm
->
FpRestoreFinish
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpRestoreFinish
(
pSyncNode
->
pFsm
);
if
(
pSyncNode
->
pFsm
->
FpRestoreFinish
Cb
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpRestoreFinish
Cb
(
pSyncNode
->
pFsm
);
}
pSyncNode
->
restoreFinish
=
true
;
sInfo
(
"==syncMaybeAdvanceCommitIndex== restoreFinish set true %p vgId:%d"
,
pSyncNode
,
pSyncNode
->
vgId
);
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
aa857815
...
...
@@ -73,7 +73,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) {
return
0
;
}
void
FpRestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==Fp
RestoreFinishCb=="
);
}
void
RestoreFinishCb
(
struct
SSyncFSM
*
pFsm
)
{
sTrace
(
"==callback== ==
RestoreFinishCb=="
);
}
SSyncFSM
*
createFsm
()
{
SSyncFSM
*
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
...
...
@@ -81,7 +81,7 @@ SSyncFSM* createFsm() {
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpRestoreFinish
=
Fp
RestoreFinishCb
;
pFsm
->
FpRestoreFinish
Cb
=
RestoreFinishCb
;
return
pFsm
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录