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 *rpcMsg);
typedef int32_t (*SendReqToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
typedef void (*SendRedirectRspFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
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 42 43
typedef struct {
  int32_t sver;
} SQnodeCfg;
D
dapan1121 已提交
44

S
Shengliang Guan 已提交
45 46 47 48 49
typedef struct {
  int32_t           dnodeId;
  int64_t           clusterId;
  SQnodeCfg         cfg;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
50 51 52
  SendReqToDnodeFp  sendReqToDnodeFp;
  SendReqToMnodeFp  sendReqToMnodeFp;
  SendRedirectRspFp sendRedirectRspFp;
S
Shengliang Guan 已提交
53 54 55
} SQnodeOpt;

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

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

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

/**
S
Shengliang Guan 已提交
81
 * @brief Process a query or fetch message.
S
Shengliang Guan 已提交
82 83 84 85 86
 *
 * @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 已提交
87
 */
S
Shengliang Guan 已提交
88
int32_t qndProcessMsg(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
D
dapan1121 已提交
89

H
refact  
Hongze Cheng 已提交
90 91 92 93 94
#ifdef __cplusplus
}
#endif

#endif /*_TD_QNODE_H_*/