Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bb58ec1e
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb58ec1e
编写于
7月 16, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(tmq): support background heartbeat
上级
280ed4f6
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
436 addition
and
468 deletion
+436
-468
include/common/tmsg.h
include/common/tmsg.h
+37
-105
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+43
-53
source/client/src/tmq.c
source/client/src/tmq.c
+317
-246
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+35
-2
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+2
-62
未找到文件。
include/common/tmsg.h
浏览文件 @
bb58ec1e
...
...
@@ -75,13 +75,18 @@ typedef uint16_t tmsg_t;
#define TSDB_IE_TYPE_DNODE_EXT 6
#define TSDB_IE_TYPE_DNODE_STATE 7
enum
{
CONN_TYPE__QUERY
=
1
,
CONN_TYPE__TMQ
,
CONN_TYPE__UDFD
,
CONN_TYPE__MAX
};
enum
{
CONN_TYPE__QUERY
=
1
,
CONN_TYPE__TMQ
,
CONN_TYPE__UDFD
,
CONN_TYPE__MAX
,
};
enum
{
HEARTBEAT_KEY_USER_AUTHINFO
=
1
,
HEARTBEAT_KEY_DBINFO
,
HEARTBEAT_KEY_STBINFO
,
HEARTBEAT_KEY_
MQ_TMP
,
HEARTBEAT_KEY_
TMQ
,
};
typedef
enum
_mgmt_table
{
...
...
@@ -2145,6 +2150,15 @@ typedef struct {
char
cgroup
[
TSDB_CGROUP_LEN
];
}
SMqAskEpReq
;
typedef
struct
{
int64_t
consumerId
;
int32_t
epoch
;
}
SMqHbReq
;
typedef
struct
{
int8_t
reserved
;
}
SMqHbRsp
;
typedef
struct
{
int32_t
key
;
int32_t
valueLen
;
...
...
@@ -2333,29 +2347,30 @@ static FORCE_INLINE int32_t tDecodeSClientHbKey(SDecoder* pDecoder, SClientHbKey
return
0
;
}
typedef
struct
SMqHbVgInfo
{
typedef
struct
{
int32_t
vgId
;
}
SMqHbVgInfo
;
// TODO stas
}
SMqReportVgInfo
;
static
FORCE_INLINE
int32_t
taosEncodeSMqVgInfo
(
void
**
buf
,
const
SMq
Hb
VgInfo
*
pVgInfo
)
{
static
FORCE_INLINE
int32_t
taosEncodeSMqVgInfo
(
void
**
buf
,
const
SMq
Report
VgInfo
*
pVgInfo
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pVgInfo
->
vgId
);
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSMqVgInfo
(
void
*
buf
,
SMq
Hb
VgInfo
*
pVgInfo
)
{
static
FORCE_INLINE
void
*
taosDecodeSMqVgInfo
(
void
*
buf
,
SMq
Report
VgInfo
*
pVgInfo
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pVgInfo
->
vgId
);
return
buf
;
}
typedef
struct
SMqHbTopicInfo
{
typedef
struct
{
int32_t
epoch
;
int64_t
topicUid
;
char
name
[
TSDB_TOPIC_FNAME_LEN
];
SArray
*
pVgInfo
;
// SArray<SMqHbVgInfo>
}
SMq
Hb
TopicInfo
;
}
SMqTopicInfo
;
static
FORCE_INLINE
int32_t
taosEncodeSMq
HbTopicInfoMsg
(
void
**
buf
,
const
SMqHb
TopicInfo
*
pTopicInfo
)
{
static
FORCE_INLINE
int32_t
taosEncodeSMq
TopicInfoMsg
(
void
**
buf
,
const
SMq
TopicInfo
*
pTopicInfo
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pTopicInfo
->
epoch
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pTopicInfo
->
topicUid
);
...
...
@@ -2363,35 +2378,35 @@ static FORCE_INLINE int32_t taosEncodeSMqHbTopicInfoMsg(void** buf, const SMqHbT
int32_t
sz
=
taosArrayGetSize
(
pTopicInfo
->
pVgInfo
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMq
HbVgInfo
*
pVgInfo
=
(
SMqHb
VgInfo
*
)
taosArrayGet
(
pTopicInfo
->
pVgInfo
,
i
);
SMq
ReportVgInfo
*
pVgInfo
=
(
SMqReport
VgInfo
*
)
taosArrayGet
(
pTopicInfo
->
pVgInfo
,
i
);
tlen
+=
taosEncodeSMqVgInfo
(
buf
,
pVgInfo
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSMq
HbTopicInfoMsg
(
void
*
buf
,
SMqHb
TopicInfo
*
pTopicInfo
)
{
static
FORCE_INLINE
void
*
taosDecodeSMq
TopicInfoMsg
(
void
*
buf
,
SMq
TopicInfo
*
pTopicInfo
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pTopicInfo
->
epoch
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pTopicInfo
->
topicUid
);
buf
=
taosDecodeStringTo
(
buf
,
pTopicInfo
->
name
);
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pTopicInfo
->
pVgInfo
=
taosArrayInit
(
sz
,
sizeof
(
SMq
Hb
VgInfo
));
pTopicInfo
->
pVgInfo
=
taosArrayInit
(
sz
,
sizeof
(
SMq
Report
VgInfo
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMq
Hb
VgInfo
vgInfo
;
SMq
Report
VgInfo
vgInfo
;
buf
=
taosDecodeSMqVgInfo
(
buf
,
&
vgInfo
);
taosArrayPush
(
pTopicInfo
->
pVgInfo
,
&
vgInfo
);
}
return
buf
;
}
typedef
struct
SMqHbMsg
{
typedef
struct
{
int32_t
status
;
// ask hb endpoint
int32_t
epoch
;
int64_t
consumerId
;
SArray
*
pTopics
;
// SArray<SMqHbTopicInfo>
}
SMq
HbMsg
;
}
SMq
ReportReq
;
static
FORCE_INLINE
int32_t
taosEncodeSMq
Msg
(
void
**
buf
,
const
SMqHbMsg
*
pMsg
)
{
static
FORCE_INLINE
int32_t
taosEncodeSMq
ReportMsg
(
void
**
buf
,
const
SMqReportReq
*
pMsg
)
{
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI32
(
buf
,
pMsg
->
status
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pMsg
->
epoch
);
...
...
@@ -2399,22 +2414,22 @@ static FORCE_INLINE int32_t taosEncodeSMqMsg(void** buf, const SMqHbMsg* pMsg) {
int32_t
sz
=
taosArrayGetSize
(
pMsg
->
pTopics
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMq
HbTopicInfo
*
topicInfo
=
(
SMqHb
TopicInfo
*
)
taosArrayGet
(
pMsg
->
pTopics
,
i
);
tlen
+=
taosEncodeSMq
Hb
TopicInfoMsg
(
buf
,
topicInfo
);
SMq
TopicInfo
*
topicInfo
=
(
SMq
TopicInfo
*
)
taosArrayGet
(
pMsg
->
pTopics
,
i
);
tlen
+=
taosEncodeSMqTopicInfoMsg
(
buf
,
topicInfo
);
}
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeSMq
Msg
(
void
*
buf
,
SMqHbMsg
*
pMsg
)
{
static
FORCE_INLINE
void
*
taosDecodeSMq
ReportMsg
(
void
*
buf
,
SMqReportReq
*
pMsg
)
{
buf
=
taosDecodeFixedI32
(
buf
,
&
pMsg
->
status
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pMsg
->
epoch
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pMsg
->
consumerId
);
int32_t
sz
;
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pMsg
->
pTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMq
Hb
TopicInfo
));
pMsg
->
pTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqTopicInfo
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMq
Hb
TopicInfo
topicInfo
;
buf
=
taosDecodeSMq
Hb
TopicInfoMsg
(
buf
,
&
topicInfo
);
SMqTopicInfo
topicInfo
;
buf
=
taosDecodeSMqTopicInfoMsg
(
buf
,
&
topicInfo
);
taosArrayPush
(
pMsg
->
pTopics
,
&
topicInfo
);
}
return
buf
;
...
...
@@ -2919,89 +2934,6 @@ typedef struct {
int32_t
tEncodeSMqDataRsp
(
SEncoder
*
pEncoder
,
const
SMqDataRsp
*
pRsp
);
int32_t
tDecodeSMqDataRsp
(
SDecoder
*
pDecoder
,
SMqDataRsp
*
pRsp
);
#if 0
typedef struct {
SMqRspHead head;
int64_t reqOffset;
int64_t rspOffset;
int32_t skipLogNum;
int32_t blockNum;
int8_t withTbName;
int8_t withSchema;
SArray* blockDataLen; // SArray<int32_t>
SArray* blockData; // SArray<SRetrieveTableRsp*>
SArray* blockTbName; // SArray<char*>
SArray* blockSchema; // SArray<SSchemaWrapper>
} SMqDataBlkRsp;
static FORCE_INLINE int32_t tEncodeSMqDataBlkRsp(void** buf, const SMqDataBlkRsp* pRsp) {
int32_t tlen = 0;
tlen += taosEncodeFixedI64(buf, pRsp->reqOffset);
tlen += taosEncodeFixedI64(buf, pRsp->rspOffset);
tlen += taosEncodeFixedI32(buf, pRsp->skipLogNum);
tlen += taosEncodeFixedI32(buf, pRsp->blockNum);
if (pRsp->blockNum != 0) {
tlen += taosEncodeFixedI8(buf, pRsp->withTbName);
tlen += taosEncodeFixedI8(buf, pRsp->withSchema);
for (int32_t i = 0; i < pRsp->blockNum; i++) {
int32_t bLen = *(int32_t*)taosArrayGet(pRsp->blockDataLen, i);
void* data = taosArrayGetP(pRsp->blockData, i);
tlen += taosEncodeFixedI32(buf, bLen);
tlen += taosEncodeBinary(buf, data, bLen);
if (pRsp->withSchema) {
SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRsp->blockSchema, i);
tlen += taosEncodeSSchemaWrapper(buf, pSW);
}
if (pRsp->withTbName) {
char* tbName = (char*)taosArrayGetP(pRsp->blockTbName, i);
tlen += taosEncodeString(buf, tbName);
}
}
}
return tlen;
}
static FORCE_INLINE void* tDecodeSMqDataBlkRsp(const void* buf, SMqDataBlkRsp* pRsp) {
buf = taosDecodeFixedI64(buf, &pRsp->reqOffset);
buf = taosDecodeFixedI64(buf, &pRsp->rspOffset);
buf = taosDecodeFixedI32(buf, &pRsp->skipLogNum);
buf = taosDecodeFixedI32(buf, &pRsp->blockNum);
if (pRsp->blockNum != 0) {
pRsp->blockData = taosArrayInit(pRsp->blockNum, sizeof(void*));
pRsp->blockDataLen = taosArrayInit(pRsp->blockNum, sizeof(int32_t));
buf = taosDecodeFixedI8(buf, &pRsp->withTbName);
buf = taosDecodeFixedI8(buf, &pRsp->withSchema);
if (pRsp->withTbName) {
pRsp->blockTbName = taosArrayInit(pRsp->blockNum, sizeof(void*));
}
if (pRsp->withSchema) {
pRsp->blockSchema = taosArrayInit(pRsp->blockNum, sizeof(void*));
}
for (int32_t i = 0; i < pRsp->blockNum; i++) {
int32_t bLen = 0;
void* data = NULL;
buf = taosDecodeFixedI32(buf, &bLen);
buf = taosDecodeBinary(buf, &data, bLen);
taosArrayPush(pRsp->blockDataLen, &bLen);
taosArrayPush(pRsp->blockData, &data);
if (pRsp->withSchema) {
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
buf = taosDecodeSSchemaWrapper(buf, pSW);
taosArrayPush(pRsp->blockSchema, &pSW);
}
if (pRsp->withTbName) {
char* name = NULL;
buf = taosDecodeString(buf, &name);
taosArrayPush(pRsp->blockTbName, &name);
}
}
}
return (void*)buf;
}
#endif
typedef
struct
{
SMqRspHead
head
;
char
cgroup
[
TSDB_CGROUP_LEN
];
...
...
include/common/tmsgdef.h
浏览文件 @
bb58ec1e
...
...
@@ -144,6 +144,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_ASK_EP
,
"ask-ep"
,
SMqAskEpReq
,
SMqAskEpRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_LOST
,
"consumer-lost"
,
SMqConsumerLostMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_CONSUMER_RECOVER
,
"consumer-recover"
,
SMqConsumerRecoverMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_HB
,
"consumer-hb"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DO_REBALANCE
,
"do-rebalance"
,
SMqDoRebalanceMsg
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_DROP_CGROUP
,
"drop-cgroup"
,
SMqDropCGroupReq
,
SMqDropCGroupRsp
)
TD_DEF_MSG_TYPE
(
TDMT_MND_MQ_COMMIT_OFFSET
,
"mnode-commit-offset"
,
SMqCMCommitOffsetReq
,
SMqCMCommitOffsetRsp
)
...
...
source/client/src/clientHb.c
浏览文件 @
bb58ec1e
...
...
@@ -24,9 +24,15 @@ static SClientHbMgr clientHbMgr = {0};
static
int32_t
hbCreateThread
();
static
void
hbStopThread
();
static
int32_t
hbMqHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
return
0
;
}
static
int32_t
hbMqHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
//
return
0
;
}
static
int32_t
hbMqHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
return
0
;
}
static
int32_t
hbMqHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
//
return
0
;
}
static
int32_t
hbProcessUserAuthInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
int32_t
code
=
0
;
...
...
@@ -70,7 +76,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
if
(
NULL
==
vgInfo
)
{
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
vgInfo
->
vgVersion
=
rsp
->
vgVersion
;
vgInfo
->
hashMethod
=
rsp
->
hashMethod
;
vgInfo
->
vgHash
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
...
...
@@ -156,18 +162,18 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
STscObj
*
pTscObj
=
(
STscObj
*
)
acquireTscObj
(
pRsp
->
connKey
.
tscRid
);
if
(
NULL
==
pTscObj
)
{
tscDebug
(
"tscObj rid %"
PRIx64
" not exist"
,
pRsp
->
connKey
.
tscRid
);
}
else
{
}
else
{
if
(
pRsp
->
query
->
totalDnodes
>
1
&&
!
isEpsetEqual
(
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
,
&
pRsp
->
query
->
epSet
))
{
SEpSet
*
pOrig
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
SEp
*
pOrigEp
=
&
pOrig
->
eps
[
pOrig
->
inUse
];
SEp
*
pNewEp
=
&
pRsp
->
query
->
epSet
.
eps
[
pRsp
->
query
->
epSet
.
inUse
];
tscDebug
(
"mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in hb"
,
pOrig
->
inUse
,
pOrig
->
numOfEps
,
pOrigEp
->
fqdn
,
pOrigEp
->
port
,
pRsp
->
query
->
epSet
.
inUse
,
pRsp
->
query
->
epSet
.
numOfEps
,
pNewEp
->
fqdn
,
pNewEp
->
port
);
SEpSet
*
pOrig
=
&
pTscObj
->
pAppInfo
->
mgmtEp
.
epSet
;
SEp
*
pOrigEp
=
&
pOrig
->
eps
[
pOrig
->
inUse
];
SEp
*
pNewEp
=
&
pRsp
->
query
->
epSet
.
eps
[
pRsp
->
query
->
epSet
.
inUse
];
tscDebug
(
"mnode epset updated from %d/%d=>%s:%d to %d/%d=>%s:%d in hb"
,
pOrig
->
inUse
,
pOrig
->
numOfEps
,
pOrigEp
->
fqdn
,
pOrigEp
->
port
,
pRsp
->
query
->
epSet
.
inUse
,
pRsp
->
query
->
epSet
.
numOfEps
,
pNewEp
->
fqdn
,
pNewEp
->
port
);
updateEpSet_s
(
&
pTscObj
->
pAppInfo
->
mgmtEp
,
&
pRsp
->
query
->
epSet
);
}
pTscObj
->
pAppInfo
->
totalDnodes
=
pRsp
->
query
->
totalDnodes
;
pTscObj
->
pAppInfo
->
onlineDnodes
=
pRsp
->
query
->
onlineDnodes
;
pTscObj
->
connId
=
pRsp
->
query
->
connId
;
...
...
@@ -263,13 +269,13 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) {
}
static
int32_t
hbAsyncCallBack
(
void
*
param
,
SDataBuf
*
pMsg
,
int32_t
code
)
{
static
int32_t
emptyRspNum
=
0
;
static
int32_t
emptyRspNum
=
0
;
char
*
key
=
(
char
*
)
param
;
SClientHbBatchRsp
pRsp
=
{
0
};
if
(
TSDB_CODE_SUCCESS
==
code
)
{
tDeserializeSClientHbBatchRsp
(
pMsg
->
pData
,
pMsg
->
len
,
&
pRsp
);
}
int32_t
rspNum
=
taosArrayGetSize
(
pRsp
.
rsps
);
taosThreadMutexLock
(
&
appInfo
.
mutex
);
...
...
@@ -373,7 +379,7 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
releaseTscObj
(
connKey
->
tscRid
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
hbBasic
->
connId
=
pTscObj
->
connId
;
int32_t
numOfQueries
=
pTscObj
->
pRequests
?
taosHashGetSize
(
pTscObj
->
pRequests
)
:
0
;
...
...
@@ -392,7 +398,6 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) {
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
int32_t
code
=
hbBuildQueryDesc
(
hbBasic
,
pTscObj
);
if
(
code
)
{
releaseTscObj
(
connKey
->
tscRid
);
...
...
@@ -436,13 +441,12 @@ int32_t hbGetExpiredUserInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S
if
(
NULL
==
req
->
info
)
{
req
->
info
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
}
taosHashPut
(
req
->
info
,
&
kv
.
key
,
sizeof
(
kv
.
key
),
&
kv
,
sizeof
(
kv
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
hbGetExpiredDBInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
SDbVgVersion
*
dbs
=
NULL
;
uint32_t
dbNum
=
0
;
...
...
@@ -483,8 +487,8 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
int32_t
hbGetExpiredStbInfo
(
SClientHbKey
*
connKey
,
struct
SCatalog
*
pCatalog
,
SClientHbReq
*
req
)
{
SSTableVersion
*
stbs
=
NULL
;
uint32_t
stbNum
=
0
;
int32_t
code
=
0
;
uint32_t
stbNum
=
0
;
int32_t
code
=
0
;
code
=
catalogGetExpiredSTables
(
pCatalog
,
&
stbs
,
&
stbNum
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
...
@@ -521,20 +525,19 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
}
int32_t
hbGetAppInfo
(
int64_t
clusterId
,
SClientHbReq
*
req
)
{
SAppHbReq
*
pApp
=
taosHashGet
(
clientHbMgr
.
appSummary
,
&
clusterId
,
sizeof
(
clusterId
));
SAppHbReq
*
pApp
=
taosHashGet
(
clientHbMgr
.
appSummary
,
&
clusterId
,
sizeof
(
clusterId
));
if
(
NULL
!=
pApp
)
{
memcpy
(
&
req
->
app
,
pApp
,
sizeof
(
*
pApp
));
}
else
{
memset
(
&
req
->
app
.
summary
,
0
,
sizeof
(
req
->
app
.
summary
));
req
->
app
.
pid
=
taosGetPId
();
req
->
app
.
appId
=
clientHbMgr
.
appId
;
taosGetAppName
(
req
->
app
.
name
,
NULL
);
taosGetAppName
(
req
->
app
.
name
,
NULL
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
hbQueryHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
int64_t
*
clusterId
=
(
int64_t
*
)
param
;
struct
SCatalog
*
pCatalog
=
NULL
;
...
...
@@ -567,7 +570,8 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
return
TSDB_CODE_SUCCESS
;
}
void
hbMgrInitMqHbHandle
()
{
static
FORCE_INLINE
void
hbMgrInitHandle
()
{
// init all handle
clientHbMgr
.
reqHandle
[
CONN_TYPE__QUERY
]
=
hbQueryHbReqHandle
;
clientHbMgr
.
reqHandle
[
CONN_TYPE__TMQ
]
=
hbMqHbReqHandle
;
...
...
@@ -575,11 +579,6 @@ void hbMgrInitMqHbHandle() {
clientHbMgr
.
rspHandle
[
CONN_TYPE__TMQ
]
=
hbMqHbRspHandle
;
}
static
FORCE_INLINE
void
hbMgrInitHandle
()
{
// init all handle
hbMgrInitMqHbHandle
();
}
SClientHbBatchReq
*
hbGatherAllInfo
(
SAppHbMgr
*
pAppHbMgr
)
{
SClientHbBatchReq
*
pBatchReq
=
taosMemoryCalloc
(
1
,
sizeof
(
SClientHbBatchReq
));
if
(
pBatchReq
==
NULL
)
{
...
...
@@ -602,7 +601,7 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
continue
;
}
//hbClearClientHbReq(pOneReq);
//
hbClearClientHbReq(pOneReq);
pIter
=
taosHashIterate
(
pAppHbMgr
->
activeInfo
,
pIter
);
}
...
...
@@ -615,11 +614,9 @@ SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) {
return
pBatchReq
;
}
void
hbThreadFuncUnexpectedStopped
(
void
)
{
atomic_store_8
(
&
clientHbMgr
.
threadStop
,
2
);
}
void
hbThreadFuncUnexpectedStopped
(
void
)
{
atomic_store_8
(
&
clientHbMgr
.
threadStop
,
2
);
}
void
hbMergeSummary
(
SAppClusterSummary
*
dst
,
SAppClusterSummary
*
src
)
{
void
hbMergeSummary
(
SAppClusterSummary
*
dst
,
SAppClusterSummary
*
src
)
{
dst
->
numOfInsertsReq
+=
src
->
numOfInsertsReq
;
dst
->
numOfInsertRows
+=
src
->
numOfInsertRows
;
dst
->
insertElapsedTime
+=
src
->
insertElapsedTime
;
...
...
@@ -633,7 +630,7 @@ void hbMergeSummary(SAppClusterSummary* dst, SAppClusterSummary* src) {
int32_t
hbGatherAppInfo
(
void
)
{
SAppHbReq
req
=
{
0
};
int
sz
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
);
int
sz
=
taosArrayGetSize
(
clientHbMgr
.
appHbMgrs
);
if
(
sz
>
0
)
{
req
.
pid
=
taosGetPId
();
req
.
appId
=
clientHbMgr
.
appId
;
...
...
@@ -641,11 +638,11 @@ int32_t hbGatherAppInfo(void) {
}
taosHashClear
(
clientHbMgr
.
appSummary
);
for
(
int32_t
i
=
0
;
i
<
sz
;
++
i
)
{
SAppHbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
uint64_t
clusterId
=
pAppHbMgr
->
pAppInstInfo
->
clusterId
;
SAppHbReq
*
pApp
=
taosHashGet
(
clientHbMgr
.
appSummary
,
&
clusterId
,
sizeof
(
clusterId
));
uint64_t
clusterId
=
pAppHbMgr
->
pAppInstInfo
->
clusterId
;
SAppHbReq
*
pApp
=
taosHashGet
(
clientHbMgr
.
appSummary
,
&
clusterId
,
sizeof
(
clusterId
));
if
(
NULL
==
pApp
)
{
memcpy
(
&
req
.
summary
,
&
pAppHbMgr
->
pAppInstInfo
->
summary
,
sizeof
(
req
.
summary
));
req
.
startTime
=
pAppHbMgr
->
startTime
;
...
...
@@ -654,7 +651,7 @@ int32_t hbGatherAppInfo(void) {
if
(
pAppHbMgr
->
startTime
<
pApp
->
startTime
)
{
pApp
->
startTime
=
pAppHbMgr
->
startTime
;
}
hbMergeSummary
(
&
pApp
->
summary
,
&
pAppHbMgr
->
pAppInstInfo
->
summary
);
}
}
...
...
@@ -662,7 +659,6 @@ int32_t hbGatherAppInfo(void) {
return
TSDB_CODE_SUCCESS
;
}
static
void
*
hbThreadFunc
(
void
*
param
)
{
setThreadName
(
"hb"
);
#ifdef WINDOWS
...
...
@@ -681,7 +677,7 @@ static void *hbThreadFunc(void *param) {
if
(
sz
>
0
)
{
hbGatherAppInfo
();
}
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
SAppHbMgr
*
pAppHbMgr
=
taosArrayGetP
(
clientHbMgr
.
appHbMgrs
,
i
);
...
...
@@ -698,7 +694,6 @@ static void *hbThreadFunc(void *param) {
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tFreeClientHbBatchReq
(
pReq
);
//hbClearReqInfo(pAppHbMgr);
break
;
}
...
...
@@ -708,7 +703,6 @@ static void *hbThreadFunc(void *param) {
if
(
pInfo
==
NULL
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tFreeClientHbBatchReq
(
pReq
);
//hbClearReqInfo(pAppHbMgr);
taosMemoryFree
(
buf
);
break
;
}
...
...
@@ -725,7 +719,6 @@ static void *hbThreadFunc(void *param) {
SEpSet
epSet
=
getEpSet_s
(
&
pAppInstInfo
->
mgmtEp
);
asyncSendMsgToServer
(
pAppInstInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
pInfo
);
tFreeClientHbBatchReq
(
pReq
);
//hbClearReqInfo(pAppHbMgr);
atomic_add_fetch_32
(
&
pAppHbMgr
->
reportCnt
,
1
);
}
...
...
@@ -759,7 +752,7 @@ static void hbStopThread() {
return
;
}
taosThreadJoin
(
clientHbMgr
.
thread
,
NULL
);
taosThreadJoin
(
clientHbMgr
.
thread
,
NULL
);
tscDebug
(
"hb thread stopped"
);
}
...
...
@@ -808,7 +801,7 @@ void hbFreeAppHbMgr(SAppHbMgr *pTarget) {
}
taosHashCleanup
(
pTarget
->
activeInfo
);
pTarget
->
activeInfo
=
NULL
;
taosMemoryFree
(
pTarget
->
key
);
taosMemoryFree
(
pTarget
);
}
...
...
@@ -843,7 +836,7 @@ int hbMgrInit() {
clientHbMgr
.
appId
=
tGenIdPI64
();
tscDebug
(
"app %"
PRIx64
" initialized"
,
clientHbMgr
.
appId
);
clientHbMgr
.
appSummary
=
taosHashInit
(
10
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
clientHbMgr
.
appHbMgrs
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosThreadMutexInit
(
&
clientHbMgr
.
lock
,
NULL
);
...
...
@@ -881,7 +874,7 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, int64_t clust
SClientHbReq
hbReq
=
{
0
};
hbReq
.
connKey
=
connKey
;
hbReq
.
clusterId
=
clusterId
;
//hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
//
hbReq.info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
taosHashPut
(
pAppHbMgr
->
activeInfo
,
&
connKey
,
sizeof
(
SClientHbKey
),
&
hbReq
,
sizeof
(
SClientHbReq
));
...
...
@@ -896,12 +889,9 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int64_t tscRefId, int64_t clusterId, in
};
switch
(
connType
)
{
case
CONN_TYPE__QUERY
:
{
case
CONN_TYPE__QUERY
:
case
CONN_TYPE__TMQ
:
return
hbRegisterConnImpl
(
pAppHbMgr
,
connKey
,
clusterId
);
}
case
CONN_TYPE__TMQ
:
{
return
0
;
}
default:
return
0
;
}
...
...
source/client/src/tmq.c
浏览文件 @
bb58ec1e
此差异已折叠。
点击以展开。
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
bb58ec1e
...
...
@@ -196,6 +196,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_SUBSCRIBE
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_ASK_EP
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_HB
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_DROP_CGROUP_RSP
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
bb58ec1e
...
...
@@ -48,6 +48,7 @@ static void mndCancelGetNextConsumer(SMnode *pMnode, void *pIter);
static
int32_t
mndProcessSubscribeReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessAskEpReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessMqTimerMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerLostMsg
(
SRpcMsg
*
pMsg
);
static
int32_t
mndProcessConsumerRecoverMsg
(
SRpcMsg
*
pMsg
);
...
...
@@ -62,6 +63,7 @@ int32_t mndInitConsumer(SMnode *pMnode) {
.
deleteFp
=
(
SdbDeleteFp
)
mndConsumerActionDelete
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_SUBSCRIBE
,
mndProcessSubscribeReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_HB
,
mndProcessMqHbReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_ASK_EP
,
mndProcessAskEpReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_TIMER
,
mndProcessMqTimerMsg
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_CONSUMER_LOST
,
mndProcessConsumerLostMsg
);
...
...
@@ -255,6 +257,33 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
return
0
;
}
static
int32_t
mndProcessMqHbReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqHbReq
*
pReq
=
(
SMqHbReq
*
)
pMsg
->
pCont
;
int64_t
consumerId
=
be64toh
(
pReq
->
consumerId
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
atomic_store_32
(
&
pConsumer
->
hbStatus
,
0
);
int32_t
status
=
atomic_load_32
(
&
pConsumer
->
status
);
if
(
status
==
MQ_CONSUMER_STATUS__LOST_REBD
)
{
SMqConsumerRecoverMsg
*
pRecoverMsg
=
rpcMallocCont
(
sizeof
(
SMqConsumerRecoverMsg
));
pRecoverMsg
->
consumerId
=
consumerId
;
SRpcMsg
*
pRpcMsg
=
taosMemoryCalloc
(
1
,
sizeof
(
SRpcMsg
));
pRpcMsg
->
msgType
=
TDMT_MND_MQ_CONSUMER_RECOVER
;
pRpcMsg
->
pCont
=
pRecoverMsg
;
pRpcMsg
->
contLen
=
sizeof
(
SMqConsumerRecoverMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
pRpcMsg
);
}
mndReleaseConsumer
(
pMnode
,
pConsumer
);
return
0
;
}
static
int32_t
mndProcessAskEpReq
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMqAskEpReq
*
pReq
=
(
SMqAskEpReq
*
)
pMsg
->
pCont
;
...
...
@@ -262,19 +291,22 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
int64_t
consumerId
=
be64toh
(
pReq
->
consumerId
);
int32_t
epoch
=
ntohl
(
pReq
->
epoch
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pM
sg
->
info
.
node
,
consumerId
);
SMqConsumerObj
*
pConsumer
=
mndAcquireConsumer
(
pMnode
,
consumerId
);
if
(
pConsumer
==
NULL
)
{
terrno
=
TSDB_CODE_MND_CONSUMER_NOT_EXIST
;
return
-
1
;
}
ASSERT
(
strcmp
(
pReq
->
cgroup
,
pConsumer
->
cgroup
)
==
0
);
/*int32_t hbStatus = atomic_load_32(&pConsumer->hbStatus);*/
#if 1
atomic_store_32
(
&
pConsumer
->
hbStatus
,
0
);
#endif
// 1. check consumer status
int32_t
status
=
atomic_load_32
(
&
pConsumer
->
status
);
#if 0
if (status == MQ_CONSUMER_STATUS__LOST_REBD) {
SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg));
...
...
@@ -285,6 +317,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
pRpcMsg->contLen = sizeof(SMqConsumerRecoverMsg);
tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, pRpcMsg);
}
#endif
if
(
status
!=
MQ_CONSUMER_STATUS__READY
)
{
terrno
=
TSDB_CODE_MND_CONSUMER_NOT_READY
;
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
bb58ec1e
...
...
@@ -15,10 +15,10 @@
#define _DEFAULT_SOURCE
#include "mndProfile.h"
#include "mndPrivilege.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndPrivilege.h"
#include "mndQnode.h"
#include "mndShow.h"
#include "mndStb.h"
...
...
@@ -387,67 +387,7 @@ static void mndCancelGetNextApp(SMnode *pMnode, void *pIter) {
}
static
SClientHbRsp
*
mndMqHbBuildRsp
(
SMnode
*
pMnode
,
SClientHbReq
*
pReq
)
{
#if 0
SClientHbRsp* pRsp = taosMemoryMalloc(sizeof(SClientHbRsp));
if (pRsp == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
pRsp->connKey = pReq->connKey;
SMqHbBatchRsp batchRsp;
batchRsp.batchRsps = taosArrayInit(0, sizeof(SMqHbRsp));
if (batchRsp.batchRsps == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
SClientHbKey connKey = pReq->connKey;
SHashObj* pObj = pReq->info;
SKv* pKv = taosHashGet(pObj, "mq-tmp", strlen("mq-tmp") + 1);
if (pKv == NULL) {
taosMemoryFree(pRsp);
return NULL;
}
SMqHbMsg mqHb;
taosDecodeSMqMsg(pKv->value, &mqHb);
/*int64_t clientUid = htonl(pKv->value);*/
/*if (mqHb.epoch )*/
int sz = taosArrayGetSize(mqHb.pTopics);
SMqConsumerObj* pConsumer = mndAcquireConsumer(pMnode, mqHb.consumerId);
for (int i = 0; i < sz; i++) {
SMqHbOneTopicBatchRsp innerBatchRsp;
innerBatchRsp.rsps = taosArrayInit(sz, sizeof(SMqHbRsp));
if (innerBatchRsp.rsps == NULL) {
//TODO
terrno = TSDB_CODE_OUT_OF_MEMORY;
return NULL;
}
SMqHbTopicInfo* topicInfo = taosArrayGet(mqHb.pTopics, i);
SMqConsumerTopic* pConsumerTopic = taosHashGet(pConsumer->topicHash, topicInfo->name, strlen(topicInfo->name)+1);
if (pConsumerTopic->epoch != topicInfo->epoch) {
//add new vgids into rsp
int vgSz = taosArrayGetSize(topicInfo->pVgInfo);
for (int j = 0; j < vgSz; j++) {
SMqHbRsp innerRsp;
SMqHbVgInfo* pVgInfo = taosArrayGet(topicInfo->pVgInfo, i);
SVgObj* pVgObj = mndAcquireVgroup(pMnode, pVgInfo->vgId);
innerRsp.epSet = mndGetVgroupEpset(pMnode, pVgObj);
taosArrayPush(innerBatchRsp.rsps, &innerRsp);
}
}
taosArrayPush(batchRsp.batchRsps, &innerBatchRsp);
}
int32_t tlen = taosEncodeSMqHbBatchRsp(NULL, &batchRsp);
void* buf = taosMemoryMalloc(tlen);
if (buf == NULL) {
//TODO
return NULL;
}
void* abuf = buf;
taosEncodeSMqHbBatchRsp(&abuf, &batchRsp);
pRsp->body = buf;
pRsp->bodyLen = tlen;
return pRsp;
#endif
//
return
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录