Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fb861a39
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看板
提交
fb861a39
编写于
11月 17, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: refactor tmq messages
上级
3a642f06
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
135 addition
and
25 deletion
+135
-25
include/common/tmsg.h
include/common/tmsg.h
+6
-0
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+41
-17
source/common/src/tmsg.c
source/common/src/tmsg.c
+65
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+17
-6
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+6
-2
未找到文件。
include/common/tmsg.h
浏览文件 @
fb861a39
...
...
@@ -3198,6 +3198,12 @@ static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
taosMemoryFree
(
pRsp
->
msg
);
}
int32_t
tSerializeSMqAskEpReq
(
void
*
buf
,
int32_t
bufLen
,
SMqAskEpReq
*
pReq
);
int32_t
tDeserializeSMqAskEpReq
(
void
*
buf
,
int32_t
bufLen
,
SMqAskEpReq
*
pReq
);
int32_t
tSerializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
int32_t
tDeserializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
);
#pragma pack(pop)
#ifdef __cplusplus
...
...
source/client/src/clientTmq.c
浏览文件 @
fb861a39
...
...
@@ -728,12 +728,26 @@ void tmqSendHbReq(void* param, void* tmrId) {
taosMemoryFree
(
param
);
return
;
}
int64_t
consumerId
=
tmq
->
consumerId
;
int32_t
epoch
=
tmq
->
epoch
;
SMqHbReq
*
pReq
=
taosMemoryMalloc
(
sizeof
(
SMqHbReq
));
if
(
pReq
==
NULL
)
goto
OVER
;
pReq
->
consumerId
=
htobe64
(
consumerId
);
pReq
->
epoch
=
epoch
;
SMqHbReq
req
=
{
0
};
req
.
consumerId
=
tmq
->
consumerId
;
req
.
epoch
=
tmq
->
epoch
;
int32_t
tlen
=
tSerializeSMqHbReq
(
NULL
,
0
,
&
req
);
if
(
tlen
<
0
)
{
tscError
(
"tSerializeSMqHbReq failed"
);
return
;
}
void
*
pReq
=
taosMemoryCalloc
(
1
,
tlen
);
if
(
tlen
<
0
)
{
tscError
(
"failed to malloc MqHbReq msg, size:%d"
,
tlen
);
return
;
}
if
(
tSerializeSMqHbReq
(
pReq
,
tlen
,
&
req
)
<
0
)
{
tscError
(
"tSerializeSMqHbReq %d failed"
,
tlen
);
taosMemoryFree
(
pReq
);
return
;
}
SMsgSendInfo
*
sendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
sendInfo
==
NULL
)
{
...
...
@@ -1378,21 +1392,31 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
}
atomic_store_32(&tmq->epSkipCnt, 0);
#endif
int32_t
tlen
=
sizeof
(
SMqAskEpReq
);
SMqAskEpReq
*
req
=
taosMemoryCalloc
(
1
,
tlen
);
if
(
req
==
NULL
)
{
tscError
(
"failed to malloc get subscribe ep buf"
);
/*atomic_store_8(&tmq->epStatus, 0);*/
SMqAskEpReq
req
=
{
0
};
req
.
consumerId
=
tmq
->
consumerId
;
req
.
epoch
=
tmq
->
epoch
;
strcpy
(
req
.
cgroup
,
tmq
->
groupId
);
int32_t
tlen
=
tSerializeSMqAskEpReq
(
NULL
,
0
,
&
req
);
if
(
tlen
<
0
)
{
tscError
(
"tSerializeSMqAskEpReq failed"
);
return
-
1
;
}
void
*
pReq
=
taosMemoryCalloc
(
1
,
tlen
);
if
(
tlen
<
0
)
{
tscError
(
"failed to malloc askEpReq msg, size:%d"
,
tlen
);
return
-
1
;
}
if
(
tSerializeSMqAskEpReq
(
pReq
,
tlen
,
&
req
)
<
0
)
{
tscError
(
"tSerializeSMqAskEpReq %d failed"
,
tlen
);
taosMemoryFree
(
pReq
);
return
-
1
;
}
req
->
consumerId
=
htobe64
(
tmq
->
consumerId
);
req
->
epoch
=
htonl
(
tmq
->
epoch
);
strcpy
(
req
->
cgroup
,
tmq
->
groupId
);
SMqAskEpCbParam
*
pParam
=
taosMemoryCalloc
(
1
,
sizeof
(
SMqAskEpCbParam
));
if
(
pParam
==
NULL
)
{
tscError
(
"failed to malloc subscribe param"
);
taosMemoryFree
(
r
eq
);
taosMemoryFree
(
pR
eq
);
/*atomic_store_8(&tmq->epStatus, 0);*/
return
-
1
;
}
...
...
@@ -1405,13 +1429,13 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
if
(
sendInfo
==
NULL
)
{
tsem_destroy
(
&
pParam
->
rspSem
);
taosMemoryFree
(
pParam
);
taosMemoryFree
(
r
eq
);
taosMemoryFree
(
pR
eq
);
/*atomic_store_8(&tmq->epStatus, 0);*/
return
-
1
;
}
sendInfo
->
msgInfo
=
(
SDataBuf
){
.
pData
=
r
eq
,
.
pData
=
pR
eq
,
.
len
=
tlen
,
.
handle
=
NULL
,
};
...
...
source/common/src/tmsg.c
浏览文件 @
fb861a39
...
...
@@ -4579,6 +4579,71 @@ int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
}
int32_t
tSerializeSMqAskEpReq
(
void
*
buf
,
int32_t
bufLen
,
SMqAskEpReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
consumerId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
epoch
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
cgroup
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMqAskEpReq
(
void
*
buf
,
int32_t
bufLen
,
SMqAskEpReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
(
char
*
)
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
consumerId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
epoch
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
cgroup
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
&
encoder
,
pReq
->
consumerId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
epoch
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMqHbReq
(
void
*
buf
,
int32_t
bufLen
,
SMqHbReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
(
char
*
)
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeI64
(
&
decoder
,
&
pReq
->
consumerId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
epoch
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
int32_t
tSerializeSSchedulerHbReq
(
void
*
buf
,
int32_t
bufLen
,
SSchedulerHbReq
*
pReq
)
{
int32_t
headLen
=
sizeof
(
SMsgHead
);
if
(
buf
!=
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
fb861a39
...
...
@@ -325,9 +325,14 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqHbReq
*
pReq
=
(
SMqHbReq
*
)
pMsg
->
pCont
;
int64_t
consumerId
=
be64toh
(
pReq
->
consumerId
);
SMqHbReq
req
=
{
0
};
if
(
tDeserializeSMqHbReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
int64_t
consumerId
=
req
.
consumerId
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
mError
(
"consumer %"
PRId64
" not exist"
,
consumerId
);
...
...
@@ -359,10 +364,16 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
static
int32_t
mndProcessAskEpReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqAskEpReq
*
pReq
=
(
SMqAskEpReq
*
)
pMsg
->
pCont
;
SMqAskEpReq
req
=
{
0
}
;
SMqAskEpRsp
rsp
=
{
0
};
int64_t
consumerId
=
be64toh
(
pReq
->
consumerId
);
int32_t
epoch
=
ntohl
(
pReq
->
epoch
);
if
(
tDeserializeSMqAskEpReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
int64_t
consumerId
=
req
.
consumerId
;
int32_t
epoch
=
req
.
epoch
;
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
...
...
@@ -370,7 +381,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
return
-
1
;
}
ASSERT
(
strcmp
(
pReq
->
cgroup
,
pConsumer
->
cgroup
)
==
0
);
ASSERT
(
strcmp
(
req
.
cgroup
,
pConsumer
->
cgroup
)
==
0
);
atomic_store_32
(
&
pConsumer
->
hbStatus
,
0
);
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
fb861a39
...
...
@@ -301,6 +301,7 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
batchRsp
.
pRsps
=
taosArrayInit
(
msgNum
,
sizeof
(
SBatchRspMsg
));
if
(
NULL
==
batchRsp
.
pRsps
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
qError
(
"taosArrayInit %d SBatchRspMsg failed"
,
msgNum
);
goto
_exit
;
}
...
...
@@ -337,15 +338,18 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
rspSize
=
tSerializeSBatchRsp
(
NULL
,
0
,
&
batchRsp
);
if
(
rspSize
<
0
)
{
qError
(
"tSerializeSBatchRsp failed"
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
pRsp
=
rpcMallocCont
(
rspSize
);
if
(
pRsp
==
NULL
)
{
qError
(
"rpcMallocCont %d failed"
,
rspSize
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
if
(
tSerializeSBatchRsp
(
pRsp
,
rspSize
,
&
batchRsp
))
{
if
(
tSerializeSBatchRsp
(
pRsp
,
rspSize
,
&
batchRsp
)
<
0
)
{
qError
(
"tSerializeSBatchRsp %d failed"
,
rspSize
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_exit
;
}
...
...
@@ -362,7 +366,7 @@ _exit:
qError
(
"vnd get batch meta failed cause of %s"
,
tstrerror
(
code
));
}
taosArrayDestroyEx
(
batchRsp
.
pRsps
,
vnode
FreeSBatchRspMsg
);
taosArrayDestroyEx
(
batchRsp
.
pRsps
,
t
FreeSBatchRspMsg
);
tmsgSendRsp
(
&
rspMsg
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录