Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6a7f5c5f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
6a7f5c5f
编写于
3月 18, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync refactor
上级
11c8ac91
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
5 deletion
+42
-5
source/libs/sync/inc/syncCommit.h
source/libs/sync/inc/syncCommit.h
+35
-0
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+0
-1
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+2
-1
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+2
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+2
-1
source/libs/sync/test/syncWriteTest.cpp
source/libs/sync/test/syncWriteTest.cpp
+1
-1
未找到文件。
source/libs/sync/inc/syncCommit.h
0 → 100644
浏览文件 @
6a7f5c5f
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_LIBS_SYNC_COMMIT_H
#define _TD_LIBS_SYNC_COMMIT_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "syncInt.h"
#include "taosdef.h"
void
syncMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_LIBS_SYNC_COMMIT_H*/
source/libs/sync/inc/syncInt.h
浏览文件 @
6a7f5c5f
...
@@ -236,7 +236,6 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode);
...
@@ -236,7 +236,6 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode);
// raft vote --------------
// raft vote --------------
void
syncNodeVoteForTerm
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
,
SRaftId
*
pRaftId
);
void
syncNodeVoteForTerm
(
SSyncNode
*
pSyncNode
,
SyncTerm
term
,
SRaftId
*
pRaftId
);
void
syncNodeVoteForSelf
(
SSyncNode
*
pSyncNode
);
void
syncNodeVoteForSelf
(
SSyncNode
*
pSyncNode
);
void
syncNodeMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
);
// for debug --------------
// for debug --------------
void
syncNodePrint
(
SSyncNode
*
pObj
);
void
syncNodePrint
(
SSyncNode
*
pObj
);
...
...
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
6a7f5c5f
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "syncAppendEntriesReply.h"
#include "syncAppendEntriesReply.h"
#include "syncCommit.h"
#include "syncIndexMgr.h"
#include "syncIndexMgr.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftLog.h"
#include "syncRaftLog.h"
...
@@ -59,7 +60,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
...
@@ -59,7 +60,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
syncIndexMgrSetIndex
(
ths
->
pMatchIndex
,
&
(
pMsg
->
srcId
),
pMsg
->
matchIndex
);
// maybe commit
// maybe commit
sync
Node
MaybeAdvanceCommitIndex
(
ths
);
syncMaybeAdvanceCommitIndex
(
ths
);
}
else
{
}
else
{
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
SyncIndex
nextIndex
=
syncIndexMgrGetIndex
(
ths
->
pNextIndex
,
&
(
pMsg
->
srcId
));
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
6a7f5c5f
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "syncCommit.h"
#include "syncIndexMgr.h"
#include "syncIndexMgr.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftLog.h"
#include "syncRaftLog.h"
...
@@ -40,7 +41,7 @@
...
@@ -40,7 +41,7 @@
// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex]
// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex]
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
// /\ UNCHANGED <<messages, serverVars, candidateVars, leaderVars, log>>
//
//
void
sync
Node
MaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
)
{
void
syncMaybeAdvanceCommitIndex
(
SSyncNode
*
pSyncNode
)
{
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pNextIndex"
,
pSyncNode
->
pNextIndex
);
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pNextIndex"
,
pSyncNode
->
pNextIndex
);
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pMatchIndex"
,
pSyncNode
->
pMatchIndex
);
syncIndexMgrLog2
(
"==syncNodeMaybeAdvanceCommitIndex== pMatchIndex"
,
pSyncNode
->
pMatchIndex
);
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
6a7f5c5f
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "sync.h"
#include "sync.h"
#include "syncAppendEntries.h"
#include "syncAppendEntries.h"
#include "syncAppendEntriesReply.h"
#include "syncAppendEntriesReply.h"
#include "syncCommit.h"
#include "syncElection.h"
#include "syncElection.h"
#include "syncEnv.h"
#include "syncEnv.h"
#include "syncIndexMgr.h"
#include "syncIndexMgr.h"
...
@@ -740,7 +741,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
...
@@ -740,7 +741,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
ths
->
pLogStore
->
appendEntry
(
ths
->
pLogStore
,
pEntry
);
ths
->
pLogStore
->
appendEntry
(
ths
->
pLogStore
,
pEntry
);
// only myself, maybe commit
// only myself, maybe commit
sync
Node
MaybeAdvanceCommitIndex
(
ths
);
syncMaybeAdvanceCommitIndex
(
ths
);
// start replicate right now!
// start replicate right now!
syncNodeReplicate
(
ths
);
syncNodeReplicate
(
ths
);
...
...
source/libs/sync/test/syncWriteTest.cpp
浏览文件 @
6a7f5c5f
...
@@ -162,7 +162,7 @@ int main(int argc, char **argv) {
...
@@ -162,7 +162,7 @@ int main(int argc, char **argv) {
SyncClientRequest
*
pMsg1
=
step1
(
pMsg0
);
SyncClientRequest
*
pMsg1
=
step1
(
pMsg0
);
syncClientRequestPrint2
((
char
*
)
"==step1=="
,
pMsg1
);
syncClientRequestPrint2
((
char
*
)
"==step1=="
,
pMsg1
);
for
(
int
i
=
0
;
i
<
5
;
++
i
)
{
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SyncClientRequest
*
pSyncClientRequest
=
pMsg1
;
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
syncClientRequest2RpcMsg
(
pSyncClientRequest
,
&
rpcMsg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录