Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
405e9e2c
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看板
未验证
提交
405e9e2c
编写于
3月 03, 2022
作者:
L
Li Minghao
提交者:
GitHub
3月 03, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10527 from taosdata/feature/3.0_mhli
Feature/3.0 mhli
上级
47f4edc3
64d224a0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
54 addition
and
30 deletion
+54
-30
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+46
-26
source/libs/sync/inc/syncVoteMgr.h
source/libs/sync/inc/syncVoteMgr.h
+6
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-1
未找到文件。
include/libs/sync/sync.h
浏览文件 @
405e9e2c
...
...
@@ -34,9 +34,7 @@ typedef enum {
TAOS_SYNC_STATE_FOLLOWER
=
0
,
TAOS_SYNC_STATE_CANDIDATE
=
1
,
TAOS_SYNC_STATE_LEADER
=
2
,
}
ESyncRole
;
typedef
ESyncRole
ESyncState
;
}
ESyncState
;
typedef
struct
SSyncBuffer
{
void
*
data
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
405e9e2c
...
...
@@ -25,6 +25,7 @@ extern "C" {
#include <stdlib.h>
#include "sync.h"
#include "taosdef.h"
#include "tglobal.h"
#include "tlog.h"
#include "ttimer.h"
...
...
@@ -91,31 +92,61 @@ typedef struct SyncAppendEntriesReply SyncAppendEntriesReply;
struct
SSyncEnv
;
typedef
struct
SSyncEnv
SSyncEnv
;
struct
SRaftStore
;
typedef
struct
SRaftStore
SRaftStore
;
struct
SVotesGranted
;
typedef
struct
SVotesGranted
SVotesGranted
;
struct
SVotesResponded
;
typedef
struct
SVotesResponded
SVotesResponded
;
typedef
struct
SRaftId
{
SyncNodeId
addr
;
// typedef uint64_t SyncNodeId;
SyncGroupId
vgId
;
// typedef int32_t SyncGroupId;
}
SRaftId
;
typedef
struct
SSyncNode
{
// init by SSyncInfo
SyncGroupId
vgId
;
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
SSyncFSM
*
pFsm
;
// passed from outside
void
*
rpcClient
;
void
*
rpcClient
;
int32_t
(
*
FpSendMsg
)(
void
*
rpcClient
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
int32_t
refCount
;
int64_t
rid
;
// init internal
SNodeInfo
me
;
SNodeInfo
peers
[
TSDB_MAX_REPLICA
];
int32_t
peersNum
;
SNodeInfo
peers
[
TSDB_MAX_REPLICA
];
ESyncRole
role
;
// raft algorithm
SSyncFSM
*
pFsm
;
SRaftId
raftId
;
SRaftId
peersId
[
TSDB_MAX_REPLICA
];
int32_t
replicaNum
;
int32_t
quorum
;
// life cycle
int32_t
refCount
;
int64_t
rid
;
// tla+ server vars
ESyncState
state
;
SRaftStore
*
pRaftStore
;
// tla+ candidate vars
SVotesGranted
*
pVotesGranted
;
SVotesResponded
*
pVotesResponded
;
// tla+ leader vars
SHashObj
*
pNextIndex
;
SHashObj
*
pMatchIndex
;
// tla+ log vars
SSyncLogStore
*
pLogStore
;
SyncIndex
commitIndex
;
// timer
tmr_h
pPingTimer
;
int32_t
pingTimerMS
;
uint8_t
pingTimerStart
;
...
...
@@ -136,32 +167,21 @@ typedef struct SSyncNode {
// callback
int32_t
(
*
FpOnPing
)(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
(
*
FpOnPingReply
)(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
int32_t
(
*
FpOnRequestVote
)(
SSyncNode
*
ths
,
SyncRequestVote
*
pMsg
);
int32_t
(
*
FpOnRequestVoteReply
)(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
(
*
FpOnAppendEntries
)(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnAppendEntriesReply
)(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
}
SSyncNode
;
SSyncNode
*
syncNodeOpen
(
const
SSyncInfo
*
pSyncInfo
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
void
syncNodeClose
(
SSyncNode
*
pSyncNode
);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncVoteMgr.h
浏览文件 @
405e9e2c
...
...
@@ -26,6 +26,12 @@ extern "C" {
#include "syncInt.h"
#include "taosdef.h"
typedef
struct
SVotesGranted
{
}
SVotesGranted
;
typedef
struct
SVotesResponded
{
}
SVotesResponded
;
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
405e9e2c
...
...
@@ -88,7 +88,7 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
}
}
pSyncNode
->
rol
e
=
TAOS_SYNC_STATE_FOLLOWER
;
pSyncNode
->
stat
e
=
TAOS_SYNC_STATE_FOLLOWER
;
syncUtilnodeInfo2raftId
(
&
pSyncNode
->
me
,
pSyncNode
->
vgId
,
&
pSyncNode
->
raftId
);
pSyncNode
->
pPingTimer
=
NULL
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录