Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e10ec841
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看板
提交
e10ec841
编写于
2月 20, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
fd8cad28
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
9 deletion
+17
-9
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+17
-9
未找到文件。
source/client/src/clientTmq.c
浏览文件 @
e10ec841
...
...
@@ -458,6 +458,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pOffset
->
val
=
pVg
->
currentOffset
;
int32_t
groupLen
=
strlen
(
tmq
->
groupId
);
...
...
@@ -471,11 +472,13 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
if
(
code
<
0
)
{
return
-
1
;
}
void
*
buf
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgHead
)
+
len
);
if
(
buf
==
NULL
)
{
taosMemoryFree
(
pOffset
);
return
-
1
;
}
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
pVg
->
vgId
);
void
*
abuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
...
...
@@ -492,6 +495,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
taosMemoryFree
(
buf
);
return
-
1
;
}
pParam
->
params
=
pParamSet
;
pParam
->
pOffset
=
pOffset
;
...
...
@@ -503,14 +507,16 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
taosMemoryFree
(
pParam
);
return
-
1
;
}
pMsgSendInfo
->
msgInfo
=
(
SDataBuf
){
.
pData
=
buf
,
.
len
=
sizeof
(
SMsgHead
)
+
len
,
.
handle
=
NULL
,
};
tscDebug
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d offset:%"
PRId64
,
tmq
->
consumerId
,
pOffset
->
subKey
,
pVg
->
vgId
,
pOffset
->
val
.
version
);
SEp
*
pEp
=
&
pVg
->
epSet
.
eps
[
pVg
->
epSet
.
inUse
];
tscDebug
(
"consumer:0x%"
PRIx64
" topic:%s on vgId:%d offset:%"
PRId64
" prev:%"
PRId64
", ep:%s:%d"
,
tmq
->
consumerId
,
pOffset
->
subKey
,
pVg
->
vgId
,
pOffset
->
val
.
version
,
pVg
->
committedOffset
.
version
,
pEp
->
fqdn
,
pEp
->
port
);
// TODO: put into cb
pVg
->
committedOffset
=
pVg
->
currentOffset
;
...
...
@@ -637,15 +643,16 @@ static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async,
// init as 1 to prevent concurrency issue
pParamSet
->
waitingRspNum
=
1
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tmq
->
clientTopics
);
i
++
)
{
int32_t
numOfTopics
=
taosArrayGetSize
(
tmq
->
clientTopics
);
tscDebug
(
"consumer:0x%"
PRIx64
" start to commit offset for %d topics"
,
tmq
->
consumerId
,
numOfTopics
);
for
(
int32_t
i
=
0
;
i
<
numOfTopics
;
i
++
)
{
SMqClientTopic
*
pTopic
=
taosArrayGet
(
tmq
->
clientTopics
,
i
);
int32_t
numOfVgroups
=
taosArrayGetSize
(
pTopic
->
vgs
);
for
(
int32_t
j
=
0
;
j
<
numOfVgroups
;
j
++
)
{
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
j
);
if
(
pVg
->
currentOffset
.
type
>
0
&&
!
tOffsetEqual
(
&
pVg
->
currentOffset
,
&
pVg
->
committedOffset
))
{
tscDebug
(
"consumer:0x%"
PRIx64
" topic:%s vgId:%d, current %"
PRId64
", committed %"
PRId64
,
tmq
->
consumerId
,
pTopic
->
topicName
,
pVg
->
vgId
,
pVg
->
currentOffset
.
version
,
pVg
->
committedOffset
.
version
);
if
(
tmqSendCommitReq
(
tmq
,
pVg
,
pTopic
,
pParamSet
)
<
0
)
{
continue
;
}
...
...
@@ -1085,7 +1092,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) {
}
tNameExtractFullName
(
&
name
,
topicFName
);
tscDebug
(
"consumer:0x%"
PRIx64
"
,
subscribe topic: %s"
,
tmq
->
consumerId
,
topicFName
);
tscDebug
(
"consumer:0x%"
PRIx64
" subscribe topic: %s"
,
tmq
->
consumerId
,
topicFName
);
taosArrayPush
(
req
.
topicNames
,
&
topicFName
);
}
...
...
@@ -1398,7 +1405,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) {
}
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
tscDebug
(
"consumer:0x%"
PRIx64
"
,
update topic info completed"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:0x%"
PRIx64
" update topic info completed"
,
tmq
->
consumerId
);
return
set
;
}
...
...
@@ -1548,7 +1555,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
sendInfo
->
msgType
=
TDMT_MND_TMQ_ASK_EP
;
SEpSet
epSet
=
getEpSet_s
(
&
tmq
->
pTscObj
->
pAppInfo
->
mgmtEp
);
tscDebug
(
"consumer:0x%"
PRIx64
" ask ep from mnode, async:%d
"
,
tmq
->
consumerId
,
async
);
tscDebug
(
"consumer:0x%"
PRIx64
" ask ep from mnode, async:%d
, reqId:0x%"
PRIx64
,
tmq
->
consumerId
,
async
,
tmq
->
consumerId
);
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
sendInfo
);
...
...
@@ -1759,6 +1766,7 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) {
while
(
1
)
{
SMqRspWrapper
*
rspWrapper
=
NULL
;
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
if
(
rspWrapper
==
NULL
)
{
taosReadAllQitems
(
tmq
->
mqueue
,
tmq
->
qall
);
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
rspWrapper
);
...
...
@@ -1881,7 +1889,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) {
// in no topic status, delayed task also need to be processed
if
(
atomic_load_8
(
&
tmq
->
status
)
==
TMQ_CONSUMER_STATUS__INIT
)
{
tscDebug
(
"consumer:0x%"
PRIx64
", poll return since consumer
status
is init"
,
tmq
->
consumerId
);
tscDebug
(
"consumer:0x%"
PRIx64
", poll return since consumer is init"
,
tmq
->
consumerId
);
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录