Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d35028ae
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d35028ae
编写于
11月 01, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: refact sync callback func
上级
f4dc7d07
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
106 addition
and
167 deletion
+106
-167
include/libs/sync/sync.h
include/libs/sync/sync.h
+9
-3
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+0
-9
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+0
-1
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+6
-9
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+0
-1
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+6
-7
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+3
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+35
-76
source/libs/sync/src/syncRespMgr.c
source/libs/sync/src/syncRespMgr.c
+11
-10
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+0
-12
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+2
-2
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+2
-2
source/libs/sync/test/syncElectTest.cpp
source/libs/sync/test/syncElectTest.cpp
+2
-2
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+2
-2
source/libs/sync/test/syncEnqTest.cpp
source/libs/sync/test/syncEnqTest.cpp
+3
-3
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+3
-3
source/libs/sync/test/syncInitTest.cpp
source/libs/sync/test/syncInitTest.cpp
+2
-2
source/libs/sync/test/syncPingSelfTest.cpp
source/libs/sync/test/syncPingSelfTest.cpp
+2
-2
source/libs/sync/test/syncPingTimerTest.cpp
source/libs/sync/test/syncPingTimerTest.cpp
+2
-2
source/libs/sync/test/syncPingTimerTest2.cpp
source/libs/sync/test/syncPingTimerTest2.cpp
+2
-2
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+2
-2
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
+2
-2
source/libs/sync/test/syncVotesGrantedTest.cpp
source/libs/sync/test/syncVotesGrantedTest.cpp
+2
-2
source/libs/sync/test/syncVotesRespondTest.cpp
source/libs/sync/test/syncVotesRespondTest.cpp
+2
-2
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+3
-3
未找到文件。
include/libs/sync/sync.h
浏览文件 @
d35028ae
...
@@ -193,9 +193,13 @@ typedef struct SSyncInfo {
...
@@ -193,9 +193,13 @@ typedef struct SSyncInfo {
SWal
*
pWal
;
SWal
*
pWal
;
SSyncFSM
*
pFsm
;
SSyncFSM
*
pFsm
;
SMsgCb
*
msgcb
;
SMsgCb
*
msgcb
;
int32_t
(
*
FpSendMsg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
pingMs
;
int32_t
(
*
FpEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
electMs
;
int32_t
(
*
FpEqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
heartbeatMs
;
int32_t
(
*
syncSendMSg
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
syncEqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
syncEqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
}
SSyncInfo
;
int32_t
syncInit
();
int32_t
syncInit
();
...
@@ -228,6 +232,8 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
...
@@ -228,6 +232,8 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm);
int32_t
syncProcessMsg
(
int64_t
rid
,
SRpcMsg
*
pMsg
);
int32_t
syncProcessMsg
(
int64_t
rid
,
SRpcMsg
*
pMsg
);
const
char
*
syncUtilState2String
(
ESyncState
state
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/sync/syncTools.h
浏览文件 @
d35028ae
...
@@ -28,20 +28,11 @@ typedef struct SRaftId {
...
@@ -28,20 +28,11 @@ typedef struct SRaftId {
SyncGroupId
vgId
;
SyncGroupId
vgId
;
}
SRaftId
;
}
SRaftId
;
void
syncSetMsgCb
(
int64_t
rid
,
const
SMsgCb
*
msgcb
);
char
*
sync2SimpleStr
(
int64_t
rid
);
char
*
sync2SimpleStr
(
int64_t
rid
);
// set timer ms
void
setPingTimerMS
(
int64_t
rid
,
int32_t
pingTimerMS
);
void
setElectTimerMS
(
int64_t
rid
,
int32_t
electTimerMS
);
void
setHeartbeatTimerMS
(
int64_t
rid
,
int32_t
hbTimerMS
);
// for compatibility, the same as syncPropose
// for compatibility, the same as syncPropose
int32_t
syncForwardToPeer
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncForwardToPeer
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
// utils
const
char
*
syncUtilState2String
(
ESyncState
state
);
// ------------------ for debug -------------------
// ------------------ for debug -------------------
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint
(
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
void
syncRpcMsgPrint2
(
char
*
s
,
SRpcMsg
*
pMsg
);
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
d35028ae
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
#include "sdb.h"
#include "sdb.h"
#include "sync.h"
#include "sync.h"
#include "syncTools.h"
#include "tcache.h"
#include "tcache.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "tglobal.h"
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
d35028ae
...
@@ -202,9 +202,12 @@ int32_t mndInitSync(SMnode *pMnode) {
...
@@ -202,9 +202,12 @@ int32_t mndInitSync(SMnode *pMnode) {
.
vgId
=
1
,
.
vgId
=
1
,
.
pWal
=
pMnode
->
pWal
,
.
pWal
=
pMnode
->
pWal
,
.
msgcb
=
NULL
,
.
msgcb
=
NULL
,
.
FpSendMsg
=
mndSyncSendMsg
,
.
syncSendMSg
=
mndSyncSendMsg
,
.
FpEqMsg
=
mndSyncEqMsg
,
.
syncEqMsg
=
mndSyncEqMsg
,
.
FpEqCtrlMsg
=
NULL
,
.
syncEqCtrlMsg
=
NULL
,
.
pingMs
=
5000
,
.
electMs
=
3000
,
.
heartbeatMs
=
500
,
};
};
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
pMnode
->
path
,
TD_DIRSEP
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
pMnode
->
path
,
TD_DIRSEP
);
...
@@ -228,11 +231,6 @@ int32_t mndInitSync(SMnode *pMnode) {
...
@@ -228,11 +231,6 @@ int32_t mndInitSync(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
// decrease election timer
setPingTimerMS
(
pMgmt
->
sync
,
5000
);
setElectTimerMS
(
pMgmt
->
sync
,
3000
);
setHeartbeatTimerMS
(
pMgmt
->
sync
,
500
);
mInfo
(
"mnode-sync is opened, id:%"
PRId64
,
pMgmt
->
sync
);
mInfo
(
"mnode-sync is opened, id:%"
PRId64
,
pMgmt
->
sync
);
return
0
;
return
0
;
}
}
...
@@ -303,7 +301,6 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
...
@@ -303,7 +301,6 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) {
void
mndSyncStart
(
SMnode
*
pMnode
)
{
void
mndSyncStart
(
SMnode
*
pMnode
)
{
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
syncSetMsgCb
(
pMgmt
->
sync
,
&
pMnode
->
msgCb
);
syncStart
(
pMgmt
->
sync
);
syncStart
(
pMgmt
->
sync
);
mInfo
(
"vgId:1, sync started, id:%"
PRId64
,
pMgmt
->
sync
);
mInfo
(
"vgId:1, sync started, id:%"
PRId64
,
pMgmt
->
sync
);
}
}
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
d35028ae
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
#define _TD_VND_H_
#define _TD_VND_H_
#include "sync.h"
#include "sync.h"
#include "syncTools.h"
#include "ttrace.h"
#include "ttrace.h"
#include "vnodeInt.h"
#include "vnodeInt.h"
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
d35028ae
...
@@ -503,9 +503,12 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
...
@@ -503,9 +503,12 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
.
syncCfg
=
pVnode
->
config
.
syncCfg
,
.
syncCfg
=
pVnode
->
config
.
syncCfg
,
.
pWal
=
pVnode
->
pWal
,
.
pWal
=
pVnode
->
pWal
,
.
msgcb
=
NULL
,
.
msgcb
=
NULL
,
.
FpSendMsg
=
vnodeSyncSendMsg
,
.
syncSendMSg
=
vnodeSyncSendMsg
,
.
FpEqMsg
=
vnodeSyncEqMsg
,
.
syncEqMsg
=
vnodeSyncEqMsg
,
.
FpEqCtrlMsg
=
vnodeSyncEqCtrlMsg
,
.
syncEqCtrlMsg
=
vnodeSyncEqCtrlMsg
,
.
pingMs
=
5000
,
.
electMs
=
4000
,
.
heartbeatMs
=
700
,
};
};
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
path
,
TD_DIRSEP
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s%ssync"
,
path
,
TD_DIRSEP
);
...
@@ -524,15 +527,11 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
...
@@ -524,15 +527,11 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
return
-
1
;
return
-
1
;
}
}
setPingTimerMS
(
pVnode
->
sync
,
5000
);
setElectTimerMS
(
pVnode
->
sync
,
4000
);
setHeartbeatTimerMS
(
pVnode
->
sync
,
700
);
return
0
;
return
0
;
}
}
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
void
vnodeSyncStart
(
SVnode
*
pVnode
)
{
vDebug
(
"vgId:%d, start sync"
,
pVnode
->
config
.
vgId
);
vDebug
(
"vgId:%d, start sync"
,
pVnode
->
config
.
vgId
);
syncSetMsgCb
(
pVnode
->
sync
,
&
pVnode
->
msgCb
);
syncStart
(
pVnode
->
sync
);
syncStart
(
pVnode
->
sync
);
}
}
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
d35028ae
...
@@ -107,9 +107,9 @@ typedef struct SSyncNode {
...
@@ -107,9 +107,9 @@ typedef struct SSyncNode {
// sync io
// sync io
SWal
*
pWal
;
SWal
*
pWal
;
const
SMsgCb
*
msgcb
;
const
SMsgCb
*
msgcb
;
int32_t
(
*
FpSendMs
g
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
syncSendMS
g
)(
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
(
*
Fp
EqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
sync
EqMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
Fp
EqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
int32_t
(
*
sync
EqCtrlMsg
)(
const
SMsgCb
*
msgcb
,
SRpcMsg
*
pMsg
);
// init internal
// init internal
SNodeInfo
myNodeInfo
;
SNodeInfo
myNodeInfo
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
d35028ae
...
@@ -56,6 +56,12 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) {
...
@@ -56,6 +56,12 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) {
return
-
1
;
return
-
1
;
}
}
pSyncNode
->
pingBaseLine
=
pSyncInfo
->
pingMs
;
pSyncNode
->
pingTimerMS
=
pSyncInfo
->
pingMs
;
pSyncNode
->
electBaseLine
=
pSyncInfo
->
electMs
;
pSyncNode
->
hbBaseLine
=
pSyncInfo
->
heartbeatMs
;
pSyncNode
->
heartbeatTimerMS
=
pSyncInfo
->
heartbeatMs
;
pSyncNode
->
msgcb
=
pSyncInfo
->
msgcb
;
return
pSyncNode
->
rid
;
return
pSyncNode
->
rid
;
}
}
...
@@ -747,18 +753,6 @@ static void syncGetAndDelRespRpc(SSyncNode* pSyncNode, uint64_t index, SRpcHandl
...
@@ -747,18 +753,6 @@ static void syncGetAndDelRespRpc(SSyncNode* pSyncNode, uint64_t index, SRpcHandl
sTrace
(
"vgId:%d, get seq:%"
PRIu64
" rpc handle:%p"
,
pSyncNode
->
vgId
,
index
,
pInfo
->
handle
);
sTrace
(
"vgId:%d, get seq:%"
PRIu64
" rpc handle:%p"
,
pSyncNode
->
vgId
,
index
,
pInfo
->
handle
);
}
}
void
syncSetMsgCb
(
int64_t
rid
,
const
SMsgCb
*
msgcb
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
sTrace
(
"syncSetQ get pSyncNode is NULL, rid:%"
PRId64
,
rid
);
return
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
pSyncNode
->
msgcb
=
msgcb
;
syncNodeRelease
(
pSyncNode
);
}
char
*
sync2SimpleStr
(
int64_t
rid
)
{
char
*
sync2SimpleStr
(
int64_t
rid
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
...
@@ -772,41 +766,6 @@ char* sync2SimpleStr(int64_t rid) {
...
@@ -772,41 +766,6 @@ char* sync2SimpleStr(int64_t rid) {
return
s
;
return
s
;
}
}
void
setPingTimerMS
(
int64_t
rid
,
int32_t
pingTimerMS
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
pSyncNode
->
pingBaseLine
=
pingTimerMS
;
pSyncNode
->
pingTimerMS
=
pingTimerMS
;
syncNodeRelease
(
pSyncNode
);
}
void
setElectTimerMS
(
int64_t
rid
,
int32_t
electTimerMS
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
pSyncNode
->
electBaseLine
=
electTimerMS
;
syncNodeRelease
(
pSyncNode
);
}
void
setHeartbeatTimerMS
(
int64_t
rid
,
int32_t
hbTimerMS
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
return
;
}
ASSERT
(
rid
==
pSyncNode
->
rid
);
pSyncNode
->
hbBaseLine
=
hbTimerMS
;
pSyncNode
->
heartbeatTimerMS
=
hbTimerMS
;
syncNodeRelease
(
pSyncNode
);
}
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
rid
);
if
(
pSyncNode
==
NULL
)
{
if
(
pSyncNode
==
NULL
)
{
...
@@ -903,7 +862,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
...
@@ -903,7 +862,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak) {
}
}
}
else
{
}
else
{
if
(
pSyncNode
->
FpEqMsg
!=
NULL
&&
(
*
pSyncNode
->
Fp
EqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
)
==
0
)
{
if
(
pSyncNode
->
syncEqMsg
!=
NULL
&&
(
*
pSyncNode
->
sync
EqMsg
)(
pSyncNode
->
msgcb
,
&
rpcMsg
)
==
0
)
{
ret
=
0
;
ret
=
0
;
}
else
{
}
else
{
ret
=
-
1
;
ret
=
-
1
;
...
@@ -1034,9 +993,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
...
@@ -1034,9 +993,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
pSyncNode
->
pWal
=
pSyncInfo
->
pWal
;
pSyncNode
->
pWal
=
pSyncInfo
->
pWal
;
pSyncNode
->
msgcb
=
pSyncInfo
->
msgcb
;
pSyncNode
->
msgcb
=
pSyncInfo
->
msgcb
;
pSyncNode
->
FpSendMsg
=
pSyncInfo
->
FpSendMs
g
;
pSyncNode
->
syncSendMSg
=
pSyncInfo
->
syncSendMS
g
;
pSyncNode
->
FpEqMsg
=
pSyncInfo
->
Fp
EqMsg
;
pSyncNode
->
syncEqMsg
=
pSyncInfo
->
sync
EqMsg
;
pSyncNode
->
FpEqCtrlMsg
=
pSyncInfo
->
Fp
EqCtrlMsg
;
pSyncNode
->
syncEqCtrlMsg
=
pSyncInfo
->
sync
EqCtrlMsg
;
// init raft config
// init raft config
pSyncNode
->
pRaftCfg
=
raftCfgOpen
(
pSyncNode
->
configPath
);
pSyncNode
->
pRaftCfg
=
raftCfgOpen
(
pSyncNode
->
configPath
);
...
@@ -1552,12 +1511,12 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
...
@@ -1552,12 +1511,12 @@ int32_t syncNodeRestartHeartbeatTimer(SSyncNode* pSyncNode) {
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
SEpSet
epSet
;
syncUtilraftId2EpSet
(
destRaftId
,
&
epSet
);
syncUtilraftId2EpSet
(
destRaftId
,
&
epSet
);
if
(
pSyncNode
->
FpSendMs
g
!=
NULL
)
{
if
(
pSyncNode
->
syncSendMS
g
!=
NULL
)
{
// htonl
// htonl
syncUtilMsgHtoN
(
pMsg
->
pCont
);
syncUtilMsgHtoN
(
pMsg
->
pCont
);
pMsg
->
info
.
noResp
=
1
;
pMsg
->
info
.
noResp
=
1
;
pSyncNode
->
FpSendMs
g
(
&
epSet
,
pMsg
);
pSyncNode
->
syncSendMS
g
(
&
epSet
,
pMsg
);
}
else
{
}
else
{
sError
(
"vgId:%d, sync send msg by id error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
sError
(
"vgId:%d, sync send msg by id error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
return
-
1
;
return
-
1
;
...
@@ -1569,12 +1528,12 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp
...
@@ -1569,12 +1528,12 @@ int32_t syncNodeSendMsgById(const SRaftId* destRaftId, SSyncNode* pSyncNode, SRp
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
SEpSet
epSet
;
syncUtilnodeInfo2EpSet
(
nodeInfo
,
&
epSet
);
syncUtilnodeInfo2EpSet
(
nodeInfo
,
&
epSet
);
if
(
pSyncNode
->
FpSendMs
g
!=
NULL
)
{
if
(
pSyncNode
->
syncSendMS
g
!=
NULL
)
{
// htonl
// htonl
syncUtilMsgHtoN
(
pMsg
->
pCont
);
syncUtilMsgHtoN
(
pMsg
->
pCont
);
pMsg
->
info
.
noResp
=
1
;
pMsg
->
info
.
noResp
=
1
;
pSyncNode
->
FpSendMs
g
(
&
epSet
,
pMsg
);
pSyncNode
->
syncSendMS
g
(
&
epSet
,
pMsg
);
}
else
{
}
else
{
sError
(
"vgId:%d, sync send msg by info error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
sError
(
"vgId:%d, sync send msg by info error, fp-send-msg is null"
,
pSyncNode
->
vgId
);
}
}
...
@@ -1598,13 +1557,13 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
...
@@ -1598,13 +1557,13 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) {
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
msgcb
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
msgcb
);
cJSON_AddStringToObject
(
pRoot
,
"rpcClient"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"rpcClient"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
FpSendMs
g
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
syncSendMS
g
);
cJSON_AddStringToObject
(
pRoot
,
"
FpSendMs
g"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"
syncSendMS
g"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
msgcb
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
msgcb
);
cJSON_AddStringToObject
(
pRoot
,
"queue"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"queue"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
Fp
EqMsg
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%p"
,
pSyncNode
->
sync
EqMsg
);
cJSON_AddStringToObject
(
pRoot
,
"
Fp
EqMsg"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"
sync
EqMsg"
,
u64buf
);
// init internal
// init internal
cJSON
*
pMe
=
syncUtilNodeInfo2Json
(
&
pSyncNode
->
myNodeInfo
);
cJSON
*
pMe
=
syncUtilNodeInfo2Json
(
&
pSyncNode
->
myNodeInfo
);
...
@@ -2617,8 +2576,8 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
...
@@ -2617,8 +2576,8 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqPingTimer=="
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqPingTimer=="
,
&
rpcMsg
);
if
(
pSyncNode
->
Fp
EqMsg
!=
NULL
)
{
if
(
pSyncNode
->
sync
EqMsg
!=
NULL
)
{
int32_t
code
=
pSyncNode
->
Fp
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
int32_t
code
=
pSyncNode
->
sync
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, sync enqueue ping msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
sError
(
"vgId:%d, sync enqueue ping msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -2626,7 +2585,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
...
@@ -2626,7 +2585,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) {
return
;
return
;
}
}
}
else
{
}
else
{
sTrace
(
"syncNodeEqPingTimer pSyncNode->
Fp
EqMsg is NULL"
);
sTrace
(
"syncNodeEqPingTimer pSyncNode->
sync
EqMsg is NULL"
);
}
}
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
...
@@ -2651,8 +2610,8 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
...
@@ -2651,8 +2610,8 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
pSyncNode
->
vgId
,
pSyncNode
);
pSyncNode
->
vgId
,
pSyncNode
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
if
(
pSyncNode
->
Fp
EqMsg
!=
NULL
)
{
if
(
pSyncNode
->
sync
EqMsg
!=
NULL
)
{
int32_t
code
=
pSyncNode
->
Fp
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
int32_t
code
=
pSyncNode
->
sync
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, sync enqueue elect msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
sError
(
"vgId:%d, sync enqueue elect msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -2668,7 +2627,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
...
@@ -2668,7 +2627,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) {
}
while
(
0
);
}
while
(
0
);
}
else
{
}
else
{
sTrace
(
"syncNodeEqElectTimer
Fp
EqMsg is NULL"
);
sTrace
(
"syncNodeEqElectTimer
sync
EqMsg is NULL"
);
}
}
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
...
@@ -2700,8 +2659,8 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
...
@@ -2700,8 +2659,8 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncTimeout2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqHeartbeatTimer=="
,
&
rpcMsg
);
syncRpcMsgLog2
((
char
*
)
"==syncNodeEqHeartbeatTimer=="
,
&
rpcMsg
);
if
(
pSyncNode
->
Fp
EqMsg
!=
NULL
)
{
if
(
pSyncNode
->
sync
EqMsg
!=
NULL
)
{
int32_t
code
=
pSyncNode
->
Fp
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
int32_t
code
=
pSyncNode
->
sync
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, sync enqueue timer msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
sError
(
"vgId:%d, sync enqueue timer msg error, code:%d"
,
pSyncNode
->
vgId
,
code
);
rpcFreeCont
(
rpcMsg
.
pCont
);
rpcFreeCont
(
rpcMsg
.
pCont
);
...
@@ -2709,7 +2668,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
...
@@ -2709,7 +2668,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
return
;
return
;
}
}
}
else
{
}
else
{
sError
(
"vgId:%d, enqueue msg cb ptr (i.e.
Fp
EqMsg) not set."
,
pSyncNode
->
vgId
);
sError
(
"vgId:%d, enqueue msg cb ptr (i.e.
sync
EqMsg) not set."
,
pSyncNode
->
vgId
);
}
}
syncTimeoutDestroy
(
pSyncMsg
);
syncTimeoutDestroy
(
pSyncMsg
);
...
@@ -2756,8 +2715,8 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
...
@@ -2756,8 +2715,8 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
// eq msg
// eq msg
#if 0
#if 0
if (pSyncNode->
Fp
EqCtrlMsg != NULL) {
if (pSyncNode->
sync
EqCtrlMsg != NULL) {
int32_t code = pSyncNode->
Fp
EqCtrlMsg(pSyncNode->msgcb, &rpcMsg);
int32_t code = pSyncNode->
sync
EqCtrlMsg(pSyncNode->msgcb, &rpcMsg);
if (code != 0) {
if (code != 0) {
sError("vgId:%d, sync ctrl enqueue timer msg error, code:%d", pSyncNode->vgId, code);
sError("vgId:%d, sync ctrl enqueue timer msg error, code:%d", pSyncNode->vgId, code);
rpcFreeCont(rpcMsg.pCont);
rpcFreeCont(rpcMsg.pCont);
...
@@ -2765,7 +2724,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
...
@@ -2765,7 +2724,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) {
return;
return;
}
}
} else {
} else {
sError("vgId:%d, enqueue ctrl msg cb ptr (i.e.
Fp
EqMsg) not set.", pSyncNode->vgId);
sError("vgId:%d, enqueue ctrl msg cb ptr (i.e.
sync
EqMsg) not set.", pSyncNode->vgId);
}
}
#endif
#endif
...
@@ -2805,10 +2764,10 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) {
...
@@ -2805,10 +2764,10 @@ static int32_t syncNodeEqNoop(SSyncNode* ths) {
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
if
(
ths
->
Fp
EqMsg
!=
NULL
)
{
if
(
ths
->
sync
EqMsg
!=
NULL
)
{
ths
->
Fp
EqMsg
(
ths
->
msgcb
,
&
rpcMsg
);
ths
->
sync
EqMsg
(
ths
->
msgcb
,
&
rpcMsg
);
}
else
{
}
else
{
sTrace
(
"syncNodeEqNoop pSyncNode->
Fp
EqMsg is NULL"
);
sTrace
(
"syncNodeEqNoop pSyncNode->
sync
EqMsg is NULL"
);
}
}
syncEntryDestory
(
pEntry
);
syncEntryDestory
(
pEntry
);
...
@@ -2919,8 +2878,8 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg) {
...
@@ -2919,8 +2878,8 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg) {
SRpcMsg
rpcMsgLocalCmd
;
SRpcMsg
rpcMsgLocalCmd
;
syncLocalCmd2RpcMsg
(
pSyncMsg
,
&
rpcMsgLocalCmd
);
syncLocalCmd2RpcMsg
(
pSyncMsg
,
&
rpcMsgLocalCmd
);
if
(
ths
->
Fp
EqMsg
!=
NULL
&&
ths
->
msgcb
!=
NULL
)
{
if
(
ths
->
sync
EqMsg
!=
NULL
&&
ths
->
msgcb
!=
NULL
)
{
int32_t
code
=
ths
->
Fp
EqMsg
(
ths
->
msgcb
,
&
rpcMsgLocalCmd
);
int32_t
code
=
ths
->
sync
EqMsg
(
ths
->
msgcb
,
&
rpcMsgLocalCmd
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
sError
(
"vgId:%d, sync enqueue step-down msg error, code:%d"
,
ths
->
vgId
,
code
);
sError
(
"vgId:%d, sync enqueue step-down msg error, code:%d"
,
ths
->
vgId
,
code
);
rpcFreeCont
(
rpcMsgLocalCmd
.
pCont
);
rpcFreeCont
(
rpcMsgLocalCmd
.
pCont
);
...
...
source/libs/sync/src/syncRespMgr.c
浏览文件 @
d35028ae
...
@@ -145,16 +145,17 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
...
@@ -145,16 +145,17 @@ void syncRespCleanByTTL(SSyncRespMgr *pObj, int64_t ttl, bool rsp) {
taosArrayPush
(
delIndexArray
,
pSeqNum
);
taosArrayPush
(
delIndexArray
,
pSeqNum
);
cnt
++
;
cnt
++
;
SFsmCbMeta
cbMeta
=
{
0
};
SFsmCbMeta
cbMeta
=
{
cbMeta
.
index
=
SYNC_INDEX_INVALID
;
cbMeta
.
index
=
SYNC_INDEX_INVALID
,
cbMeta
.
lastConfigIndex
=
SYNC_INDEX_INVALID
;
cbMeta
.
lastConfigIndex
=
SYNC_INDEX_INVALID
,
cbMeta
.
isWeak
=
false
;
cbMeta
.
isWeak
=
false
,
cbMeta
.
code
=
TSDB_CODE_SYN_TIMEOUT
;
cbMeta
.
code
=
TSDB_CODE_SYN_TIMEOUT
,
cbMeta
.
state
=
pSyncNode
->
state
;
cbMeta
.
state
=
pSyncNode
->
state
,
cbMeta
.
seqNum
=
*
pSeqNum
;
cbMeta
.
seqNum
=
*
pSeqNum
,
cbMeta
.
term
=
SYNC_TERM_INVALID
;
cbMeta
.
term
=
SYNC_TERM_INVALID
,
cbMeta
.
currentTerm
=
pSyncNode
->
pRaftStore
->
currentTerm
;
cbMeta
.
currentTerm
=
pSyncNode
->
pRaftStore
->
currentTerm
,
cbMeta
.
flag
=
0
;
cbMeta
.
flag
=
0
,
};
pStub
->
rpcMsg
.
pCont
=
NULL
;
pStub
->
rpcMsg
.
pCont
=
NULL
;
pStub
->
rpcMsg
.
contLen
=
0
;
pStub
->
rpcMsg
.
contLen
=
0
;
...
...
source/libs/sync/src/syncUtil.c
浏览文件 @
d35028ae
...
@@ -177,18 +177,6 @@ char* syncUtilRaftId2Str(const SRaftId* p) {
...
@@ -177,18 +177,6 @@ char* syncUtilRaftId2Str(const SRaftId* p) {
}
}
const
char
*
syncUtilState2String
(
ESyncState
state
)
{
const
char
*
syncUtilState2String
(
ESyncState
state
)
{
/*
if (state == TAOS_SYNC_STATE_FOLLOWER) {
return "TAOS_SYNC_STATE_FOLLOWER";
} else if (state == TAOS_SYNC_STATE_CANDIDATE) {
return "TAOS_SYNC_STATE_CANDIDATE";
} else if (state == TAOS_SYNC_STATE_LEADER) {
return "TAOS_SYNC_STATE_LEADER";
} else {
return "TAOS_SYNC_STATE_UNKNOWN";
}
*/
if
(
state
==
TAOS_SYNC_STATE_FOLLOWER
)
{
if
(
state
==
TAOS_SYNC_STATE_FOLLOWER
)
{
return
"follower"
;
return
"follower"
;
}
else
if
(
state
==
TAOS_SYNC_STATE_CANDIDATE
)
{
}
else
if
(
state
==
TAOS_SYNC_STATE_CANDIDATE
)
{
...
...
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
d35028ae
...
@@ -195,8 +195,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
...
@@ -195,8 +195,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
createFsm
();
syncInfo
.
pFsm
=
createFsm
();
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
pWal
=
pWal
;
...
...
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
d35028ae
...
@@ -120,8 +120,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
...
@@ -120,8 +120,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
createFsm
();
syncInfo
.
pFsm
=
createFsm
();
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
pWal
=
pWal
;
...
...
source/libs/sync/test/syncElectTest.cpp
浏览文件 @
d35028ae
...
@@ -45,8 +45,8 @@ SSyncNode* createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWa
...
@@ -45,8 +45,8 @@ SSyncNode* createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWa
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
NULL
;
syncInfo
.
pFsm
=
NULL
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
pWal
=
pWal
;
...
...
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
d35028ae
...
@@ -32,8 +32,8 @@ SSyncNode *pSyncNode;
...
@@ -32,8 +32,8 @@ SSyncNode *pSyncNode;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncEnqTest.cpp
浏览文件 @
d35028ae
...
@@ -25,8 +25,8 @@ SSyncFSM* pFsm;
...
@@ -25,8 +25,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
@@ -97,7 +97,7 @@ int main(int argc, char** argv) {
...
@@ -97,7 +97,7 @@ int main(int argc, char** argv) {
SyncPingReply
*
pSyncMsg
=
syncPingReplyBuild2
(
&
pSyncNode
->
myRaftId
,
&
pSyncNode
->
myRaftId
,
1000
,
"syncEnqTest"
);
SyncPingReply
*
pSyncMsg
=
syncPingReplyBuild2
(
&
pSyncNode
->
myRaftId
,
&
pSyncNode
->
myRaftId
,
1000
,
"syncEnqTest"
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncPingReply2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
syncPingReply2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
pSyncNode
->
Fp
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
pSyncNode
->
sync
EqMsg
(
pSyncNode
->
msgcb
,
&
rpcMsg
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
d35028ae
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
@@ -103,7 +103,7 @@ int main(int argc, char** argv) {
...
@@ -103,7 +103,7 @@ int main(int argc, char** argv) {
SEpSet
epSet
;
SEpSet
epSet
;
syncUtilnodeInfo2EpSet
(
&
pSyncNode
->
myNodeInfo
,
&
epSet
);
syncUtilnodeInfo2EpSet
(
&
pSyncNode
->
myNodeInfo
,
&
epSet
);
rpcMsg
.
info
.
noResp
=
1
;
rpcMsg
.
info
.
noResp
=
1
;
pSyncNode
->
FpSendMs
g
(
&
epSet
,
&
rpcMsg
);
pSyncNode
->
syncSendMS
g
(
&
epSet
,
&
rpcMsg
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncInitTest.cpp
浏览文件 @
d35028ae
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./sync_init_test"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./sync_init_test"
);
...
...
source/libs/sync/test/syncPingSelfTest.cpp
浏览文件 @
d35028ae
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncPingTimerTest.cpp
浏览文件 @
d35028ae
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncPingTimerTest2.cpp
浏览文件 @
d35028ae
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
...
@@ -26,8 +26,8 @@ SSyncFSM* pFsm;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
d35028ae
...
@@ -100,8 +100,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
...
@@ -100,8 +100,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
createFsm
();
syncInfo
.
pFsm
=
createFsm
();
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
pWal
=
pWal
;
...
...
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
d35028ae
...
@@ -87,8 +87,8 @@ void initFsm() {
...
@@ -87,8 +87,8 @@ void initFsm() {
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
pDir
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
pDir
);
...
@@ -204,7 +204,7 @@ int main(int argc, char **argv) {
...
@@ -204,7 +204,7 @@ int main(int argc, char **argv) {
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
gSyncNode
->
Fp
EqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
gSyncNode
->
sync
EqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
d35028ae
...
@@ -217,8 +217,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
...
@@ -217,8 +217,8 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
vgId
=
vgId
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
createFsm
();
syncInfo
.
pFsm
=
createFsm
();
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s_sync_replica%d_index%d"
,
path
,
replicaNum
,
myIndex
);
syncInfo
.
pWal
=
pWal
;
syncInfo
.
pWal
=
pWal
;
...
...
source/libs/sync/test/syncVotesGrantedTest.cpp
浏览文件 @
d35028ae
...
@@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
...
@@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncVotesRespondTest.cpp
浏览文件 @
d35028ae
...
@@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
...
@@ -28,8 +28,8 @@ SSyncNode* pSyncNode;
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./"
);
...
...
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
d35028ae
...
@@ -65,8 +65,8 @@ void initFsm() {
...
@@ -65,8 +65,8 @@ void initFsm() {
SSyncNode
*
syncNodeInit
()
{
SSyncNode
*
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
vgId
=
1234
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
msgcb
=
&
gSyncIO
->
msgcb
;
syncInfo
.
FpSendMs
g
=
syncIOSendMsg
;
syncInfo
.
syncSendMS
g
=
syncIOSendMsg
;
syncInfo
.
Fp
EqMsg
=
syncIOEqMsg
;
syncInfo
.
sync
EqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
pDir
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
pDir
);
...
@@ -179,7 +179,7 @@ int main(int argc, char **argv) {
...
@@ -179,7 +179,7 @@ int main(int argc, char **argv) {
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
gSyncNode
->
Fp
EqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
gSyncNode
->
sync
EqMsg
(
gSyncNode
->
msgcb
,
&
rpcMsg
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录