Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5cb35f2f
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看板
提交
5cb35f2f
编写于
7月 19, 2023
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:add committed & position & commite_offset interface
上级
5c344b01
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
461 addition
and
151 deletion
+461
-151
include/client/taos.h
include/client/taos.h
+1
-1
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/util/taoserror.h
include/util/taoserror.h
+1
-0
source/client/src/clientRawBlockWrite.c
source/client/src/clientRawBlockWrite.c
+7
-0
source/client/src/clientTmq.c
source/client/src/clientTmq.c
+319
-149
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+83
-0
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+1
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+43
-0
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+3
-1
source/util/src/terror.c
source/util/src/terror.c
+1
-0
未找到文件。
include/client/taos.h
浏览文件 @
5cb35f2f
...
...
@@ -288,7 +288,7 @@ DLL_EXPORT int32_t tmq_consumer_close(tmq_t *tmq);
DLL_EXPORT
int32_t
tmq_commit_sync
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
);
DLL_EXPORT
void
tmq_commit_async
(
tmq_t
*
tmq
,
const
TAOS_RES
*
msg
,
tmq_commit_cb
*
cb
,
void
*
param
);
DLL_EXPORT
int32_t
tmq_commit_offset_sync
(
tmq_t
*
tmq
,
const
char
*
pTopicName
,
int32_t
vgId
,
int64_t
offset
);
DLL_EXPORT
void
tmq_commit_offset_async
(
tmq_t
*
tmq
,
const
char
*
pTopicName
,
int32_t
vgId
,
int64_t
offset
,
tmq_commit_cb
*
cb
,
void
*
param
);
DLL_EXPORT
int32_t
tmq_commit_offset_async
(
tmq_t
*
tmq
,
const
char
*
pTopicName
,
int32_t
vgId
,
int64_t
offset
,
tmq_commit_cb
*
cb
,
void
*
param
);
DLL_EXPORT
int32_t
tmq_get_topic_assignment
(
tmq_t
*
tmq
,
const
char
*
pTopicName
,
tmq_topic_assignment
**
assignment
,
int32_t
*
numOfAssignment
);
DLL_EXPORT
void
tmq_free_assignment
(
tmq_topic_assignment
*
pAssignment
);
...
...
include/common/tmsgdef.h
浏览文件 @
5cb35f2f
...
...
@@ -312,6 +312,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_VND_TMQ_CONSUME
,
"vnode-tmq-consume"
,
SMqPollReq
,
SMqDataBlkRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TMQ_CONSUME_PUSH
,
"vnode-tmq-consume-push"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TMQ_VG_WALINFO
,
"vnode-tmq-vg-walinfo"
,
SMqPollReq
,
SMqDataBlkRsp
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TMQ_VG_COMMITTEDINFO
,
"vnode-tmq-committed-walinfo"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_VND_TMQ_MAX_MSG
,
"vnd-tmq-max"
,
NULL
,
NULL
)
...
...
include/util/taoserror.h
浏览文件 @
5cb35f2f
...
...
@@ -779,6 +779,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TMQ_INVALID_VGID TAOS_DEF_ERROR_CODE(0, 0x4008)
#define TSDB_CODE_TMQ_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x4009)
#define TSDB_CODE_TMQ_NEED_INITIALIZED TAOS_DEF_ERROR_CODE(0, 0x4010)
#define TSDB_CODE_TMQ_NO_COMMITTED TAOS_DEF_ERROR_CODE(0, 0x4011)
// stream
#define TSDB_CODE_STREAM_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x4100)
...
...
source/client/src/clientRawBlockWrite.c
浏览文件 @
5cb35f2f
...
...
@@ -1327,6 +1327,9 @@ end:
int
taos_write_raw_block_with_fields
(
TAOS
*
taos
,
int
rows
,
char
*
pData
,
const
char
*
tbname
,
TAOS_FIELD
*
fields
,
int
numFields
)
{
if
(
!
taos
||
!
pData
||
!
tbname
)
{
return
TSDB_CODE_INVALID_PARA
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
STableMeta
*
pTableMeta
=
NULL
;
SQuery
*
pQuery
=
NULL
;
...
...
@@ -1413,6 +1416,9 @@ end:
}
int
taos_write_raw_block
(
TAOS
*
taos
,
int
rows
,
char
*
pData
,
const
char
*
tbname
)
{
if
(
!
taos
||
!
pData
||
!
tbname
)
{
return
TSDB_CODE_INVALID_PARA
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
STableMeta
*
pTableMeta
=
NULL
;
SQuery
*
pQuery
=
NULL
;
...
...
@@ -1812,6 +1818,7 @@ end:
}
char
*
tmq_get_json_meta
(
TAOS_RES
*
res
)
{
if
(
res
==
NULL
)
return
NULL
;
uDebug
(
"tmq_get_json_meta called"
);
if
(
!
TD_RES_TMQ_META
(
res
)
&&
!
TD_RES_TMQ_METADATA
(
res
))
{
return
NULL
;
...
...
source/client/src/clientTmq.c
浏览文件 @
5cb35f2f
此差异已折叠。
点击以展开。
source/client/test/clientTests.cpp
浏览文件 @
5cb35f2f
...
...
@@ -1075,6 +1075,89 @@ TEST(clientCase, sub_db_test) {
fprintf
(
stderr
,
"%d msg consumed, include %d rows
\n
"
,
msgCnt
,
totalRows
);
}
TEST
(
clientCase
,
tmq_commit
)
{
// taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg");
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
tmq_conf_t
*
conf
=
tmq_conf_new
();
tmq_conf_set
(
conf
,
"enable.auto.commit"
,
"false"
);
tmq_conf_set
(
conf
,
"auto.commit.interval.ms"
,
"2000"
);
tmq_conf_set
(
conf
,
"group.id"
,
"group_id_2"
);
tmq_conf_set
(
conf
,
"td.connect.user"
,
"root"
);
tmq_conf_set
(
conf
,
"td.connect.pass"
,
"taosdata"
);
tmq_conf_set
(
conf
,
"auto.offset.reset"
,
"earliest"
);
tmq_conf_set
(
conf
,
"msg.with.table.name"
,
"true"
);
tmq_t
*
tmq
=
tmq_consumer_new
(
conf
,
NULL
,
0
);
tmq_conf_destroy
(
conf
);
char
topicName
[
128
]
=
"tp"
;
// 创建订阅 topics 列表
tmq_list_t
*
topicList
=
tmq_list_new
();
tmq_list_append
(
topicList
,
topicName
);
// 启动订阅
tmq_subscribe
(
tmq
,
topicList
);
tmq_list_destroy
(
topicList
);
int32_t
totalRows
=
0
;
int32_t
msgCnt
=
0
;
int32_t
timeout
=
2000
;
tmq_topic_assignment
*
pAssign
=
NULL
;
int32_t
numOfAssign
=
0
;
int32_t
code
=
tmq_get_topic_assignment
(
tmq
,
topicName
,
&
pAssign
,
&
numOfAssign
);
if
(
code
!=
0
)
{
printf
(
"error occurs:%s
\n
"
,
tmq_err2str
(
code
));
tmq_free_assignment
(
pAssign
);
tmq_consumer_close
(
tmq
);
taos_close
(
pConn
);
fprintf
(
stderr
,
"%d msg consumed, include %d rows
\n
"
,
msgCnt
,
totalRows
);
return
;
}
for
(
int
i
=
0
;
i
<
numOfAssign
;
i
++
){
printf
(
"assign i:%d, vgId:%d, offset:%lld, start:%lld, end:%lld
\n
"
,
i
,
pAssign
[
i
].
vgId
,
pAssign
[
i
].
currentOffset
,
pAssign
[
i
].
begin
,
pAssign
[
i
].
end
);
int64_t
position
=
tmq_position
(
tmq
,
topicName
,
pAssign
[
i
].
vgId
);
printf
(
"position vgId:%d, position:%lld
\n
"
,
pAssign
[
i
].
vgId
,
position
);
tmq_offset_seek
(
tmq
,
topicName
,
pAssign
[
i
].
vgId
,
1
);
position
=
tmq_position
(
tmq
,
topicName
,
pAssign
[
i
].
vgId
);
printf
(
"after seek 100, position vgId:%d, position:%lld
\n
"
,
pAssign
[
i
].
vgId
,
position
);
}
while
(
1
)
{
printf
(
"start to poll
\n
"
);
TAOS_RES
*
pRes
=
tmq_consumer_poll
(
tmq
,
timeout
);
if
(
pRes
)
{
printSubResults
(
pRes
,
&
totalRows
);
}
else
{
break
;
}
tmq_commit_sync
(
tmq
,
pRes
);
for
(
int
i
=
0
;
i
<
numOfAssign
;
i
++
)
{
int64_t
committed
=
tmq_committed
(
tmq
,
topicName
,
pAssign
[
i
].
vgId
);
printf
(
"committed vgId:%d, committed:%lld
\n
"
,
pAssign
[
i
].
vgId
,
committed
);
}
if
(
pRes
!=
NULL
)
{
taos_free_result
(
pRes
);
}
// tmq_offset_seek(tmq, "tp", pAssign[0].vgId, pAssign[0].begin);
}
tmq_free_assignment
(
pAssign
);
tmq_consumer_close
(
tmq
);
taos_close
(
pConn
);
fprintf
(
stderr
,
"%d msg consumed, include %d rows
\n
"
,
msgCnt
,
totalRows
);
}
TEST
(
clientCase
,
td_25129
)
{
// taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg");
...
...
source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
浏览文件 @
5cb35f2f
...
...
@@ -732,6 +732,7 @@ SArray *vmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TMQ_CONSUME
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TMQ_CONSUME_PUSH
,
vmPutMsgToQueryQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TMQ_VG_WALINFO
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_TMQ_VG_COMMITTEDINFO
,
vmPutMsgToFetchQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_DELETE
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_BATCH_DEL
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_COMMIT
,
vmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
5cb35f2f
...
...
@@ -232,6 +232,7 @@ int32_t tqProcessSeekReq(STQ* pTq, SRpcMsg* pMsg);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessPollPush
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessVgWalInfoReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessVgCommittedInfoReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
// tq-stream
int32_t
tqProcessTaskDeployReq
(
STQ
*
pTq
,
int64_t
version
,
char
*
msg
,
int32_t
msgLen
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
5cb35f2f
...
...
@@ -578,6 +578,49 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
return
code
;
}
int32_t
tqProcessVgCommittedInfoReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
void
*
data
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
len
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
SMqVgOffset
vgOffset
=
{
0
};
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
data
,
len
);
if
(
tDecodeMqVgOffset
(
&
decoder
,
&
vgOffset
)
<
0
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tDecoderClear
(
&
decoder
);
STqOffset
*
pOffset
=
&
vgOffset
.
offset
;
STqOffset
*
pSavedOffset
=
tqOffsetRead
(
pTq
->
pOffsetStore
,
pOffset
->
subKey
);
if
(
pSavedOffset
==
NULL
)
{
return
TSDB_CODE_TMQ_NO_COMMITTED
;
}
vgOffset
.
offset
=
*
pSavedOffset
;
int32_t
code
=
0
;
tEncodeSize
(
tEncodeMqVgOffset
,
&
vgOffset
,
len
,
code
);
if
(
code
<
0
)
{
return
TSDB_CODE_INVALID_PARA
;
}
void
*
buf
=
taosMemoryCalloc
(
1
,
len
);
if
(
buf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SEncoder
encoder
;
tEncoderInit
(
&
encoder
,
buf
,
len
);
tEncodeMqVgOffset
(
&
encoder
,
&
vgOffset
);
tEncoderClear
(
&
encoder
);
SRpcMsg
rsp
=
{.
info
=
pMsg
->
info
,
.
pCont
=
buf
,
.
contLen
=
len
,
.
code
=
0
};
tmsgSendRsp
(
&
rsp
);
return
0
;
}
int32_t
tqProcessVgWalInfoReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
SMqPollReq
req
=
{
0
};
if
(
tDeserializeSMqPollReq
(
pMsg
->
pCont
,
pMsg
->
contLen
,
&
req
)
<
0
)
{
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
5cb35f2f
...
...
@@ -462,7 +462,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
}
break
;
case
TDMT_VND_TMQ_COMMIT_OFFSET
:
if
(
tqProcessOffsetCommitReq
(
pVnode
->
pTq
,
ver
,
pReq
,
pMsg
->
contLen
-
sizeof
(
SMsgHead
)
)
<
0
)
{
if
(
tqProcessOffsetCommitReq
(
pVnode
->
pTq
,
ver
,
pReq
,
len
)
<
0
)
{
goto
_err
;
}
break
;
...
...
@@ -638,6 +638,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
// return tqProcessPollReq(pVnode->pTq, pMsg);
case
TDMT_VND_TMQ_VG_WALINFO
:
return
tqProcessVgWalInfoReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_TMQ_VG_COMMITTEDINFO
:
return
tqProcessVgCommittedInfoReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_TMQ_SEEK
:
return
tqProcessSeekReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_STREAM_TASK_RUN
:
...
...
source/util/src/terror.c
浏览文件 @
5cb35f2f
...
...
@@ -633,6 +633,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SCALAR_CONVERT_ERROR, "Cannot convert to s
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_INVALID_MSG
,
"Invalid message"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_NEED_INITIALIZED
,
"Assignment or poll interface need to be called first"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_SNAPSHOT_ERROR
,
"Can not operate in snapshot mode"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_NO_COMMITTED
,
"No committed info"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_VERSION_OUT_OF_RANGE
,
"Offset out of range"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_INVALID_VGID
,
"VgId does not belong to this consumer"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_TMQ_INVALID_TOPIC
,
"Topic does not belong to this consumer"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录