TDengine/source/dnode/mnode/impl/src/mndStreamHb.c

75 lines
2.3 KiB
C
Raw Normal View History

2024-01-25 08:55:05 +00:00
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mndStream.h"
#include "mndTrans.h"
#include "mndMnode.h"
#include "tmisce.h"
2024-01-25 08:55:05 +00:00
2025-06-16 03:34:54 +00:00
void mndStreamHbSendRsp(SRpcHandleInfo *pRpcInfo, SRpcMsg* pRsp) {
tmsgSendRsp(pRsp);
2025-04-19 10:58:51 +00:00
pRpcInfo->handle = NULL; // disable auto rsp
}
2024-01-29 03:03:50 +00:00
2024-01-25 08:55:05 +00:00
int32_t mndProcessStreamHb(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
SStreamHbMsg req = {0};
2025-04-14 05:20:57 +00:00
SMStreamHbRspMsg rsp = {0};
int32_t code = 0;
2025-04-24 01:11:54 +00:00
int32_t lino = 0;
SDecoder decoder = {0};
2025-04-22 09:46:17 +00:00
char* msg = POINTER_SHIFT(pReq->pCont, sizeof(SStreamMsgGrpHeader));
int32_t len = pReq->contLen - sizeof(SStreamMsgGrpHeader);
int64_t currTs = taosGetTimestampMs();
2024-01-25 08:55:05 +00:00
2025-05-23 10:14:34 +00:00
mstDebug("start to process stream hb req msg");
2025-04-25 06:59:41 +00:00
2024-07-22 05:31:57 +00:00
if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
2025-04-22 09:46:17 +00:00
TAOS_CHECK_EXIT(msmHandleGrantExpired(pMnode));
2024-01-26 08:32:40 +00:00
}
2025-04-22 09:46:17 +00:00
tDecoderInit(&decoder, msg, len);
code = tDecodeStreamHbMsg(&decoder, &req);
if (code < 0) {
2025-05-23 10:14:34 +00:00
mstError("failed to decode stream hb msg, error:%s", tstrerror(terrno));
2024-05-07 15:43:21 +00:00
tCleanupStreamHbMsg(&req);
2024-01-25 08:55:05 +00:00
tDecoderClear(&decoder);
2025-04-22 09:46:17 +00:00
TAOS_CHECK_EXIT(TSDB_CODE_INVALID_MSG);
2024-01-25 08:55:05 +00:00
}
tDecoderClear(&decoder);
2025-05-23 10:14:34 +00:00
mstDebug("start to process grp %d stream-hb from dnode:%d, snodeId:%d, vgLeaders:%d, streamStatus:%d",
2025-04-24 01:11:54 +00:00
req.streamGId, req.dnodeId, req.snodeId, (int32_t)taosArrayGetSize(req.pVgLeaders), (int32_t)taosArrayGetSize(req.pStreamStatus));
2025-05-23 10:14:34 +00:00
rsp.streamGId = req.streamGId;
2025-06-16 03:34:54 +00:00
SRpcMsg rspMsg = {0};
2025-04-19 10:58:51 +00:00
2025-06-16 03:34:54 +00:00
(void)msmHandleStreamHbMsg(pMnode, currTs, &req, pReq, &rspMsg);
2025-04-22 09:46:17 +00:00
_exit:
2025-06-16 03:34:54 +00:00
if (code) {
msmEncodeStreamHbRsp(code, &pReq->info, &rsp, &rspMsg);
}
mndStreamHbSendRsp(&pReq->info, &rspMsg);
2025-04-29 00:37:37 +00:00
2025-05-23 10:14:34 +00:00
mstDebug("end to process stream hb req msg, code:%d", code);
2025-04-25 06:59:41 +00:00
2025-04-19 10:58:51 +00:00
return code;
}