TDengine/source/dnode/qnode/src/qnode.c

89 lines
2.9 KiB
C
Raw Normal View History

2021-09-22 08:29:27 +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/>.
2021-12-27 10:43:27 +00:00
*/
2022-03-21 11:08:25 +00:00
#include "executor.h"
2021-12-27 10:43:27 +00:00
#include "qndInt.h"
2022-03-09 08:13:46 +00:00
#include "query.h"
#include "qworker.h"
2021-12-27 10:43:27 +00:00
SQnode *qndOpen(const SQnodeOpt *pOption) {
SQnode *pQnode = calloc(1, sizeof(SQnode));
2022-03-07 11:37:17 +00:00
if (NULL == pQnode) {
qError("calloc SQnode failed");
return NULL;
}
2022-03-21 11:08:25 +00:00
if (qWorkerInit(NODE_TYPE_QNODE, pQnode->qndId, NULL, (void **)&pQnode->pQuery, &pOption->msgCb)) {
2022-03-07 11:37:17 +00:00
tfree(pQnode);
return NULL;
}
2022-03-21 11:08:25 +00:00
pQnode->msgCb = pOption->msgCb;
2021-12-27 10:43:27 +00:00
return pQnode;
}
2022-03-21 11:49:20 +00:00
void qndClose(SQnode *pQnode) {
2022-03-09 08:13:46 +00:00
qWorkerDestroy((void **)&pQnode->pQuery);
2022-03-07 11:37:17 +00:00
2022-03-21 11:49:20 +00:00
free(pQnode);
2022-03-07 11:37:17 +00:00
}
2021-12-27 10:43:27 +00:00
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { return 0; }
2022-03-21 11:49:20 +00:00
int32_t qndProcessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg) {
2022-03-07 11:37:17 +00:00
qTrace("message in query queue is processing");
SReadHandle handle = {0};
switch (pMsg->msgType) {
2022-03-21 11:49:20 +00:00
case TDMT_VND_QUERY: {
2022-03-07 11:37:17 +00:00
return qWorkerProcessQueryMsg(&handle, pQnode->pQuery, pMsg);
}
case TDMT_VND_QUERY_CONTINUE:
return qWorkerProcessCQueryMsg(&handle, pQnode->pQuery, pMsg);
default:
2022-03-09 08:13:46 +00:00
qError("unknown msg type:%d in query queue", pMsg->msgType);
2022-03-07 11:37:17 +00:00
return TSDB_CODE_VND_APP_ERROR;
}
}
2022-03-21 11:49:20 +00:00
int32_t qndProcessFetchMsg(SQnode *pQnode, SRpcMsg *pMsg) {
2022-03-07 11:37:17 +00:00
qTrace("message in fetch queue is processing");
switch (pMsg->msgType) {
case TDMT_VND_FETCH:
return qWorkerProcessFetchMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_FETCH_RSP:
return qWorkerProcessFetchRsp(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_RES_READY:
return qWorkerProcessReadyMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_TASKS_STATUS:
return qWorkerProcessStatusMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_CANCEL_TASK:
return qWorkerProcessCancelMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_DROP_TASK:
return qWorkerProcessDropMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_SHOW_TABLES:
return qWorkerProcessShowMsg(pQnode, pQnode->pQuery, pMsg);
case TDMT_VND_SHOW_TABLES_FETCH:
2022-03-21 11:49:20 +00:00
// return vnodeGetTableList(pQnode, pMsg);
2022-03-07 11:37:17 +00:00
case TDMT_VND_TABLE_META:
2022-03-21 11:49:20 +00:00
// return vnodeGetTableMeta(pQnode, pMsg);
2022-03-07 11:37:17 +00:00
case TDMT_VND_CONSUME:
2022-03-21 11:49:20 +00:00
// return tqProcessConsumeReq(pQnode->pTq, pMsg);
2022-03-07 11:37:17 +00:00
default:
2022-03-09 08:13:46 +00:00
qError("unknown msg type:%d in fetch queue", pMsg->msgType);
2022-03-07 11:37:17 +00:00
return TSDB_CODE_VND_APP_ERROR;
}
}