qworker.h 3.1 KB
Newer Older
D
dapan1121 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

D
dapan1121 已提交
16 17
#ifndef _TD_QWORKER_H_
#define _TD_QWORKER_H_
D
dapan1121 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

H
Hongze Cheng 已提交
23
#include "executor.h"
S
Shengliang Guan 已提交
24
#include "tmsgcb.h"
D
dapan1121 已提交
25
#include "trpc.h"
D
dapan1121 已提交
26 27 28 29 30

enum {
  NODE_TYPE_VNODE = 1,
  NODE_TYPE_QNODE,
  NODE_TYPE_SNODE,
D
dapan1121 已提交
31
  NODE_TYPE_MNODE,
D
dapan1121 已提交
32
  NODE_TYPE_CLIENT,
D
dapan1121 已提交
33 34
};

D
dapan1121 已提交
35 36
typedef struct SQWorkerCfg {
  uint32_t maxSchedulerNum;
D
dapan1121 已提交
37
  uint32_t maxTaskNum;
D
dapan1121 已提交
38
  uint32_t maxSchTaskNum;
D
dapan1121 已提交
39 40 41
} SQWorkerCfg;

typedef struct {
D
dapan1121 已提交
42
  uint64_t cacheDataSize;
H
Hongze Cheng 已提交
43

D
dapan1121 已提交
44 45 46 47 48
  uint64_t queryProcessed;
  uint64_t cqueryProcessed;
  uint64_t fetchProcessed;
  uint64_t dropProcessed;
  uint64_t hbProcessed;
D
dapan1121 已提交
49
  uint64_t deleteProcessed;
H
Hongze Cheng 已提交
50

D
dapan1121 已提交
51
  uint64_t numOfQueryInQueue;
D
dapan1121 已提交
52
  uint64_t numOfFetchInQueue;
D
dapan1121 已提交
53 54
  uint64_t timeInQueryQueue;
  uint64_t timeInFetchQueue;
H
Hongze Cheng 已提交
55

D
dapan1121 已提交
56 57 58
  uint64_t numOfErrors;
} SQWorkerStat;

D
dapan1121 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
typedef struct SQWMsgInfo {
  int8_t taskType;
  int8_t explain;
  int8_t needFetch;
} SQWMsgInfo;

typedef struct SQWMsg {
  void          *node;
  int32_t        code;
  int32_t        msgType;
  void          *msg;
  int32_t        msgLen;
  SQWMsgInfo     msgInfo;
  SRpcHandleInfo connInfo;
} SQWMsg;

D
dapan1121 已提交
75
int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb);
D
dapan1121 已提交
76

D
dapan1121 已提交
77 78
int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg);

D
dapan1121 已提交
79 80
int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg);

D
dapan1121 已提交
81
int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
82

D
dapan1121 已提交
83
int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
84

D
dapan1121 已提交
85
int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
86

D
dapan1121 已提交
87
int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
S
Shengliang 已提交
88

D
dapan1121 已提交
89
int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
90

D
dapan1121 已提交
91
int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
92

D
dapan1121 已提交
93
int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts);
D
dapan1121 已提交
94

95
int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SDeleteRes *pRes);
D
dapan1121 已提交
96

H
Hongze Cheng 已提交
97
void qWorkerDestroy(void **qWorkerMgmt);
D
dapan1121 已提交
98

D
dapan1121 已提交
99
int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pStat);
D
dapan1121 已提交
100

H
Hongze Cheng 已提交
101 102
int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
                                 SQWMsg *qwMsg, SArray *explainRes);
D
dapan1121 已提交
103

H
Hongze Cheng 已提交
104 105
int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId,
                                 void **pRsp, SArray *explainRes);
D
dapan1121 已提交
106

D
dapan1121 已提交
107 108 109 110
#ifdef __cplusplus
}
#endif

D
dapan1121 已提交
111
#endif /*_TD_QWORKER_H_*/