qnode.h 2.5 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
 * 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/>.
 */

#ifndef _TD_QNODE_H_
#define _TD_QNODE_H_

#ifdef __cplusplus
extern "C" {
#endif
S
Shengliang Guan 已提交
22 23 24 25

/* ------------------------ TYPES EXPOSED ------------------------ */
typedef struct SDnode SDnode;
typedef struct SQnode SQnode;
S
Shengliang Guan 已提交
26 27 28
typedef int32_t (*SendReqToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *pMsg);
typedef int32_t (*SendReqToMnodeFp)(SDnode *pDnode, struct SRpcMsg *pMsg);
typedef void (*SendRedirectRspFp)(SDnode *pDnode, struct SRpcMsg *pMsg);
D
dapan1121 已提交
29 30

typedef struct {
S
Shengliang Guan 已提交
31 32 33 34 35 36 37 38 39
  int64_t numOfStartTask;
  int64_t numOfStopTask;
  int64_t numOfRecvedFetch;
  int64_t numOfSentHb;
  int64_t numOfSentFetch;
  int64_t numOfTaskInQueue;
  int64_t numOfFetchInQueue;
  int64_t numOfErrors;
} SQnodeLoad;
D
dapan1121 已提交
40

S
Shengliang Guan 已提交
41
typedef struct {
S
Shengliang Guan 已提交
42
  int32_t           sver;
S
Shengliang Guan 已提交
43 44 45
  int32_t           dnodeId;
  int64_t           clusterId;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
46 47 48
  SendReqToDnodeFp  sendReqToDnodeFp;
  SendReqToMnodeFp  sendReqToMnodeFp;
  SendRedirectRspFp sendRedirectRspFp;
S
Shengliang Guan 已提交
49 50 51
} SQnodeOpt;

/* ------------------------ SQnode ------------------------ */
D
dapan1121 已提交
52
/**
S
Shengliang Guan 已提交
53 54 55 56
 * @brief Start one Qnode in Dnode.
 *
 * @param pOption Option of the qnode.
 * @return SQnode* The qnode object.
D
dapan1121 已提交
57
 */
S
Shengliang Guan 已提交
58
SQnode *qndOpen(const SQnodeOpt *pOption);
D
dapan1121 已提交
59 60

/**
S
Shengliang Guan 已提交
61
 * @brief Stop Qnode in Dnode.
D
dapan1121 已提交
62
 *
S
Shengliang Guan 已提交
63
 * @param pQnode The qnode object to close.
D
dapan1121 已提交
64
 */
S
Shengliang Guan 已提交
65
void qndClose(SQnode *pQnode);
D
dapan1121 已提交
66 67

/**
S
Shengliang Guan 已提交
68
 * @brief Get the statistical information of Qnode
D
dapan1121 已提交
69
 *
S
Shengliang Guan 已提交
70 71 72
 * @param pQnode The qnode object.
 * @param pLoad Statistics of the qnode.
 * @return int32_t 0 for success, -1 for failure.
D
dapan1121 已提交
73
 */
S
Shengliang Guan 已提交
74
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad);
D
dapan1121 已提交
75 76

/**
S
Shengliang Guan 已提交
77
 * @brief Process a query or fetch message.
S
Shengliang Guan 已提交
78 79 80 81 82
 *
 * @param pQnode The qnode object.
 * @param pMsg The request message
 * @param pRsp The response message
 * @return int32_t 0 for success, -1 for failure
D
dapan1121 已提交
83
 */
S
Shengliang Guan 已提交
84
int32_t qndProcessMsg(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
D
dapan1121 已提交
85

H
refact  
Hongze Cheng 已提交
86 87 88 89 90
#ifdef __cplusplus
}
#endif

#endif /*_TD_QNODE_H_*/