Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d59a0b39
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看板
未验证
提交
d59a0b39
编写于
8月 10, 2022
作者:
L
Li Minghao
提交者:
GitHub
8月 10, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15944 from taosdata/feature/3.0_mhli
refactor(sync): add leader, follower call back
上级
51aa9413
b4c86857
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
1 deletion
+42
-1
include/libs/sync/sync.h
include/libs/sync/sync.h
+3
-0
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+14
-0
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+14
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+11
-1
未找到文件。
include/libs/sync/sync.h
浏览文件 @
d59a0b39
...
...
@@ -129,6 +129,9 @@ typedef struct SSyncFSM {
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpLeaderTransferCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpBecomeLeaderCb
)(
struct
SSyncFSM
*
pFsm
);
void
(
*
FpBecomeFollowerCb
)(
struct
SSyncFSM
*
pFsm
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
);
int32_t
(
*
FpGetSnapshotInfo
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
d59a0b39
...
...
@@ -166,6 +166,18 @@ void mndLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cb
mDebug
(
"vgId:1, mnode leader transfer finish"
);
}
static
void
mndBecomeFollower
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
mDebug
(
"vgId:1, become follower"
);
// clear old leader resource
}
static
void
mndBecomeLeader
(
struct
SSyncFSM
*
pFsm
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
mDebug
(
"vgId:1, become leader"
);
}
SSyncFSM
*
mndSyncMakeFsm
(
SMnode
*
pMnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pMnode
;
...
...
@@ -175,6 +187,8 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
mndLeaderTransfer
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
pFsm
->
FpBecomeLeaderCb
=
mndBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
mndBecomeFollower
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpGetSnapshotInfo
=
mndSyncGetSnapshotInfo
;
pFsm
->
FpSnapshotStartRead
=
mndSnapshotStartRead
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
d59a0b39
...
...
@@ -672,6 +672,18 @@ static void vnodeRestoreFinish(struct SSyncFSM *pFsm) {
vDebug
(
"vgId:%d, sync restore finished"
,
pVnode
->
config
.
vgId
);
}
static
void
vnodeBecomeFollower
(
struct
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
vDebug
(
"vgId:%d, become follower"
,
pVnode
->
config
.
vgId
);
// clear old leader resource
}
static
void
vnodeBecomeLeader
(
struct
SSyncFSM
*
pFsm
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
vDebug
(
"vgId:%d, become leader"
,
pVnode
->
config
.
vgId
);
}
static
SSyncFSM
*
vnodeSyncMakeFsm
(
SVnode
*
pVnode
)
{
SSyncFSM
*
pFsm
=
taosMemoryCalloc
(
1
,
sizeof
(
SSyncFSM
));
pFsm
->
data
=
pVnode
;
...
...
@@ -681,6 +693,8 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpGetSnapshotInfo
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
vnodeRestoreFinish
;
pFsm
->
FpLeaderTransferCb
=
vnodeLeaderTransfer
;
pFsm
->
FpBecomeLeaderCb
=
vnodeBecomeLeader
;
pFsm
->
FpBecomeFollowerCb
=
vnodeBecomeFollower
;
pFsm
->
FpReConfigCb
=
vnodeSyncReconfig
;
pFsm
->
FpSnapshotStartRead
=
vnodeSnapshotStartRead
;
pFsm
->
FpSnapshotStopRead
=
vnodeSnapshotStopRead
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
d59a0b39
...
...
@@ -2028,6 +2028,11 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) {
// reset elect timer
syncNodeResetElectTimer
(
pSyncNode
);
// call back
if
(
pSyncNode
->
pFsm
!=
NULL
&&
pSyncNode
->
pFsm
->
FpBecomeFollowerCb
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpBecomeFollowerCb
(
pSyncNode
->
pFsm
);
}
// trace log
do
{
int32_t
debugStrLen
=
strlen
(
debugStr
);
...
...
@@ -2109,6 +2114,11 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) {
// start heartbeat timer
syncNodeStartHeartbeatTimer
(
pSyncNode
);
// call back
if
(
pSyncNode
->
pFsm
!=
NULL
&&
pSyncNode
->
pFsm
->
FpBecomeLeaderCb
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpBecomeLeaderCb
(
pSyncNode
->
pFsm
);
}
// trace log
do
{
int32_t
debugStrLen
=
strlen
(
debugStr
);
...
...
@@ -3100,7 +3110,7 @@ void syncLogRecvAppendEntriesBatch(SSyncNode* pSyncNode, const SyncAppendEntries
syncNodeEventLog
(
pSyncNode
,
logBuf
);
}
void
syncLogSendAppendEntriesReply
(
SSyncNode
*
pSyncNode
,
const
SyncAppendEntriesReply
*
pMsg
,
const
char
*
s
)
{
void
syncLogSendAppendEntriesReply
(
SSyncNode
*
pSyncNode
,
const
SyncAppendEntriesReply
*
pMsg
,
const
char
*
s
)
{
char
host
[
64
];
uint16_t
port
;
syncUtilU642Addr
(
pMsg
->
destId
.
addr
,
host
,
sizeof
(
host
),
&
port
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录