Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eaf6142c
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
eaf6142c
编写于
2月 28, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync modify timer
上级
c9efe3de
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
110 addition
and
11 deletion
+110
-11
include/libs/sync/sync.h
include/libs/sync/sync.h
+3
-1
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+4
-3
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+3
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+2
-1
source/libs/sync/inc/syncUtil.h
source/libs/sync/inc/syncUtil.h
+40
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+35
-3
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+22
-0
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+1
-0
未找到文件。
include/libs/sync/sync.h
浏览文件 @
eaf6142c
...
@@ -137,7 +137,9 @@ typedef struct SSyncInfo {
...
@@ -137,7 +137,9 @@ typedef struct SSyncInfo {
SSyncCfg
syncCfg
;
SSyncCfg
syncCfg
;
char
path
[
TSDB_FILENAME_LEN
];
char
path
[
TSDB_FILENAME_LEN
];
SSyncFSM
*
pFsm
;
SSyncFSM
*
pFsm
;
int32_t
(
*
FpSendMsg
)(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
void
*
rpcClient
;
int32_t
(
*
FpSendMsg
)(
void
*
rpcClient
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
}
SSyncInfo
;
}
SSyncInfo
;
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
eaf6142c
...
@@ -34,17 +34,18 @@ typedef struct SSyncEnv {
...
@@ -34,17 +34,18 @@ typedef struct SSyncEnv {
tmr_h
pEnvTickTimer
;
tmr_h
pEnvTickTimer
;
tmr_h
pTimerManager
;
tmr_h
pTimerManager
;
char
name
[
128
];
char
name
[
128
];
}
SSyncEnv
;
}
SSyncEnv
;
extern
SSyncEnv
*
gSyncEnv
;
extern
SSyncEnv
*
gSyncEnv
;
int32_t
syncEnvStart
();
int32_t
syncEnvStart
();
int32_t
syncEnvStop
();
int32_t
syncEnvStop
();
tmr_h
syncEnvStartTimer
(
TAOS_TMR_CALLBACK
fp
,
int
mseconds
,
void
*
param
);
tmr_h
syncEnvStartTimer
(
TAOS_TMR_CALLBACK
fp
,
int
mseconds
,
void
*
param
);
void
syncEnvStopTimer
(
tmr_h
*
pTimer
);
void
syncEnvStopTimer
(
tmr_h
*
pTimer
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/sync/inc/syncIO.h
浏览文件 @
eaf6142c
...
@@ -30,10 +30,10 @@ extern "C" {
...
@@ -30,10 +30,10 @@ extern "C" {
#include "trpc.h"
#include "trpc.h"
typedef
struct
SSyncIO
{
typedef
struct
SSyncIO
{
void
*
serverRpc
;
void
*
serverRpc
;
void
*
clientRpc
;
void
*
clientRpc
;
STaosQueue
*
pMsgQ
;
STaosQueue
*
pMsgQ
;
STaosQset
*
pQset
;
STaosQset
*
pQset
;
pthread_t
tid
;
pthread_t
tid
;
int8_t
isStart
;
int8_t
isStart
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
eaf6142c
...
@@ -146,7 +146,8 @@ typedef struct SSyncNode {
...
@@ -146,7 +146,8 @@ typedef struct SSyncNode {
int32_t
(
*
FpOnAppendEntriesReply
)(
struct
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpOnAppendEntriesReply
)(
struct
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
// passed from outside
// passed from outside
int32_t
(
*
FpSendMsg
)(
void
*
handle
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
void
*
rpcClient
;
int32_t
(
*
FpSendMsg
)(
void
*
rpcClient
,
const
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
);
}
SSyncNode
;
}
SSyncNode
;
...
...
source/libs/sync/inc/syncUtil.h
0 → 100644
浏览文件 @
eaf6142c
/*
* 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_UTIL_H
#define _TD_LIBS_SYNC_UTIL_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "syncInt.h"
#include "syncMessage.h"
#include "taosdef.h"
void
nodeInfo2EpSet
(
const
SNodeInfo
*
pNodeInfo
,
SEpSet
*
pEpSet
);
void
raftId2EpSet
(
const
SRaftId
*
raftId
,
SEpSet
*
pEpSet
);
void
syncPing2RpcMsg
(
const
SyncPing
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_LIBS_SYNC_UTIL_H*/
source/libs/sync/src/syncMain.c
浏览文件 @
eaf6142c
...
@@ -18,10 +18,14 @@
...
@@ -18,10 +18,14 @@
#include "syncEnv.h"
#include "syncEnv.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaft.h"
#include "syncRaft.h"
#include "syncUtil.h"
static
int32_t
tsNodeRefId
=
-
1
;
static
int32_t
tsNodeRefId
=
-
1
;
// ------ local funciton ---------
// ------ local funciton ---------
static
int32_t
doSyncNodeSendMsgById
(
SRaftId
*
destRaftId
,
struct
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
static
int32_t
doSyncNodeSendMsgByInfo
(
SNodeInfo
*
nodeInfo
,
struct
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
);
static
int32_t
doSyncNodePing
(
struct
SSyncNode
*
ths
,
const
SyncPing
*
pMsg
);
static
int32_t
doSyncNodePing
(
struct
SSyncNode
*
ths
,
const
SyncPing
*
pMsg
);
static
int32_t
onSyncNodePing
(
struct
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
onSyncNodePing
(
struct
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
onSyncNodePingReply
(
struct
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
static
int32_t
onSyncNodePingReply
(
struct
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
...
@@ -68,7 +72,9 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
...
@@ -68,7 +72,9 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) {
pSyncNode
->
FpPingTimer
=
syncNodePingTimerCb
;
pSyncNode
->
FpPingTimer
=
syncNodePingTimerCb
;
pSyncNode
->
pingTimerCounter
=
0
;
pSyncNode
->
pingTimerCounter
=
0
;
pSyncNode
->
rpcClient
=
pSyncInfo
->
rpcClient
;
pSyncNode
->
FpSendMsg
=
pSyncInfo
->
FpSendMsg
;
pSyncNode
->
FpSendMsg
=
pSyncInfo
->
FpSendMsg
;
pSyncNode
->
FpOnPing
=
onSyncNodePing
;
pSyncNode
->
FpOnPing
=
onSyncNodePing
;
pSyncNode
->
FpOnPingReply
=
onSyncNodePingReply
;
pSyncNode
->
FpOnPingReply
=
onSyncNodePingReply
;
pSyncNode
->
FpOnRequestVote
=
onSyncNodeRequestVote
;
pSyncNode
->
FpOnRequestVote
=
onSyncNodeRequestVote
;
...
@@ -84,7 +90,11 @@ void syncNodeClose(SSyncNode* pSyncNode) {
...
@@ -84,7 +90,11 @@ void syncNodeClose(SSyncNode* pSyncNode) {
free
(
pSyncNode
);
free
(
pSyncNode
);
}
}
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
)
{
sTrace
(
"syncNodePingAll %p "
,
pSyncNode
);
}
void
syncNodePingAll
(
SSyncNode
*
pSyncNode
)
{
sTrace
(
"syncNodePingAll %p "
,
pSyncNode
);
SyncPing
msg
;
doSyncNodePing
(
pSyncNode
,
&
msg
);
}
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
)
{}
void
syncNodePingPeers
(
SSyncNode
*
pSyncNode
)
{}
...
@@ -110,8 +120,30 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) {
...
@@ -110,8 +120,30 @@ int32_t syncNodeStopPingTimer(SSyncNode* pSyncNode) {
}
}
// ------ local funciton ---------
// ------ local funciton ---------
static
int32_t
doSyncNodeSendMsgById
(
SRaftId
*
destRaftId
,
struct
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
raftId2EpSet
(
destRaftId
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
static
int32_t
doSyncNodeSendMsgByInfo
(
SNodeInfo
*
nodeInfo
,
struct
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
)
{
SEpSet
epSet
;
nodeInfo2EpSet
(
nodeInfo
,
&
epSet
);
pSyncNode
->
FpSendMsg
(
pSyncNode
->
rpcClient
,
&
epSet
,
pMsg
);
return
0
;
}
static
int32_t
doSyncNodePing
(
struct
SSyncNode
*
ths
,
const
SyncPing
*
pMsg
)
{
static
int32_t
doSyncNodePing
(
struct
SSyncNode
*
ths
,
const
SyncPing
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
;
for
(
int
i
=
0
;
i
<
ths
->
syncCfg
.
replicaNum
;
++
i
)
{
SRpcMsg
*
rpcMsg
;
syncPing2RpcMsg
(
pMsg
,
rpcMsg
);
doSyncNodeSendMsgByInfo
(
&
ths
->
syncCfg
.
nodeInfo
[
i
],
ths
,
rpcMsg
);
}
return
ret
;
return
ret
;
}
}
...
@@ -167,6 +199,6 @@ static void syncNodePingTimerCb(void* param, void* tmrId) {
...
@@ -167,6 +199,6 @@ static void syncNodePingTimerCb(void* param, void* tmrId) {
taosTmrReset
(
syncNodePingTimerCb
,
pSyncNode
->
pingTimerMS
,
pSyncNode
,
&
gSyncEnv
->
pTimerManager
,
taosTmrReset
(
syncNodePingTimerCb
,
pSyncNode
->
pingTimerMS
,
pSyncNode
,
&
gSyncEnv
->
pTimerManager
,
&
pSyncNode
->
pPingTimer
);
&
pSyncNode
->
pPingTimer
);
syncNodePing
Self
(
pSyncNode
);
syncNodePing
All
(
pSyncNode
);
}
}
}
}
\ No newline at end of file
source/libs/sync/src/syncUtil.c
0 → 100644
浏览文件 @
eaf6142c
/*
* 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/>.
*/
#include "syncUtil.h"
void
nodeInfo2EpSet
(
const
SNodeInfo
*
pNodeInfo
,
SEpSet
*
pEpSet
)
{}
void
raftId2EpSet
(
const
SRaftId
*
raftId
,
SEpSet
*
pEpSet
)
{}
void
syncPing2RpcMsg
(
const
SyncPing
*
pMsg
,
SRpcMsg
*
pRpcMsg
)
{}
\ No newline at end of file
source/libs/sync/test/syncPingTest.cpp
浏览文件 @
eaf6142c
...
@@ -18,6 +18,7 @@ SSyncNode* doSync() {
...
@@ -18,6 +18,7 @@ SSyncNode* doSync() {
SSyncInfo
syncInfo
;
SSyncInfo
syncInfo
;
syncInfo
.
vgId
=
1
;
syncInfo
.
vgId
=
1
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
pFsm
=
pFsm
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./test_sync_ping"
);
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"%s"
,
"./test_sync_ping"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录