Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
25af19bd
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看板
提交
25af19bd
编写于
3月 07, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync refactor
上级
a0319ae4
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
131 addition
and
109 deletion
+131
-109
source/libs/sync/inc/syncAppendEntries.h
source/libs/sync/inc/syncAppendEntries.h
+2
-0
source/libs/sync/inc/syncAppendEntriesReply.h
source/libs/sync/inc/syncAppendEntriesReply.h
+2
-0
source/libs/sync/inc/syncElection.h
source/libs/sync/inc/syncElection.h
+5
-1
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+7
-14
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+3
-1
source/libs/sync/inc/syncRequestVote.h
source/libs/sync/inc/syncRequestVote.h
+2
-0
source/libs/sync/inc/syncRequestVoteReply.h
source/libs/sync/inc/syncRequestVoteReply.h
+2
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+0
-27
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+25
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+46
-50
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+36
-1
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+0
-14
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+1
-0
未找到文件。
source/libs/sync/inc/syncAppendEntries.h
浏览文件 @
25af19bd
...
@@ -28,6 +28,8 @@ extern "C" {
...
@@ -28,6 +28,8 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/inc/syncAppendEntriesReply.h
浏览文件 @
25af19bd
...
@@ -28,6 +28,8 @@ extern "C" {
...
@@ -28,6 +28,8 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/inc/syncElection.h
浏览文件 @
25af19bd
...
@@ -26,7 +26,11 @@ extern "C" {
...
@@ -26,7 +26,11 @@ extern "C" {
#include "syncInt.h"
#include "syncInt.h"
#include "taosdef.h"
#include "taosdef.h"
void
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
25af19bd
...
@@ -188,29 +188,22 @@ typedef struct SSyncNode {
...
@@ -188,29 +188,22 @@ typedef struct SSyncNode {
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
);
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
);
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopElectTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRestartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeRestartElectTimer
(
SSyncNode
*
pSyncNode
,
int32_t
ms
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopHeartbeatTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVote
(
SSyncNode
*
ths
,
const
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
syncNodeOnRequestVoteReplyCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
syncNodeAppendEntries
(
SSyncNode
*
ths
,
const
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/inc/syncReplication.h
浏览文件 @
25af19bd
...
@@ -26,7 +26,9 @@ extern "C" {
...
@@ -26,7 +26,9 @@ extern "C" {
#include "syncInt.h"
#include "syncInt.h"
#include "taosdef.h"
#include "taosdef.h"
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntries
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncRequestVote.h
浏览文件 @
25af19bd
...
@@ -28,6 +28,8 @@ extern "C" {
...
@@ -28,6 +28,8 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/inc/syncRequestVoteReply.h
浏览文件 @
25af19bd
...
@@ -28,6 +28,8 @@ extern "C" {
...
@@ -28,6 +28,8 @@ extern "C" {
#include "syncRaft.h"
#include "syncRaft.h"
#include "taosdef.h"
#include "taosdef.h"
int32_t
syncNodeOnRequestVoteReplyCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
25af19bd
...
@@ -15,33 +15,6 @@
...
@@ -15,33 +15,6 @@
#include "syncAppendEntries.h"
#include "syncAppendEntries.h"
int32_t
syncNodeAppendEntries
(
SSyncNode
*
ths
,
const
SyncAppendEntries
*
pMsg
)
{
// TLA+ Spec
// AppendEntries(i, j) ==
// /\ i /= j
// /\ state[i] = Leader
// /\ LET prevLogIndex == nextIndex[i][j] - 1
// prevLogTerm == IF prevLogIndex > 0 THEN
// log[i][prevLogIndex].term
// ELSE
// 0
// \* Send up to 1 entry, constrained by the end of the log.
// lastEntry == Min({Len(log[i]), nextIndex[i][j]})
// entries == SubSeq(log[i], nextIndex[i][j], lastEntry)
// IN Send([mtype |-> AppendEntriesRequest,
// mterm |-> currentTerm[i],
// mprevLogIndex |-> prevLogIndex,
// mprevLogTerm |-> prevLogTerm,
// mentries |-> entries,
// \* mlog is used as a history variable for the proof.
// \* It would not exist in a real implementation.
// mlog |-> log[i],
// mcommitIndex |-> Min({commitIndex[i], lastEntry}),
// msource |-> i,
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
}
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
)
{
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
)
{
// TLA+ Spec
// TLA+ Spec
// HandleAppendEntriesRequest(i, j, m) ==
// HandleAppendEntriesRequest(i, j, m) ==
...
...
source/libs/sync/src/syncElection.c
浏览文件 @
25af19bd
...
@@ -14,8 +14,32 @@
...
@@ -14,8 +14,32 @@
*/
*/
#include "syncElection.h"
#include "syncElection.h"
#include "syncMessage.h"
void
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{
// start election
// start election
syncNodeRequestVotePeers
(
pSyncNode
);
syncNodeRequestVotePeers
(
pSyncNode
);
}
}
// TLA+ Spec
// RequestVote(i, j) ==
// /\ state[i] = Candidate
// /\ j \notin votesResponded[i]
// /\ Send([mtype |-> RequestVoteRequest,
// mterm |-> currentTerm[i],
// mlastLogTerm |-> LastTerm(log[i]),
// mlastLogIndex |-> Len(log[i]),
// msource |-> i,
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{}
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
)
{
sTrace
(
"syncNodeRequestVote pSyncNode:%p "
,
pSyncNode
);
int32_t
ret
=
0
;
SRpcMsg
rpcMsg
;
syncRequestVote2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
return
ret
;
}
\ No newline at end of file
source/libs/sync/src/syncMain.c
浏览文件 @
25af19bd
...
@@ -15,23 +15,23 @@
...
@@ -15,23 +15,23 @@
#include <stdint.h>
#include <stdint.h>
#include "sync.h"
#include "sync.h"
#include "syncAppendEntries.h"
#include "syncAppendEntriesReply.h"
#include "syncEnv.h"
#include "syncEnv.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaft.h"
#include "syncRaft.h"
#include "syncRequestVote.h"
#include "syncRequestVoteReply.h"
#include "syncTimeout.h"
#include "syncTimeout.h"
#include "syncUtil.h"
#include "syncUtil.h"
static
int32_t
tsNodeRefId
=
-
1
;
static
int32_t
tsNodeRefId
=
-
1
;
// ------ local funciton ---------
// ------ local funciton ---------
static
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
static
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
);
static
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
);
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
static
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
...
@@ -135,6 +135,48 @@ void syncNodeClose(SSyncNode* pSyncNode) {
...
@@ -135,6 +135,48 @@ void syncNodeClose(SSyncNode* pSyncNode) {
free
(
pSyncNode
);
free
(
pSyncNode
);
}
}
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
syncUtilraftId2EpSet
(
destRaftId
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
syncUtilnodeInfo2EpSet
(
nodeInfo
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
)
{
sTrace
(
"syncNodePing pSyncNode:%p "
,
pSyncNode
);
int32_t
ret
=
0
;
SRpcMsg
rpcMsg
;
syncPing2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"syncNodePing pMsg:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
{
SyncPing
*
pMsg2
=
rpcMsg
.
pCont
;
cJSON
*
pJson
=
syncPing2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"syncNodePing rpcMsg.pCont:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
return
ret
;
}
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
)
{
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
)
{
sTrace
(
"syncNodePingAll pSyncNode:%p "
,
pSyncNode
);
sTrace
(
"syncNodePingAll pSyncNode:%p "
,
pSyncNode
);
int32_t
ret
=
0
;
int32_t
ret
=
0
;
...
@@ -168,10 +210,6 @@ void syncNodePingSelf(SSyncNode* pSyncNode) {
...
@@ -168,10 +210,6 @@ void syncNodePingSelf(SSyncNode* pSyncNode) {
syncPingDestroy
(
pMsg
);
syncPingDestroy
(
pMsg
);
}
}
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{}
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
)
{
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
)
{
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClock
,
pSyncNode
->
pingTimerLogicClockUser
);
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClock
,
pSyncNode
->
pingTimerLogicClockUser
);
pSyncNode
->
pingTimerMS
=
PING_TIMER_MS
;
pSyncNode
->
pingTimerMS
=
PING_TIMER_MS
;
...
@@ -235,48 +273,6 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
...
@@ -235,48 +273,6 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
}
}
// ------ local funciton ---------
// ------ local funciton ---------
static
int32_t
syncNodePing
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
SyncPing
*
pMsg
)
{
sTrace
(
"syncNodePing pSyncNode:%p "
,
pSyncNode
);
int32_t
ret
=
0
;
SRpcMsg
rpcMsg
;
syncPing2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
{
cJSON
*
pJson
=
syncPing2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"syncNodePing pMsg:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
{
SyncPing
*
pMsg2
=
rpcMsg
.
pCont
;
cJSON
*
pJson
=
syncPing2Json
(
pMsg2
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"syncNodePing rpcMsg.pCont:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
return
ret
;
}
static
int32_t
syncNodeSendMsgById
(
const
SRaftId
*
destRaftId
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
syncUtilraftId2EpSet
(
destRaftId
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
static
int32_t
syncNodeSendMsgByInfo
(
const
SNodeInfo
*
nodeInfo
,
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
syncUtilnodeInfo2EpSet
(
nodeInfo
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
sTrace
(
"<-- syncNodeOnPingCb -->"
);
sTrace
(
"<-- syncNodeOnPingCb -->"
);
...
...
source/libs/sync/src/syncReplication.c
浏览文件 @
25af19bd
...
@@ -14,5 +14,40 @@
...
@@ -14,5 +14,40 @@
*/
*/
#include "syncReplication.h"
#include "syncReplication.h"
#include "syncMessage.h"
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{}
// TLA+ Spec
\ No newline at end of file
// AppendEntries(i, j) ==
// /\ i /= j
// /\ state[i] = Leader
// /\ LET prevLogIndex == nextIndex[i][j] - 1
// prevLogTerm == IF prevLogIndex > 0 THEN
// log[i][prevLogIndex].term
// ELSE
// 0
// \* Send up to 1 entry, constrained by the end of the log.
// lastEntry == Min({Len(log[i]), nextIndex[i][j]})
// entries == SubSeq(log[i], nextIndex[i][j], lastEntry)
// IN Send([mtype |-> AppendEntriesRequest,
// mterm |-> currentTerm[i],
// mprevLogIndex |-> prevLogIndex,
// mprevLogTerm |-> prevLogTerm,
// mentries |-> entries,
// \* mlog is used as a history variable for the proof.
// \* It would not exist in a real implementation.
// mlog |-> log[i],
// mcommitIndex |-> Min({commitIndex[i], lastEntry}),
// msource |-> i,
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
int32_t
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{}
int32_t
syncNodeAppendEntries
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncAppendEntries
*
pMsg
)
{
sTrace
(
"syncNodeAppendEntries pSyncNode:%p "
,
pSyncNode
);
int32_t
ret
=
0
;
SRpcMsg
rpcMsg
;
syncAppendEntries2RpcMsg
(
pMsg
,
&
rpcMsg
);
syncNodeSendMsgById
(
destRaftId
,
pSyncNode
,
&
rpcMsg
);
return
ret
;
}
\ No newline at end of file
source/libs/sync/src/syncRequestVote.c
浏览文件 @
25af19bd
...
@@ -15,20 +15,6 @@
...
@@ -15,20 +15,6 @@
#include "syncRequestVote.h"
#include "syncRequestVote.h"
int32_t
syncNodeRequestVote
(
SSyncNode
*
ths
,
const
SyncRequestVote
*
pMsg
)
{
// TLA+ Spec
// RequestVote(i, j) ==
// /\ state[i] = Candidate
// /\ j \notin votesResponded[i]
// /\ Send([mtype |-> RequestVoteRequest,
// mterm |-> currentTerm[i],
// mlastLogTerm |-> LastTerm(log[i]),
// mlastLogIndex |-> Len(log[i]),
// msource |-> i,
// mdest |-> j])
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
}
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
)
{
int32_t
syncNodeOnRequestVoteCb
(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
)
{
// TLA+ Spec
// TLA+ Spec
// HandleRequestVoteRequest(i, j, m) ==
// HandleRequestVoteRequest(i, j, m) ==
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
25af19bd
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include "syncTimeout.h"
#include "syncTimeout.h"
#include "syncElection.h"
#include "syncElection.h"
#include "syncReplication.h"
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录