Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8a15c2ad
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,发现更多精彩内容 >>
未验证
提交
8a15c2ad
编写于
6月 20, 2022
作者:
L
Li Minghao
提交者:
GitHub
6月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13995 from taosdata/feature/3.0_mhli
refactor(sync): get snapshot and create reader
上级
a8694bd8
5968c635
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
65 addition
and
50 deletion
+65
-50
include/libs/sync/sync.h
include/libs/sync/sync.h
+4
-3
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+12
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+3
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+3
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-2
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+3
-3
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+12
-12
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+1
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+3
-3
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+3
-3
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+3
-3
source/libs/sync/test/syncRaftLogTest2.cpp
source/libs/sync/test/syncRaftLogTest2.cpp
+1
-1
source/libs/sync/test/syncRaftLogTest3.cpp
source/libs/sync/test/syncRaftLogTest3.cpp
+6
-6
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+3
-3
source/libs/sync/test/syncSnapshotSenderTest.cpp
source/libs/sync/test/syncSnapshotSenderTest.cpp
+1
-1
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+3
-3
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+1
-1
未找到文件。
include/libs/sync/sync.h
浏览文件 @
8a15c2ad
...
...
@@ -107,7 +107,9 @@ typedef struct SSyncFSM {
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpLeaderTransferCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
);
int32_t
(
*
FpGetSnapshotInfo
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpSnapshotStartRead
)(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
);
int32_t
(
*
FpSnapshotStopRead
)(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
);
...
...
@@ -193,8 +195,7 @@ int32_t syncPropose(int64_t rid, const SRpcMsg* pMsg, bool isWeak);
bool
syncEnvIsStart
();
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMetaByIndex
(
int64_t
rid
,
SyncIndex
snapshotIndex
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
);
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
8a15c2ad
...
...
@@ -73,7 +73,17 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
}
}
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
)
{
// TODO:
// atomic operation
// step1. sdbGetCommitInfo
// step2. create ppReader with pReaderParam
return
0
;
}
int32_t
mndSyncGetSnapshotInfo
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
sdbGetCommitInfo
(
pMnode
->
pSdb
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
return
0
;
...
...
@@ -159,6 +169,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpGetSnapshotInfo
=
mndSyncGetSnapshotInfo
;
pFsm
->
FpSnapshotStartRead
=
mndSnapshotStartRead
;
pFsm
->
FpSnapshotStopRead
=
mndSnapshotStopRead
;
pFsm
->
FpSnapshotDoRead
=
mndSnapshotDoRead
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
8a15c2ad
...
...
@@ -353,8 +353,8 @@ static void vnodeSyncCommitMsg(SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta c
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
char
logBuf
[
256
]
=
{
0
};
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
(
*
pFsm
->
FpGetSnapshot
)(
pFsm
,
&
snapshot
);
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
(
*
pFsm
->
FpGetSnapshot
Info
)(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
}
...
...
@@ -416,7 +416,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpCommitCb
=
vnodeSyncCommitMsg
;
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpGetSnapshot
=
vnodeSyncGetSnapshot
;
pFsm
->
FpGetSnapshot
Info
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
NULL
;
pFsm
->
FpReConfigCb
=
vnodeSyncReconfig
;
pFsm
->
FpSnapshotStartRead
=
vnodeSnapshotStartRead
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
8a15c2ad
...
...
@@ -238,6 +238,9 @@ int32_t syncNodeUpdateNewConfigIndex(SSyncNode* ths, SSyncCfg* pNewCfg);
bool
syncNodeInRaftGroup
(
SSyncNode
*
ths
,
SRaftId
*
pRaftId
);
SSyncSnapshotSender
*
syncNodeGetSnapshotSender
(
SSyncNode
*
ths
,
SRaftId
*
pDestId
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMetaByIndex
(
int64_t
rid
,
SyncIndex
snapshotIndex
,
struct
SSnapshotMeta
*
sMeta
);
void
syncStartNormal
(
int64_t
rid
);
void
syncStartStandBy
(
int64_t
rid
);
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
8a15c2ad
...
...
@@ -497,7 +497,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
do
{
SyncIndex
myLastIndex
=
syncNodeGetLastIndex
(
ths
);
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
);
ths
->
pFsm
->
FpGetSnapshot
Info
(
ths
->
pFsm
,
&
snapshot
);
bool
condition0
=
(
pMsg
->
term
==
ths
->
pRaftStore
->
currentTerm
)
&&
(
ths
->
state
==
TAOS_SYNC_STATE_FOLLOWER
)
&&
syncNodeHasSnapshot
(
ths
);
...
...
@@ -710,7 +710,7 @@ int32_t syncNodeOnAppendEntriesSnapshotCb(SSyncNode* ths, SyncAppendEntries* pMs
if
(
pMsg
->
commitIndex
<=
ths
->
pLogStore
->
syncLogLastIndex
(
ths
->
pLogStore
))
{
// advance commit index to sanpshot first
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
);
ths
->
pFsm
->
FpGetSnapshot
Info
(
ths
->
pFsm
,
&
snapshot
);
if
(
snapshot
.
lastApplyIndex
>=
0
&&
snapshot
.
lastApplyIndex
>
ths
->
commitIndex
)
{
SyncIndex
commitBegin
=
ths
->
commitIndex
;
SyncIndex
commitEnd
=
snapshot
.
lastApplyIndex
;
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
8a15c2ad
...
...
@@ -123,7 +123,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, before pMatchIndex:"
,
ths
->
pMatchIndex
);
if
(
gRaftDetailLog
)
{
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
);
ths
->
pFsm
->
FpGetSnapshot
Info
(
ths
->
pFsm
,
&
snapshot
);
sTrace
(
"recv SyncAppendEntriesReply, before snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu"
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
}
...
...
@@ -175,7 +175,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
ASSERT
(
pSender
!=
NULL
);
bool
hasSnapshot
=
syncNodeHasSnapshot
(
ths
);
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
);
ths
->
pFsm
->
FpGetSnapshot
Info
(
ths
->
pFsm
,
&
snapshot
);
// start sending snapshot first time
// start here, stop by receiver
...
...
@@ -209,7 +209,7 @@ int32_t syncNodeOnAppendEntriesReplySnapshotCb(SSyncNode* ths, SyncAppendEntries
syncIndexMgrLog2
(
"recv SyncAppendEntriesReply, after pMatchIndex:"
,
ths
->
pMatchIndex
);
if
(
gRaftDetailLog
)
{
SSnapshot
snapshot
;
ths
->
pFsm
->
FpGetSnapshot
(
ths
->
pFsm
,
&
snapshot
);
ths
->
pFsm
->
FpGetSnapshot
Info
(
ths
->
pFsm
,
&
snapshot
);
sTrace
(
"recv SyncAppendEntriesReply, after snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu"
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
}
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
8a15c2ad
...
...
@@ -50,7 +50,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
// advance commit index to sanpshot first
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
snapshot
.
lastApplyIndex
>
0
&&
snapshot
.
lastApplyIndex
>
pSyncNode
->
commitIndex
)
{
SyncIndex
commitBegin
=
pSyncNode
->
commitIndex
;
SyncIndex
commitEnd
=
snapshot
.
lastApplyIndex
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
8a15c2ad
...
...
@@ -809,9 +809,9 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) {
pSyncNode
->
restoreFinish
=
false
;
// pSyncNode->pSnapshot = NULL;
// if (pSyncNode->pFsm->FpGetSnapshot != NULL) {
// if (pSyncNode->pFsm->FpGetSnapshot
Info
!= NULL) {
// pSyncNode->pSnapshot = taosMemoryMalloc(sizeof(SSnapshot));
// pSyncNode->pFsm->FpGetSnapshot(pSyncNode->pFsm, pSyncNode->pSnapshot);
// pSyncNode->pFsm->FpGetSnapshot
Info
(pSyncNode->pFsm, pSyncNode->pSnapshot);
// }
// tsem_init(&(pSyncNode->restoreSem), 0, 0);
...
...
@@ -1658,8 +1658,8 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode) {
bool
syncNodeHasSnapshot
(
SSyncNode
*
pSyncNode
)
{
bool
ret
=
false
;
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
snapshot
.
lastApplyIndex
>=
SYNC_INDEX_BEGIN
)
{
ret
=
true
;
}
...
...
@@ -1669,19 +1669,19 @@ bool syncNodeHasSnapshot(SSyncNode* pSyncNode) {
bool
syncNodeIsIndexInSnapshot
(
SSyncNode
*
pSyncNode
,
SyncIndex
index
)
{
ASSERT
(
syncNodeHasSnapshot
(
pSyncNode
));
ASSERT
(
pSyncNode
->
pFsm
->
FpGetSnapshot
!=
NULL
);
ASSERT
(
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
!=
NULL
);
ASSERT
(
index
>=
SYNC_INDEX_BEGIN
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
bool
b
=
(
index
<=
snapshot
.
lastApplyIndex
);
return
b
;
}
SyncIndex
syncNodeGetLastIndex
(
SSyncNode
*
pSyncNode
)
{
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
}
SyncIndex
logLastIndex
=
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
);
...
...
@@ -1694,8 +1694,8 @@ SyncTerm syncNodeGetLastTerm(SSyncNode* pSyncNode) {
if
(
syncNodeHasSnapshot
(
pSyncNode
))
{
// has snapshot
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
}
SyncIndex
logLastIndex
=
pSyncNode
->
pLogStore
->
syncLogLastIndex
(
pSyncNode
->
pLogStore
);
...
...
@@ -1747,8 +1747,8 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) {
if
(
syncNodeHasSnapshot
(
pSyncNode
))
{
// has snapshot
SSnapshot
snapshot
=
{.
data
=
NULL
,
.
lastApplyIndex
=
-
1
,
.
lastApplyTerm
=
0
};
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
if
(
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
}
if
(
index
>
snapshot
.
lastApplyIndex
+
1
)
{
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
8a15c2ad
...
...
@@ -124,7 +124,7 @@ int32_t syncNodeAppendEntriesPeersSnapshot(SSyncNode* pSyncNode) {
logStoreSimpleLog2
(
"begin append entries peers LogStore:"
,
pSyncNode
->
pLogStore
);
if
(
gRaftDetailLog
)
{
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
sTrace
(
"begin append entries peers, snapshot.lastApplyIndex:%ld, snapshot.lastApplyTerm:%lu"
,
snapshot
.
lastApplyIndex
,
snapshot
.
lastApplyTerm
);
}
...
...
source/libs/sync/src/syncSnapshot.c
浏览文件 @
8a15c2ad
...
...
@@ -45,7 +45,7 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI
pSender
->
replicaIndex
=
replicaIndex
;
pSender
->
term
=
pSyncNode
->
pRaftStore
->
currentTerm
;
pSender
->
privateTerm
=
taosGetTimestampMs
()
+
100
;
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
pSender
->
finish
=
false
;
}
else
{
sError
(
"snapshotSenderCreate cannot create sender"
);
...
...
@@ -84,7 +84,7 @@ void snapshotSenderStart(SSyncSnapshotSender *pSender) {
pSender
->
blockLen
=
0
;
// get current snapshot info
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
pSender
->
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSender
->
pSyncNode
->
pFsm
,
&
(
pSender
->
snapshot
));
sTrace
(
"snapshotSenderStart lastApplyIndex:%ld, lastApplyTerm:%lu, lastConfigIndex:%ld"
,
pSender
->
snapshot
.
lastApplyIndex
,
pSender
->
snapshot
.
lastApplyTerm
,
pSender
->
snapshot
.
lastConfigIndex
);
...
...
@@ -558,7 +558,7 @@ int32_t syncNodeOnSnapshotSendCb(SSyncNode *pSyncNode, SyncSnapshotSend *pMsg) {
}
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
do
{
char
*
eventLog
=
snapshotReceiver2SimpleStr
(
pReceiver
,
"snapshot receiver finish"
);
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
8a15c2ad
...
...
@@ -36,9 +36,9 @@ void cleanup() { walCleanUp(); }
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
SSnapshot
snapshot
;
pFsm
->
FpGetSnapshot
(
pFsm
,
&
snapshot
);
pFsm
->
FpGetSnapshot
Info
(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
}
...
...
@@ -159,7 +159,7 @@ SSyncFSM* createFsm() {
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
pFsm
->
FpRestoreFinishCb
=
RestoreFinishCb
;
pFsm
->
FpSnapshotStartRead
=
SnapshotStartRead
;
pFsm
->
FpSnapshotStopRead
=
SnapshotStopRead
;
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
8a15c2ad
...
...
@@ -35,9 +35,9 @@ void cleanup() { walCleanUp(); }
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
SSnapshot
snapshot
;
pFsm
->
FpGetSnapshot
(
pFsm
,
&
snapshot
);
pFsm
->
FpGetSnapshot
Info
(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
}
...
...
@@ -90,7 +90,7 @@ SSyncFSM* createFsm() {
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
pFsm
->
FpRestoreFinishCb
=
RestoreFinishCb
;
pFsm
->
FpReConfigCb
=
ReConfigCb
;
...
...
source/libs/sync/test/syncRaftLogTest2.cpp
浏览文件 @
8a15c2ad
...
...
@@ -54,7 +54,7 @@ void init() {
pSyncNode
->
pWal
=
pWal
;
pSyncNode
->
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
pSyncNode
->
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
}
void
cleanup
()
{
...
...
source/libs/sync/test/syncRaftLogTest3.cpp
浏览文件 @
8a15c2ad
...
...
@@ -54,7 +54,7 @@ void init() {
pSyncNode
->
pWal
=
pWal
;
pSyncNode
->
pFsm
=
(
SSyncFSM
*
)
taosMemoryMalloc
(
sizeof
(
SSyncFSM
));
pSyncNode
->
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
}
void
cleanup
()
{
...
...
@@ -80,7 +80,7 @@ void test1() {
bool
hasSnapshot
=
syncNodeHasSnapshot
(
pSyncNode
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
SyncIndex
lastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncTerm
lastTerm
=
syncNodeGetLastTerm
(
pSyncNode
);
...
...
@@ -146,7 +146,7 @@ void test2() {
bool
hasSnapshot
=
syncNodeHasSnapshot
(
pSyncNode
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
SyncIndex
lastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncTerm
lastTerm
=
syncNodeGetLastTerm
(
pSyncNode
);
...
...
@@ -203,7 +203,7 @@ void test3() {
bool
hasSnapshot
=
syncNodeHasSnapshot
(
pSyncNode
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
SyncIndex
lastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncTerm
lastTerm
=
syncNodeGetLastTerm
(
pSyncNode
);
...
...
@@ -268,7 +268,7 @@ void test4() {
bool
hasSnapshot
=
syncNodeHasSnapshot
(
pSyncNode
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
SyncIndex
lastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncTerm
lastTerm
=
syncNodeGetLastTerm
(
pSyncNode
);
...
...
@@ -335,7 +335,7 @@ void test5() {
bool
hasSnapshot
=
syncNodeHasSnapshot
(
pSyncNode
);
SSnapshot
snapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
(
pSyncNode
->
pFsm
,
&
snapshot
);
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
(
pSyncNode
->
pFsm
,
&
snapshot
);
SyncIndex
lastIndex
=
syncNodeGetLastIndex
(
pSyncNode
);
SyncTerm
lastTerm
=
syncNodeGetLastTerm
(
pSyncNode
);
...
...
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
8a15c2ad
...
...
@@ -32,9 +32,9 @@ void cleanup() { walCleanUp(); }
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
SSnapshot
snapshot
;
pFsm
->
FpGetSnapshot
(
pFsm
,
&
snapshot
);
pFsm
->
FpGetSnapshot
Info
(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
}
...
...
@@ -75,7 +75,7 @@ SSyncFSM* createFsm() {
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
return
pFsm
;
}
...
...
source/libs/sync/test/syncSnapshotSenderTest.cpp
浏览文件 @
8a15c2ad
...
...
@@ -40,7 +40,7 @@ SSyncSnapshotSender* createSender() {
pSyncNode
->
pFsm
->
FpSnapshotStartRead
=
SnapshotStartRead
;
pSyncNode
->
pFsm
->
FpSnapshotStopRead
=
SnapshotStopRead
;
pSyncNode
->
pFsm
->
FpSnapshotDoRead
=
SnapshotDoRead
;
pSyncNode
->
pFsm
->
FpGetSnapshot
=
GetSnapshot
;
pSyncNode
->
pFsm
->
FpGetSnapshot
Info
=
GetSnapshot
;
SSyncSnapshotSender
*
pSender
=
snapshotSenderCreate
(
pSyncNode
,
2
);
pSender
->
start
=
true
;
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
8a15c2ad
...
...
@@ -35,9 +35,9 @@ const char *pWalDir = "./syncSnapshotTest_wal";
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
SSnapshot
snapshot
;
pFsm
->
FpGetSnapshot
(
pFsm
,
&
snapshot
);
pFsm
->
FpGetSnapshot
Info
(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
}
...
...
@@ -79,7 +79,7 @@ void initFsm() {
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
}
SSyncNode
*
syncNodeInit
()
{
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
8a15c2ad
...
...
@@ -172,7 +172,7 @@ SSyncFSM* createFsm() {
pFsm
->
FpRollBackCb
=
RollBackCb
;
pFsm
->
FpReConfigCb
=
ReConfigCb
;
pFsm
->
FpGetSnapshot
=
GetSnapshotCb
;
pFsm
->
FpGetSnapshot
Info
=
GetSnapshotCb
;
pFsm
->
FpRestoreFinishCb
=
RestoreFinishCb
;
pFsm
->
FpSnapshotStartRead
=
SnapshotStartRead
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录