Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a0319ae4
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看板
提交
a0319ae4
编写于
3月 07, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync refactor
上级
b5902836
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
48 addition
and
50 deletion
+48
-50
source/libs/sync/inc/syncAppendEntries.h
source/libs/sync/inc/syncAppendEntries.h
+0
-4
source/libs/sync/inc/syncAppendEntriesReply.h
source/libs/sync/inc/syncAppendEntriesReply.h
+0
-2
source/libs/sync/inc/syncElection.h
source/libs/sync/inc/syncElection.h
+0
-1
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-0
source/libs/sync/inc/syncOnMessage.h
source/libs/sync/inc/syncOnMessage.h
+0
-2
source/libs/sync/inc/syncTimeout.h
source/libs/sync/inc/syncTimeout.h
+1
-1
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+4
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+5
-34
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+0
-2
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+36
-1
未找到文件。
source/libs/sync/inc/syncAppendEntries.h
浏览文件 @
a0319ae4
...
...
@@ -28,10 +28,6 @@ extern "C" {
#include "syncRaft.h"
#include "taosdef.h"
void
appendEntries
(
SRaft
*
pRaft
,
const
SyncAppendEntries
*
pMsg
);
void
onAppendEntries
(
SRaft
*
pRaft
,
const
SyncAppendEntries
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncAppendEntriesReply.h
浏览文件 @
a0319ae4
...
...
@@ -28,8 +28,6 @@ extern "C" {
#include "syncRaft.h"
#include "taosdef.h"
void
onAppendEntriesReply
(
SRaft
*
pRaft
,
const
SyncAppendEntriesReply
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncElection.h
浏览文件 @
a0319ae4
...
...
@@ -27,7 +27,6 @@ extern "C" {
#include "taosdef.h"
void
syncNodeElect
(
SSyncNode
*
pSyncNode
);
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
#ifdef __cplusplus
}
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
a0319ae4
...
...
@@ -191,6 +191,8 @@ void syncNodeClose(SSyncNode* pSyncNode);
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
);
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
);
void
syncNodePingSelf
(
SSyncNode
*
pSyncNode
);
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeStopPingTimer
(
SSyncNode
*
pSyncNode
);
...
...
source/libs/sync/inc/syncOnMessage.h
浏览文件 @
a0319ae4
...
...
@@ -26,8 +26,6 @@ extern "C" {
#include "syncRaft.h"
#include "taosdef.h"
void
onMessage
(
SRaft
*
pRaft
,
void
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncTimeout.h
浏览文件 @
a0319ae4
...
...
@@ -28,7 +28,7 @@ extern "C" {
#include "syncRaft.h"
#include "taosdef.h"
void
onTimeout
(
SRaft
*
pRaft
,
void
*
pMsg
);
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/libs/sync/src/syncElection.c
浏览文件 @
a0319ae4
...
...
@@ -15,6 +15,7 @@
#include "syncElection.h"
void
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{}
\ No newline at end of file
void
syncNodeElect
(
SSyncNode
*
pSyncNode
)
{
// start election
syncNodeRequestVotePeers
(
pSyncNode
);
}
source/libs/sync/src/syncMain.c
浏览文件 @
a0319ae4
...
...
@@ -18,6 +18,7 @@
#include "syncEnv.h"
#include "syncInt.h"
#include "syncRaft.h"
#include "syncTimeout.h"
#include "syncUtil.h"
static
int32_t
tsNodeRefId
=
-
1
;
...
...
@@ -33,7 +34,6 @@ 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
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
static
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
static
void
syncNodeBecomeFollower
(
SSyncNode
*
pSyncNode
);
static
void
syncNodeBecomeLeader
(
SSyncNode
*
pSyncNode
);
...
...
@@ -41,9 +41,6 @@ static void syncNodeFollower2Candidate(SSyncNode* pSyncNode);
static
void
syncNodeCandidate2Leader
(
SSyncNode
*
pSyncNode
);
static
void
syncNodeLeader2Follower
(
SSyncNode
*
pSyncNode
);
static
void
syncNodeCandidate2Follower
(
SSyncNode
*
pSyncNode
);
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
);
// ---------------------------------
int32_t
syncInit
()
{
...
...
@@ -171,6 +168,10 @@ void syncNodePingSelf(SSyncNode* pSyncNode) {
syncPingDestroy
(
pMsg
);
}
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{}
int32_t
syncNodeStartPingTimer
(
SSyncNode
*
pSyncNode
)
{
atomic_store_64
(
&
pSyncNode
->
pingTimerLogicClock
,
pSyncNode
->
pingTimerLogicClockUser
);
pSyncNode
->
pingTimerMS
=
PING_TIMER_MS
;
...
...
@@ -311,32 +312,6 @@ static int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) {
return
ret
;
}
static
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
ret
=
0
;
sTrace
(
"<-- syncNodeOnTimeoutCb -->"
);
{
cJSON
*
pJson
=
syncTimeout2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"process syncMessage recv: syncNodeOnTimeoutCb pMsg:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_PING
)
{
if
(
atomic_load_64
(
&
ths
->
pingTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
pingTimerCounter
);
syncNodePingAll
(
ths
);
}
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
{
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_HEARTBEAT
)
{
}
else
{
}
return
ret
;
}
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
param
;
if
(
atomic_load_64
(
&
pSyncNode
->
pingTimerLogicClockUser
)
<=
atomic_load_64
(
&
pSyncNode
->
pingTimerLogicClock
))
{
...
...
@@ -415,7 +390,3 @@ static void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {}
static
void
syncNodeLeader2Follower
(
SSyncNode
*
pSyncNode
)
{}
static
void
syncNodeCandidate2Follower
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodeAppendEntriesPeers
(
SSyncNode
*
pSyncNode
)
{}
\ No newline at end of file
source/libs/sync/src/syncMessage.c
浏览文件 @
a0319ae4
...
...
@@ -18,8 +18,6 @@
#include "syncUtil.h"
#include "tcoding.h"
void
onMessage
(
SRaft
*
pRaft
,
void
*
pMsg
)
{}
// ---------------------------------------------
cJSON
*
syncRpcMsg2Json
(
SRpcMsg
*
pRpcMsg
)
{
cJSON
*
pRoot
;
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
a0319ae4
...
...
@@ -14,5 +14,40 @@
*/
#include "syncTimeout.h"
#include "syncElection.h"
void
onTimeout
(
SRaft
*
pRaft
,
void
*
pMsg
)
{}
\ No newline at end of file
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
ret
=
0
;
sTrace
(
"<-- syncNodeOnTimeoutCb -->"
);
{
cJSON
*
pJson
=
syncTimeout2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"process syncMessage recv: syncNodeOnTimeoutCb pMsg:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
}
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_PING
)
{
if
(
atomic_load_64
(
&
ths
->
pingTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
pingTimerCounter
);
syncNodePingAll
(
ths
);
}
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_ELECTION
)
{
if
(
atomic_load_64
(
&
ths
->
electTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
electTimerCounter
);
syncNodeElect
(
ths
);
}
}
else
if
(
pMsg
->
timeoutType
==
SYNC_TIMEOUT_HEARTBEAT
)
{
if
(
atomic_load_64
(
&
ths
->
heartbeatTimerLogicClockUser
)
<=
pMsg
->
logicClock
)
{
++
(
ths
->
heartbeatTimerCounter
);
syncNodeAppendEntriesPeers
(
ths
);
}
}
else
{
sTrace
(
"unknown timeoutType:%d"
,
pMsg
->
timeoutType
);
}
return
ret
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录