Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6d3efd1b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
6d3efd1b
编写于
11月 12, 2021
作者:
L
lichuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-10645][raft]<feature>refactor sync typedef
上级
5a4f137b
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
49 addition
and
48 deletion
+49
-48
source/libs/sync/inc/raft.h
source/libs/sync/inc/raft.h
+2
-1
source/libs/sync/inc/raft_log.h
source/libs/sync/inc/raft_log.h
+3
-3
source/libs/sync/inc/raft_message.h
source/libs/sync/inc/raft_message.h
+8
-8
source/libs/sync/inc/sync_raft_impl.h
source/libs/sync/inc/sync_raft_impl.h
+2
-2
source/libs/sync/inc/sync_raft_progress.h
source/libs/sync/inc/sync_raft_progress.h
+6
-6
source/libs/sync/inc/sync_raft_progress_tracker.h
source/libs/sync/inc/sync_raft_progress_tracker.h
+3
-3
source/libs/sync/inc/sync_raft_quorum.h
source/libs/sync/inc/sync_raft_quorum.h
+3
-3
source/libs/sync/inc/sync_raft_quorum_joint.h
source/libs/sync/inc/sync_raft_quorum_joint.h
+1
-1
source/libs/sync/inc/sync_raft_quorum_majority.h
source/libs/sync/inc/sync_raft_quorum_majority.h
+1
-1
source/libs/sync/inc/sync_type.h
source/libs/sync/inc/sync_type.h
+2
-2
source/libs/sync/src/raft.c
source/libs/sync/src/raft.c
+2
-2
source/libs/sync/src/raft_election.c
source/libs/sync/src/raft_election.c
+3
-3
source/libs/sync/src/raft_handle_vote_resp_message.c
source/libs/sync/src/raft_handle_vote_resp_message.c
+1
-1
source/libs/sync/src/sync_raft_impl.c
source/libs/sync/src/sync_raft_impl.c
+2
-2
source/libs/sync/src/sync_raft_progress.c
source/libs/sync/src/sync_raft_progress.c
+4
-4
source/libs/sync/src/sync_raft_progress_tracker.c
source/libs/sync/src/sync_raft_progress_tracker.c
+2
-2
source/libs/sync/src/sync_raft_quorum_joint.c
source/libs/sync/src/sync_raft_quorum_joint.c
+3
-3
source/libs/sync/src/sync_raft_quorum_majority.c
source/libs/sync/src/sync_raft_quorum_majority.c
+1
-1
未找到文件。
source/libs/sync/inc/raft.h
浏览文件 @
6d3efd1b
...
...
@@ -65,7 +65,8 @@ struct SSyncRaft {
SSyncRaftLog
*
log
;
int
maxMsgSize
;
uint64_t
maxMsgSize
;
uint64_t
maxUncommittedSize
;
SSyncRaftProgressTracker
*
tracker
;
ESyncState
state
;
...
...
source/libs/sync/inc/raft_log.h
浏览文件 @
6d3efd1b
...
...
@@ -19,16 +19,16 @@
#include "sync.h"
#include "sync_type.h"
typedef
enum
Sync
EntryType
{
typedef
enum
ESyncRaft
EntryType
{
SYNC_ENTRY_TYPE_LOG
=
1
,
}
Sync
EntryType
;
}
ESyncRaft
EntryType
;
struct
SSyncRaftEntry
{
SyncTerm
term
;
SyncIndex
index
;
Sync
EntryType
type
;
ESyncRaft
EntryType
type
;
SSyncBuffer
buffer
;
};
...
...
source/libs/sync/inc/raft_message.h
浏览文件 @
6d3efd1b
...
...
@@ -28,7 +28,7 @@
* outter message start with RAFT_MSG_*, which communicate between cluster peers,
* need to implement its decode/encode functions.
**/
typedef
enum
RaftMessageType
{
typedef
enum
ESync
RaftMessageType
{
// client propose a cmd
RAFT_MSG_INTERNAL_PROP
=
1
,
...
...
@@ -40,7 +40,7 @@ typedef enum RaftMessageType {
RAFT_MSG_APPEND
=
5
,
RAFT_MSG_APPEND_RESP
=
6
,
}
RaftMessageType
;
}
ESync
RaftMessageType
;
typedef
struct
RaftMsgInternal_Prop
{
const
SSyncBuffer
*
pBuf
;
...
...
@@ -53,14 +53,14 @@ typedef struct RaftMsgInternal_Election {
}
RaftMsgInternal_Election
;
typedef
struct
RaftMsg_Vote
{
SyncRaftElectionType
cType
;
E
SyncRaftElectionType
cType
;
SyncIndex
lastIndex
;
SyncTerm
lastTerm
;
}
RaftMsg_Vote
;
typedef
struct
RaftMsg_VoteResp
{
bool
rejected
;
SyncRaftElectionType
cType
;
E
SyncRaftElectionType
cType
;
}
RaftMsg_VoteResp
;
typedef
struct
RaftMsg_Append_Entries
{
...
...
@@ -85,7 +85,7 @@ typedef struct RaftMsg_Append_Resp {
}
RaftMsg_Append_Resp
;
typedef
struct
SSyncMessage
{
RaftMessageType
msgType
;
ESync
RaftMessageType
msgType
;
SyncTerm
term
;
SyncGroupId
groupId
;
SyncNodeId
from
;
...
...
@@ -131,7 +131,7 @@ static FORCE_INLINE SSyncMessage* syncInitElectionMsg(SSyncMessage* pMsg, SyncNo
}
static
FORCE_INLINE
SSyncMessage
*
syncNewVoteMsg
(
SyncGroupId
groupId
,
SyncNodeId
from
,
SyncTerm
term
,
SyncRaftElectionType
cType
,
SyncTerm
term
,
E
SyncRaftElectionType
cType
,
SyncIndex
lastIndex
,
SyncTerm
lastTerm
)
{
SSyncMessage
*
pMsg
=
(
SSyncMessage
*
)
malloc
(
sizeof
(
SSyncMessage
));
if
(
pMsg
==
NULL
)
{
...
...
@@ -153,7 +153,7 @@ static FORCE_INLINE SSyncMessage* syncNewVoteMsg(SyncGroupId groupId, SyncNodeId
}
static
FORCE_INLINE
SSyncMessage
*
syncNewVoteRespMsg
(
SyncGroupId
groupId
,
SyncNodeId
from
,
SyncRaftElectionType
cType
,
bool
rejected
)
{
E
SyncRaftElectionType
cType
,
bool
rejected
)
{
SSyncMessage
*
pMsg
=
(
SSyncMessage
*
)
malloc
(
sizeof
(
SSyncMessage
));
if
(
pMsg
==
NULL
)
{
return
NULL
;
...
...
@@ -213,7 +213,7 @@ static FORCE_INLINE SSyncMessage* syncNewEmptyAppendRespMsg(SyncGroupId groupId,
return
pMsg
;
}
static
FORCE_INLINE
bool
syncIsInternalMsg
(
RaftMessageType
msgType
)
{
static
FORCE_INLINE
bool
syncIsInternalMsg
(
ESync
RaftMessageType
msgType
)
{
return
msgType
==
RAFT_MSG_INTERNAL_PROP
||
msgType
==
RAFT_MSG_INTERNAL_ELECTION
;
}
...
...
source/libs/sync/inc/sync_raft_impl.h
浏览文件 @
6d3efd1b
...
...
@@ -26,7 +26,7 @@ void syncRaftBecomePreCandidate(SSyncRaft* pRaft);
void
syncRaftBecomeCandidate
(
SSyncRaft
*
pRaft
);
void
syncRaftBecomeLeader
(
SSyncRaft
*
pRaft
);
void
syncRaftStartElection
(
SSyncRaft
*
pRaft
,
SyncRaftElectionType
cType
);
void
syncRaftStartElection
(
SSyncRaft
*
pRaft
,
E
SyncRaftElectionType
cType
);
void
syncRaftTriggerHeartbeat
(
SSyncRaft
*
pRaft
);
...
...
@@ -35,7 +35,7 @@ bool syncRaftIsPromotable(SSyncRaft* pRaft);
bool
syncRaftIsPastElectionTimeout
(
SSyncRaft
*
pRaft
);
int
syncRaftQuorum
(
SSyncRaft
*
pRaft
);
S
SyncRaftVoteResult
syncRaftPollVote
(
SSyncRaft
*
pRaft
,
SyncNodeId
id
,
E
SyncRaftVoteResult
syncRaftPollVote
(
SSyncRaft
*
pRaft
,
SyncNodeId
id
,
bool
preVote
,
bool
accept
,
int
*
rejectNum
,
int
*
granted
);
...
...
source/libs/sync/inc/sync_raft_progress.h
浏览文件 @
6d3efd1b
...
...
@@ -34,7 +34,7 @@
*
* PROGRESS_STATE_PROBE is the initial state.
**/
typedef
enum
RaftProgressState
{
typedef
enum
ESync
RaftProgressState
{
/**
* StateProbe indicates a follower whose last index isn't known. Such a
* follower is "probed" (i.e. an append sent periodically) to narrow down
...
...
@@ -56,7 +56,7 @@ typedef enum RaftProgressState {
* return to StateReplicate.
**/
PROGRESS_STATE_SNAPSHOT
,
}
RaftProgressState
;
}
ESync
RaftProgressState
;
/**
* Progress represents a follower’s progress in the view of the leader. Leader maintains
...
...
@@ -82,7 +82,7 @@ struct SSyncRaftProgress {
* When in StateSnapshot, leader should have sent out snapshot
* before and stops sending any replication message.
**/
RaftProgressState
state
;
ESync
RaftProgressState
state
;
/**
* pendingSnapshotIndex is used in PROGRESS_STATE_SNAPSHOT.
...
...
@@ -187,15 +187,15 @@ static FORCE_INLINE SyncIndex syncRaftProgressNextIndex(SSyncRaftProgress* progr
return
progress
->
nextIndex
;
}
static
FORCE_INLINE
RaftProgressState
syncRaftProgressInReplicate
(
SSyncRaftProgress
*
progress
)
{
static
FORCE_INLINE
ESync
RaftProgressState
syncRaftProgressInReplicate
(
SSyncRaftProgress
*
progress
)
{
return
progress
->
state
==
PROGRESS_STATE_REPLICATE
;
}
static
FORCE_INLINE
RaftProgressState
syncRaftProgressInSnapshot
(
SSyncRaftProgress
*
progress
)
{
static
FORCE_INLINE
ESync
RaftProgressState
syncRaftProgressInSnapshot
(
SSyncRaftProgress
*
progress
)
{
return
progress
->
state
==
PROGRESS_STATE_SNAPSHOT
;
}
static
FORCE_INLINE
RaftProgressState
syncRaftProgressInProbe
(
SSyncRaftProgress
*
progress
)
{
static
FORCE_INLINE
ESync
RaftProgressState
syncRaftProgressInProbe
(
SSyncRaftProgress
*
progress
)
{
return
progress
->
state
==
PROGRESS_STATE_PROBE
;
}
...
...
source/libs/sync/inc/sync_raft_progress_tracker.h
浏览文件 @
6d3efd1b
...
...
@@ -87,8 +87,8 @@ struct SSyncRaftProgressTracker {
SSyncRaftProgress
progressMap
[
TSDB_MAX_REPLICA
];
SyncRaftVoteResult
votes
[
TSDB_MAX_REPLICA
];
int
maxInflight
;
E
SyncRaftVoteResult
votes
[
TSDB_MAX_REPLICA
];
int
maxInflight
Msgs
;
};
SSyncRaftProgressTracker
*
syncRaftOpenProgressTracker
();
...
...
@@ -108,6 +108,6 @@ void syncRaftRecordVote(SSyncRaftProgressTracker* tracker, int i, bool grant);
* syncRaftTallyVotes returns the number of granted and rejected Votes, and whether the
* election outcome is known.
**/
SyncRaftVoteResult
syncRaftTallyVotes
(
SSyncRaftProgressTracker
*
tracker
,
int
*
rejected
,
int
*
granted
);
E
SyncRaftVoteResult
syncRaftTallyVotes
(
SSyncRaftProgressTracker
*
tracker
,
int
*
rejected
,
int
*
granted
);
#endif
/* _TD_LIBS_SYNC_RAFT_PROGRESS_TRACKER_H */
source/libs/sync/inc/sync_raft_quorum.h
浏览文件 @
6d3efd1b
...
...
@@ -17,11 +17,11 @@
#define TD_SYNC_RAFT_QUORUM_H
/**
*
S
SyncRaftVoteResult indicates the outcome of a vote.
*
E
SyncRaftVoteResult indicates the outcome of a vote.
**/
typedef
enum
{
/**
*
SYNC_RAFT_VOTE_PENDING indicates that the decision of the vote depends on future
* SYNC_RAFT_VOTE_PENDING indicates that the decision of the vote depends on future
* votes, i.e. neither "yes" or "no" has reached quorum yet.
**/
SYNC_RAFT_VOTE_PENDING
=
1
,
...
...
@@ -35,6 +35,6 @@ typedef enum {
* SYNC_RAFT_VOTE_WON indicates that the quorum has voted "yes".
**/
SYNC_RAFT_VOTE_WON
=
3
,
}
S
SyncRaftVoteResult
;
}
E
SyncRaftVoteResult
;
#endif
/* TD_SYNC_RAFT_QUORUM_H */
\ No newline at end of file
source/libs/sync/inc/sync_raft_quorum_joint.h
浏览文件 @
6d3efd1b
...
...
@@ -33,6 +33,6 @@ typedef struct SSyncRaftQuorumJointConfig {
* a result indicating whether the vote is pending, lost, or won. A joint quorum
* requires both majority quorums to vote in favor.
**/
SyncRaftVoteResult
syncRaftVoteResult
(
SSyncRaftQuorumJointConfig
*
config
,
const
SyncRaftVoteResult
*
votes
);
ESyncRaftVoteResult
syncRaftVoteResult
(
SSyncRaftQuorumJointConfig
*
config
,
const
E
SyncRaftVoteResult
*
votes
);
#endif
/* _TD_LIBS_SYNC_RAFT_QUORUM_JOINT_H */
source/libs/sync/inc/sync_raft_quorum_majority.h
浏览文件 @
6d3efd1b
...
...
@@ -25,6 +25,6 @@
* yes/no has been reached), won (a quorum of yes has been reached), or lost (a
* quorum of no has been reached).
**/
SyncRaftVoteResult
syncRaftMajorityVoteResult
(
SSyncCluster
*
config
,
const
SyncRaftVoteResult
*
votes
);
ESyncRaftVoteResult
syncRaftMajorityVoteResult
(
SSyncCluster
*
config
,
const
E
SyncRaftVoteResult
*
votes
);
#endif
/* _TD_LIBS_SYNC_RAFT_QUORUM_MAJORITY_H */
source/libs/sync/inc/sync_type.h
浏览文件 @
6d3efd1b
...
...
@@ -50,7 +50,7 @@ typedef enum {
SYNC_RAFT_CAMPAIGN_PRE_ELECTION
=
0
,
SYNC_RAFT_CAMPAIGN_ELECTION
=
1
,
SYNC_RAFT_CAMPAIGN_TRANSFER
=
2
,
}
SyncRaftElectionType
;
}
E
SyncRaftElectionType
;
typedef
enum
{
// the init vote resp status
...
...
@@ -61,6 +61,6 @@ typedef enum {
//reject the vote request
SYNC_RAFT_VOTE_RESP_REJECT
=
2
,
}
SyncRaftVoteResult
;
}
E
SyncRaftVoteResult
;
#endif
/* _TD_LIBS_SYNC_TYPE_H */
source/libs/sync/src/raft.c
浏览文件 @
6d3efd1b
...
...
@@ -101,7 +101,7 @@ int32_t syncRaftStep(SSyncRaft* pRaft, const SSyncMessage* pMsg) {
return
0
;
}
RaftMessageType
msgType
=
pMsg
->
msgType
;
ESync
RaftMessageType
msgType
=
pMsg
->
msgType
;
if
(
msgType
==
RAFT_MSG_INTERNAL_ELECTION
)
{
syncRaftHandleElectionMessage
(
pRaft
,
pMsg
);
}
else
if
(
msgType
==
RAFT_MSG_VOTE
)
{
...
...
@@ -140,7 +140,7 @@ static bool preHandleMessage(SSyncRaft* pRaft, const SSyncMessage* pMsg) {
static
bool
preHandleNewTermMessage
(
SSyncRaft
*
pRaft
,
const
SSyncMessage
*
pMsg
)
{
SyncNodeId
leaderId
=
pMsg
->
from
;
RaftMessageType
msgType
=
pMsg
->
msgType
;
ESync
RaftMessageType
msgType
=
pMsg
->
msgType
;
if
(
msgType
==
RAFT_MSG_VOTE
)
{
// TODO
...
...
source/libs/sync/src/raft_election.c
浏览文件 @
6d3efd1b
...
...
@@ -18,10 +18,10 @@
#include "raft_log.h"
#include "raft_message.h"
void
syncRaftStartElection
(
SSyncRaft
*
pRaft
,
SyncRaftElectionType
cType
)
{
void
syncRaftStartElection
(
SSyncRaft
*
pRaft
,
E
SyncRaftElectionType
cType
)
{
SyncTerm
term
;
bool
preVote
;
RaftMessageType
voteMsgType
;
ESync
RaftMessageType
voteMsgType
;
if
(
syncRaftIsPromotable
(
pRaft
))
{
syncDebug
(
"[%d:%d] is unpromotable; campaign() should have been called"
,
pRaft
->
selfGroupId
,
pRaft
->
selfId
);
...
...
@@ -41,7 +41,7 @@ void syncRaftStartElection(SSyncRaft* pRaft, SyncRaftElectionType cType) {
}
int
quorum
=
syncRaftQuorum
(
pRaft
);
S
SyncRaftVoteResult
result
=
syncRaftPollVote
(
pRaft
,
pRaft
->
selfId
,
preVote
,
true
,
NULL
,
NULL
);
E
SyncRaftVoteResult
result
=
syncRaftPollVote
(
pRaft
,
pRaft
->
selfId
,
preVote
,
true
,
NULL
,
NULL
);
if
(
result
==
SYNC_RAFT_VOTE_WON
)
{
/**
* We won the election after voting for ourselves (which must mean that
...
...
source/libs/sync/src/raft_handle_vote_resp_message.c
浏览文件 @
6d3efd1b
...
...
@@ -36,7 +36,7 @@ int syncRaftHandleVoteRespMessage(SSyncRaft* pRaft, const SSyncMessage* pMsg) {
return
0
;
}
S
SyncRaftVoteResult
result
=
syncRaftPollVote
(
pRaft
,
pMsg
->
from
,
E
SyncRaftVoteResult
result
=
syncRaftPollVote
(
pRaft
,
pMsg
->
from
,
pMsg
->
voteResp
.
cType
==
SYNC_RAFT_CAMPAIGN_PRE_ELECTION
,
!
pMsg
->
voteResp
.
rejected
,
&
rejected
,
&
granted
);
...
...
source/libs/sync/src/sync_raft_impl.c
浏览文件 @
6d3efd1b
...
...
@@ -127,7 +127,7 @@ int syncRaftQuorum(SSyncRaft* pRaft) {
return
pRaft
->
cluster
.
replica
/
2
+
1
;
}
S
SyncRaftVoteResult
syncRaftPollVote
(
SSyncRaft
*
pRaft
,
SyncNodeId
id
,
E
SyncRaftVoteResult
syncRaftPollVote
(
SSyncRaft
*
pRaft
,
SyncNodeId
id
,
bool
preVote
,
bool
grant
,
int
*
rejected
,
int
*
granted
)
{
int
voterIndex
=
syncRaftConfigurationIndexOfNode
(
pRaft
,
id
);
...
...
@@ -186,7 +186,7 @@ static int stepCandidate(SSyncRaft* pRaft, const SSyncMessage* pMsg) {
* StateCandidate, we may get stale MsgPreVoteResp messages in this term from
* our pre-candidate state).
**/
RaftMessageType
msgType
=
pMsg
->
msgType
;
ESync
RaftMessageType
msgType
=
pMsg
->
msgType
;
if
(
msgType
==
RAFT_MSG_INTERNAL_PROP
)
{
return
0
;
...
...
source/libs/sync/src/sync_raft_progress.c
浏览文件 @
6d3efd1b
...
...
@@ -20,13 +20,13 @@
#include "sync.h"
#include "syncInt.h"
static
void
resetProgressState
(
SSyncRaftProgress
*
progress
,
RaftProgressState
state
);
static
void
resetProgressState
(
SSyncRaftProgress
*
progress
,
ESync
RaftProgressState
state
);
static
void
probeAcked
(
SSyncRaftProgress
*
progress
);
static
void
resumeProgress
(
SSyncRaftProgress
*
progress
);
void
syncRaftInitProgress
(
int
i
,
SSyncRaft
*
pRaft
,
SSyncRaftProgress
*
progress
)
{
SSyncRaftInflights
*
inflights
=
syncRaftOpenInflights
(
pRaft
->
tracker
->
maxInflight
);
SSyncRaftInflights
*
inflights
=
syncRaftOpenInflights
(
pRaft
->
tracker
->
maxInflight
Msgs
);
if
(
inflights
==
NULL
)
{
return
;
}
...
...
@@ -153,7 +153,7 @@ void syncRaftProgressBecomeSnapshot(SSyncRaftProgress* progress, SyncIndex snaps
* ResetState moves the Progress into the specified State, resetting ProbeSent,
* PendingSnapshot, and Inflights.
**/
static
void
resetProgressState
(
SSyncRaftProgress
*
progress
,
RaftProgressState
state
)
{
static
void
resetProgressState
(
SSyncRaftProgress
*
progress
,
ESync
RaftProgressState
state
)
{
progress
->
probeSent
=
false
;
progress
->
pendingSnapshotIndex
=
0
;
progress
->
state
=
state
;
...
...
@@ -233,7 +233,7 @@ void syncRaftProgressAbortSnapshot(SSyncRaft* pRaft, int i) {
progress->state = PROGRESS_STATE_PROBE;
}
RaftProgressState syncRaftProgressState(SSyncRaft* pRaft, int i) {
ESync
RaftProgressState syncRaftProgressState(SSyncRaft* pRaft, int i) {
return pRaft->leaderState.progress[i].state;
}
...
...
source/libs/sync/src/sync_raft_progress_tracker.c
浏览文件 @
6d3efd1b
...
...
@@ -25,7 +25,7 @@ SSyncRaftProgressTracker* syncRaftOpenProgressTracker() {
}
void
syncRaftResetVotes
(
SSyncRaftProgressTracker
*
tracker
)
{
memset
(
tracker
->
votes
,
SYNC_RAFT_VOTE_RESP_UNKNOWN
,
sizeof
(
SyncRaftVoteResult
)
*
TSDB_MAX_REPLICA
);
memset
(
tracker
->
votes
,
SYNC_RAFT_VOTE_RESP_UNKNOWN
,
sizeof
(
E
SyncRaftVoteResult
)
*
TSDB_MAX_REPLICA
);
}
void
syncRaftProgressVisit
(
SSyncRaftProgressTracker
*
tracker
,
visitProgressFp
visit
,
void
*
arg
)
{
...
...
@@ -48,7 +48,7 @@ void syncRaftRecordVote(SSyncRaftProgressTracker* tracker, int i, bool grant) {
* syncRaftTallyVotes returns the number of granted and rejected Votes, and whether the
* election outcome is known.
**/
SyncRaftVoteResult
syncRaftTallyVotes
(
SSyncRaftProgressTracker
*
tracker
,
int
*
rejected
,
int
*
granted
)
{
E
SyncRaftVoteResult
syncRaftTallyVotes
(
SSyncRaftProgressTracker
*
tracker
,
int
*
rejected
,
int
*
granted
)
{
int
i
;
SSyncRaftProgress
*
progress
;
int
r
,
g
;
...
...
source/libs/sync/src/sync_raft_quorum_joint.c
浏览文件 @
6d3efd1b
...
...
@@ -22,9 +22,9 @@
* a result indicating whether the vote is pending, lost, or won. A joint quorum
* requires both majority quorums to vote in favor.
**/
SyncRaftVoteResult
syncRaftVoteResult
(
SSyncRaftQuorumJointConfig
*
config
,
const
SyncRaftVoteResult
*
votes
)
{
SyncRaftVoteResult
r1
=
syncRaftMajorityVoteResult
(
&
(
config
->
majorityConfig
[
0
]),
votes
);
SyncRaftVoteResult
r2
=
syncRaftMajorityVoteResult
(
&
(
config
->
majorityConfig
[
1
]),
votes
);
ESyncRaftVoteResult
syncRaftVoteResult
(
SSyncRaftQuorumJointConfig
*
config
,
const
E
SyncRaftVoteResult
*
votes
)
{
E
SyncRaftVoteResult
r1
=
syncRaftMajorityVoteResult
(
&
(
config
->
majorityConfig
[
0
]),
votes
);
E
SyncRaftVoteResult
r2
=
syncRaftMajorityVoteResult
(
&
(
config
->
majorityConfig
[
1
]),
votes
);
if
(
r1
==
r2
)
{
// If they agree, return the agreed state.
...
...
source/libs/sync/src/sync_raft_quorum_majority.c
浏览文件 @
6d3efd1b
...
...
@@ -22,7 +22,7 @@
* yes/no has been reached), won (a quorum of yes has been reached), or lost (a
* quorum of no has been reached).
**/
SyncRaftVoteResult
syncRaftMajorityVoteResult
(
SSyncCluster
*
config
,
const
SyncRaftVoteResult
*
votes
)
{
ESyncRaftVoteResult
syncRaftMajorityVoteResult
(
SSyncCluster
*
config
,
const
E
SyncRaftVoteResult
*
votes
)
{
if
(
config
->
replica
==
0
)
{
return
SYNC_RAFT_VOTE_WON
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录