Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
98b35306
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看板
提交
98b35306
编写于
3月 04, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync timeout
上级
8d789bba
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
34 addition
and
7 deletion
+34
-7
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+4
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+4
-0
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+14
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+5
-3
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+6
-0
source/libs/sync/test/syncEnqTest.cpp
source/libs/sync/test/syncEnqTest.cpp
+1
-1
未找到文件。
source/libs/sync/inc/syncIO.h
浏览文件 @
98b35306
...
...
@@ -31,11 +31,11 @@ extern "C" {
typedef
struct
SSyncIO
{
STaosQueue
*
pMsgQ
;
STaosQset
*
pQset
;
STaosQset
*
pQset
;
pthread_t
consumerTid
;
void
*
serverRpc
;
void
*
clientRpc
;
void
*
serverRpc
;
void
*
clientRpc
;
SEpSet
myAddr
;
void
*
ioTimerTickQ
;
...
...
@@ -49,6 +49,7 @@ typedef struct SSyncIO {
int32_t
(
*
FpOnSyncRequestVoteReply
)(
SSyncNode
*
pSyncNode
,
SyncRequestVoteReply
*
pMsg
);
int32_t
(
*
FpOnSyncAppendEntries
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnSyncAppendEntriesReply
)(
SSyncNode
*
pSyncNode
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpOnSyncTimeout
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
int8_t
isStart
;
...
...
source/libs/sync/inc/syncInt.h
浏览文件 @
98b35306
...
...
@@ -71,6 +71,9 @@ extern int32_t sDebugFlag;
struct
SRaft
;
typedef
struct
SRaft
SRaft
;
struct
SyncTimeout
;
typedef
struct
SyncTimeout
SyncTimeout
;
struct
SyncPing
;
typedef
struct
SyncPing
SyncPing
;
...
...
@@ -174,6 +177,7 @@ typedef struct SSyncNode {
int32_t
(
*
FpOnRequestVoteReply
)(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
int32_t
(
*
FpOnAppendEntries
)(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
int32_t
(
*
FpOnAppendEntriesReply
)(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
int32_t
(
*
FpOnTimeout
)(
SSyncNode
*
pSyncNode
,
SyncTimeout
*
pMsg
);
}
SSyncNode
;
...
...
source/libs/sync/inc/syncMessage.h
浏览文件 @
98b35306
...
...
@@ -39,12 +39,26 @@ typedef enum ESyncMessageType {
SYNC_REQUEST_VOTE_REPLY
=
111
,
SYNC_APPEND_ENTRIES
=
113
,
SYNC_APPEND_ENTRIES_REPLY
=
115
,
SYNC_TIMEOUT
=
117
,
}
ESyncMessageType
;
// ---------------------------------------------
cJSON
*
syncRpcMsg2Json
(
SRpcMsg
*
pRpcMsg
);
cJSON
*
syncRpcUnknownMsg2Json
();
// ---------------------------------------------
typedef
enum
ESyncTimeoutType
{
SYNC_TIMEOUT_PING
=
0
,
SYNC_TIMEOUT_ELECTION
,
SYNC_TIMEOUT_HEARTBEAT
,
}
ESyncTimeoutType
;
typedef
struct
SyncTimeout
{
ESyncTimeoutType
type
;
void
*
data
;
}
SyncTimeout
;
// ---------------------------------------------
typedef
struct
SyncPing
{
uint32_t
bytes
;
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
98b35306
...
...
@@ -80,7 +80,7 @@ int32_t syncIOSendMsg(void *clientRpc, const SEpSet *pEpSet, SRpcMsg *pMsg) {
pMsg
->
msgType
,
pMsg
->
contLen
);
{
cJSON
*
pJson
=
syncRpcMsg2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
char
*
serialized
=
cJSON_Print
(
pJson
);
sTrace
(
"process syncMessage send: pMsg:%s "
,
serialized
);
free
(
serialized
);
cJSON_Delete
(
pJson
);
...
...
@@ -211,7 +211,7 @@ static void *syncIOConsumerFunc(void *param) {
SSyncIO
*
io
=
param
;
STaosQall
*
qall
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
int
type
;
qall
=
taosAllocateQall
();
...
...
@@ -244,7 +244,9 @@ static void *syncIOConsumerFunc(void *param) {
io
->
FpOnSyncPingReply
(
io
->
pSyncNode
,
pSyncMsg
);
syncPingReplyDestroy
(
pSyncMsg
);
}
}
else
{
}
else
if
(
pRpcMsg
->
msgType
==
SYNC_TIMEOUT
)
{
}
else
{
;
}
}
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
98b35306
...
...
@@ -37,6 +37,7 @@ static int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg);
static
int32_t
syncNodeOnRequestVoteReplyCb
(
SSyncNode
*
ths
,
SyncRequestVoteReply
*
pMsg
);
static
int32_t
syncNodeOnAppendEntriesCb
(
SSyncNode
*
ths
,
SyncAppendEntries
*
pMsg
);
static
int32_t
syncNodeOnAppendEntriesReplyCb
(
SSyncNode
*
ths
,
SyncAppendEntriesReply
*
pMsg
);
static
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
);
// ---------------------------------
int32_t
syncInit
()
{
...
...
@@ -326,6 +327,11 @@ static int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesR
return
ret
;
}
static
int32_t
syncNodeOnTimeoutCb
(
SSyncNode
*
ths
,
SyncTimeout
*
pMsg
)
{
int32_t
ret
=
0
;
return
ret
;
}
static
void
syncNodePingTimerCb
(
void
*
param
,
void
*
tmrId
)
{
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
param
;
if
(
atomic_load_8
(
&
pSyncNode
->
pingTimerEnable
))
{
...
...
source/libs/sync/test/syncEnqTest.cpp
浏览文件 @
98b35306
...
...
@@ -85,7 +85,7 @@ int main(int argc, char** argv) {
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
SyncPingReply
*
pSyncMsg
=
syncPingReplyBuild3
(
&
pSyncNode
->
raftId
,
&
pSyncNode
->
raftId
);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncPingReply2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
pSyncNode
->
FpEqMsg
(
pSyncNode
->
queue
,
&
rpcMsg
);
taosMsleep
(
1000
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录