Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
376bf46a
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看板
提交
376bf46a
编写于
6月 30, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(sync): add SyncClientRequestBatch
上级
1a8cf049
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
0 deletion
+74
-0
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-0
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+31
-0
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+2
-0
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+39
-0
未找到文件。
include/common/tmsgdef.h
浏览文件 @
376bf46a
...
...
@@ -232,6 +232,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_SYNC_PING
,
"sync-ping"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_PING_REPLY
,
"sync-ping-reply"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST
,
"sync-client-request"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST_BATCH
,
"sync-client-request-batch"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CLIENT_REQUEST_REPLY
,
"sync-client-request-reply"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_REQUEST_VOTE
,
"sync-request-vote"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_REQUEST_VOTE_REPLY
,
"sync-request-vote-reply"
,
NULL
,
NULL
)
...
...
include/libs/sync/sync.h
浏览文件 @
376bf46a
...
...
@@ -202,6 +202,7 @@ SyncGroupId syncGetVgId(int64_t rid);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetRetryEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
int32_t
syncPropose
(
int64_t
rid
,
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
pMsgArr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
);
bool
syncEnvIsStart
();
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
...
...
include/libs/sync/syncTools.h
浏览文件 @
376bf46a
...
...
@@ -219,6 +219,33 @@ void syncClientRequestPrint2(char* s, const SyncClientRequest* pMsg);
void
syncClientRequestLog
(
const
SyncClientRequest
*
pMsg
);
void
syncClientRequestLog2
(
char
*
s
,
const
SyncClientRequest
*
pMsg
);
// ---------------------------------------------
typedef
struct
SOffsetAndContLen
{
int32_t
offset
;
int32_t
contLen
;
}
SOffsetAndContLen
;
typedef
struct
SRaftMeta
{
uint64_t
seqNum
;
bool
isWeak
;
}
SRaftMeta
;
// block1:
// block2: SRaftMeta array
// block3: rpc msg array (with pCont)
typedef
struct
SyncClientRequestBatch
{
uint32_t
bytes
;
int32_t
vgId
;
uint32_t
msgType
;
// SyncClientRequestBatch msgType
uint32_t
dataCount
;
uint32_t
dataLen
;
// user RpcMsg.contLen
char
data
[];
// user RpcMsg.pCont
}
SyncClientRequestBatch
;
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
rpcMsgArr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
int32_t
vgId
);
// ---------------------------------------------
typedef
struct
SyncClientRequestReply
{
uint32_t
bytes
;
...
...
@@ -325,10 +352,14 @@ void syncAppendEntriesLog(const SyncAppendEntries* pMsg);
void
syncAppendEntriesLog2
(
char
*
s
,
const
SyncAppendEntries
*
pMsg
);
// ---------------------------------------------
// define ahead
/*
typedef struct SOffsetAndContLen {
int32_t offset;
int32_t contLen;
} SOffsetAndContLen;
*/
typedef
struct
SyncAppendEntriesBatch
{
uint32_t
bytes
;
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
376bf46a
...
...
@@ -627,6 +627,8 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak) {
return
ret
;
}
int32_t
syncProposeBatch
(
int64_t
rid
,
SRpcMsg
*
pMsgArr
,
bool
*
pIsWeakArr
,
int32_t
arrSize
)
{
return
0
;
}
int32_t
syncNodePropose
(
SSyncNode
*
pSyncNode
,
SRpcMsg
*
pMsg
,
bool
isWeak
)
{
int32_t
ret
=
0
;
...
...
source/libs/sync/src/syncMessage.c
浏览文件 @
376bf46a
...
...
@@ -956,6 +956,45 @@ void syncClientRequestLog2(char* s, const SyncClientRequest* pMsg) {
}
}
// ---- message process SyncClientRequestBatch----
// block1:
// block2: SRaftMeta array
// block3: rpc msg array (with pCont)
SyncClientRequestBatch
*
syncClientRequestBatchBuild
(
SRpcMsg
*
rpcMsgArr
,
SRaftMeta
*
raftArr
,
int32_t
arrSize
,
int32_t
vgId
)
{
ASSERT
(
rpcMsgArr
!=
NULL
);
ASSERT
(
arrSize
>
0
);
int32_t
dataLen
=
0
;
int32_t
raftMetaArrayLen
=
sizeof
(
SRpcMsg
)
*
arrSize
;
int32_t
rpcArrayLen
=
sizeof
(
SRaftMeta
)
*
arrSize
;
uint32_t
bytes
=
sizeof
(
SyncClientRequestBatch
)
+
dataLen
;
SyncClientRequestBatch
*
pMsg
=
taosMemoryMalloc
(
bytes
);
memset
(
pMsg
,
0
,
bytes
);
pMsg
->
bytes
=
bytes
;
pMsg
->
vgId
=
vgId
;
pMsg
->
msgType
=
TDMT_SYNC_CLIENT_REQUEST_BATCH
;
pMsg
->
dataCount
=
arrSize
;
pMsg
->
dataLen
=
dataLen
;
SRaftMeta
*
raftMetaArr
=
(
SRaftMeta
*
)(
pMsg
->
data
);
SRpcMsg
*
msgArr
=
(
SRpcMsg
*
)((
char
*
)(
pMsg
->
data
)
+
raftMetaArrayLen
);
for
(
int
i
=
0
;
i
<
arrSize
;
++
i
)
{
// init raftMetaArr
raftMetaArr
[
i
].
isWeak
=
raftArr
[
i
].
isWeak
;
raftMetaArr
[
i
].
seqNum
=
raftArr
[
i
].
seqNum
;
// init msgArr
msgArr
[
i
]
=
rpcMsgArr
[
i
];
}
return
pMsg
;
}
// ---- message process SyncRequestVote----
SyncRequestVote
*
syncRequestVoteBuild
(
int32_t
vgId
)
{
uint32_t
bytes
=
sizeof
(
SyncRequestVote
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录