Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8deb3b83
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看板
提交
8deb3b83
编写于
11月 12, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact: adjust timeout msg build
上级
60fd3c4e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
56 addition
and
60 deletion
+56
-60
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+0
-14
source/libs/sync/inc/syncTimeout.h
source/libs/sync/inc/syncTimeout.h
+1
-1
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+0
-44
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+1
-1
source/libs/sync/test/sync_test_lib/inc/syncTest.h
source/libs/sync/test/sync_test_lib/inc/syncTest.h
+10
-0
source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c
source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c
+44
-0
未找到文件。
source/libs/sync/inc/syncMessage.h
浏览文件 @
8deb3b83
...
...
@@ -54,20 +54,9 @@ typedef struct SyncClientRequest {
char
data
[];
// origin RpcMsg.pCont
}
SyncClientRequest
;
SyncClientRequest
*
syncClientRequestAlloc
(
uint32_t
dataLen
);
int32_t
syncClientRequestBuildFromRpcMsg
(
SRpcMsg
*
pClientRequestRpcMsg
,
const
SRpcMsg
*
pOriginalRpcMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
);
int32_t
syncClientRequestBuildFromNoopEntry
(
SRpcMsg
*
pClientRequestRpcMsg
,
const
SSyncRaftEntry
*
pEntry
,
int32_t
vgId
);
void
syncClientRequest2RpcMsg
(
const
SyncClientRequest
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
// step 2
void
syncClientRequestFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncClientRequest
*
pMsg
);
cJSON
*
syncClientRequest2Json
(
const
SyncClientRequest
*
pMsg
);
char
*
syncClientRequest2Str
(
const
SyncClientRequest
*
pMsg
);
// for debug ----------------------
void
syncClientRequestPrint
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestPrint2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestLog
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestLog2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
);
// ---------------------------------------------
typedef
struct
SRaftMeta
{
...
...
@@ -609,9 +598,6 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, SyncLocalCmd* pMsg);
bool
syncNodeSnapshotEnable
(
SSyncNode
*
pSyncNode
);
ESyncStrategy
syncNodeStrategy
(
SSyncNode
*
pSyncNode
);
// ---------------------------------------------
SyncTimeout
*
syncTimeoutBuildX
();
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/inc/syncTimeout.h
浏览文件 @
8deb3b83
...
...
@@ -34,7 +34,7 @@ extern "C" {
// /\ voterLog' = [voterLog EXCEPT ![i] = [j \in {} |-> <<>>]]
// /\ UNCHANGED <<messages, leaderVars, logVars>>
//
int32_t
syncNodeOnTimer
(
SSyncNode
*
ths
,
SRpcMsg
*
pMsg
);
int32_t
syncNodeOnTimer
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
}
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
8deb3b83
...
...
@@ -42,15 +42,6 @@ int32_t syncTimeoutBuild(SRpcMsg* pTimeoutRpcMsg, ESyncTimeoutType timeoutType,
return
0
;
}
SyncClientRequest
*
syncClientRequestAlloc
(
uint32_t
dataLen
)
{
uint32_t
bytes
=
sizeof
(
SyncClientRequest
)
+
dataLen
;
SyncClientRequest
*
pMsg
=
taosMemoryCalloc
(
1
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
TDMT_SYNC_CLIENT_REQUEST
;
pMsg
->
dataLen
=
dataLen
;
return
pMsg
;
}
int32_t
syncClientRequestBuildFromRpcMsg
(
SRpcMsg
*
pClientRequestRpcMsg
,
const
SRpcMsg
*
pOriginalRpcMsg
,
uint64_t
seqNum
,
bool
isWeak
,
int32_t
vgId
)
{
int32_t
bytes
=
sizeof
(
SyncClientRequest
)
+
pOriginalRpcMsg
->
contLen
;
...
...
@@ -97,41 +88,6 @@ int32_t syncClientRequestBuildFromNoopEntry(SRpcMsg* pClientRequestRpcMsg, const
return
0
;
}
cJSON
*
syncClientRequest2Json
(
const
SyncClientRequest
*
pMsg
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pMsg
!=
NULL
)
{
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"vgId"
,
pMsg
->
vgId
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON_AddNumberToObject
(
pRoot
,
"originalRpcType"
,
pMsg
->
originalRpcType
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pMsg
->
seqNum
);
cJSON_AddStringToObject
(
pRoot
,
"seqNum"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"isWeak"
,
pMsg
->
isWeak
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pMsg
->
dataLen
);
char
*
s
;
s
=
syncUtilPrintBin
((
char
*
)(
pMsg
->
data
),
pMsg
->
dataLen
);
cJSON_AddStringToObject
(
pRoot
,
"data"
,
s
);
taosMemoryFree
(
s
);
s
=
syncUtilPrintBin2
((
char
*
)(
pMsg
->
data
),
pMsg
->
dataLen
);
cJSON_AddStringToObject
(
pRoot
,
"data2"
,
s
);
taosMemoryFree
(
s
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncClientRequest"
,
pRoot
);
return
pJson
;
}
char
*
syncClientRequest2Str
(
const
SyncClientRequest
*
pMsg
)
{
cJSON
*
pJson
=
syncClientRequest2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
// ---- message process SyncClientRequestBatch----
// block1:
...
...
source/libs/sync/src/syncTimeout.c
浏览文件 @
8deb3b83
...
...
@@ -85,7 +85,7 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) {
return
0
;
}
int32_t
syncNodeOnTimer
(
SSyncNode
*
ths
,
SRpcMsg
*
pRpc
)
{
int32_t
syncNodeOnTimer
(
SSyncNode
*
ths
,
const
SRpcMsg
*
pRpc
)
{
int32_t
ret
=
0
;
SyncTimeout
*
pMsg
=
pRpc
->
pCont
;
...
...
source/libs/sync/test/sync_test_lib/inc/syncTest.h
浏览文件 @
8deb3b83
...
...
@@ -231,6 +231,16 @@ void syncTimeoutPrint2(char* s, const SyncTimeout* pMsg);
void
syncTimeoutLog
(
const
SyncTimeout
*
pMsg
);
void
syncTimeoutLog2
(
char
*
s
,
const
SyncTimeout
*
pMsg
);
SyncClientRequest
*
syncClientRequestAlloc
(
uint32_t
dataLen
);
void
syncClientRequest2RpcMsg
(
const
SyncClientRequest
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
// step 2
void
syncClientRequestFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncClientRequest
*
pMsg
);
cJSON
*
syncClientRequest2Json
(
const
SyncClientRequest
*
pMsg
);
char
*
syncClientRequest2Str
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestPrint
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestPrint2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestLog
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestLog2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/sync/test/sync_test_lib/src/syncMessageDebug.c
浏览文件 @
8deb3b83
...
...
@@ -938,6 +938,50 @@ void syncSnapshotSendLog2(char* s, const SyncSnapshotSend* pMsg) {
}
}
SyncClientRequest
*
syncClientRequestAlloc
(
uint32_t
dataLen
)
{
uint32_t
bytes
=
sizeof
(
SyncClientRequest
)
+
dataLen
;
SyncClientRequest
*
pMsg
=
taosMemoryCalloc
(
1
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
msgType
=
TDMT_SYNC_CLIENT_REQUEST
;
pMsg
->
dataLen
=
dataLen
;
return
pMsg
;
}
cJSON
*
syncClientRequest2Json
(
const
SyncClientRequest
*
pMsg
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pMsg
!=
NULL
)
{
cJSON_AddNumberToObject
(
pRoot
,
"bytes"
,
pMsg
->
bytes
);
cJSON_AddNumberToObject
(
pRoot
,
"vgId"
,
pMsg
->
vgId
);
cJSON_AddNumberToObject
(
pRoot
,
"msgType"
,
pMsg
->
msgType
);
cJSON_AddNumberToObject
(
pRoot
,
"originalRpcType"
,
pMsg
->
originalRpcType
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%"
PRIu64
,
pMsg
->
seqNum
);
cJSON_AddStringToObject
(
pRoot
,
"seqNum"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"isWeak"
,
pMsg
->
isWeak
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pMsg
->
dataLen
);
char
*
s
;
s
=
syncUtilPrintBin
((
char
*
)(
pMsg
->
data
),
pMsg
->
dataLen
);
cJSON_AddStringToObject
(
pRoot
,
"data"
,
s
);
taosMemoryFree
(
s
);
s
=
syncUtilPrintBin2
((
char
*
)(
pMsg
->
data
),
pMsg
->
dataLen
);
cJSON_AddStringToObject
(
pRoot
,
"data2"
,
s
);
taosMemoryFree
(
s
);
}
cJSON
*
pJson
=
cJSON_CreateObject
();
cJSON_AddItemToObject
(
pJson
,
"SyncClientRequest"
,
pRoot
);
return
pJson
;
}
char
*
syncClientRequest2Str
(
const
SyncClientRequest
*
pMsg
)
{
cJSON
*
pJson
=
syncClientRequest2Json
(
pMsg
);
char
*
serialized
=
cJSON_Print
(
pJson
);
cJSON_Delete
(
pJson
);
return
serialized
;
}
cJSON
*
syncClientRequestBatch2Json
(
const
SyncClientRequestBatch
*
pMsg
)
{
char
u64buf
[
128
]
=
{
0
};
cJSON
*
pRoot
=
cJSON_CreateObject
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录