qnode.h 2.1 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

/* ------------------------ TYPES EXPOSED ------------------------ */
S
shm  
Shengliang Guan 已提交
24 25
typedef struct SMgmtWrapper SMgmtWrapper;
typedef struct SQnode       SQnode;
D
dapan1121 已提交
26 27

typedef struct {
S
Shengliang Guan 已提交
28 29 30 31 32 33 34 35 36
  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 已提交
37

S
Shengliang Guan 已提交
38
typedef struct {
S
shm  
Shengliang Guan 已提交
39 40 41 42
  SMgmtWrapper  *pWrapper;
  SendReqFp      sendReqFp;
  SendMnodeReqFp sendMnodeReqFp;
  SendRspFp      sendRspFp;
S
Shengliang Guan 已提交
43 44 45
} SQnodeOpt;

/* ------------------------ SQnode ------------------------ */
D
dapan1121 已提交
46
/**
S
Shengliang Guan 已提交
47 48 49 50
 * @brief Start one Qnode in Dnode.
 *
 * @param pOption Option of the qnode.
 * @return SQnode* The qnode object.
D
dapan1121 已提交
51
 */
S
Shengliang Guan 已提交
52
SQnode *qndOpen(const SQnodeOpt *pOption);
D
dapan1121 已提交
53 54

/**
S
Shengliang Guan 已提交
55
 * @brief Stop Qnode in Dnode.
D
dapan1121 已提交
56
 *
S
Shengliang Guan 已提交
57
 * @param pQnode The qnode object to close.
D
dapan1121 已提交
58
 */
S
Shengliang Guan 已提交
59
void qndClose(SQnode *pQnode);
D
dapan1121 已提交
60 61

/**
S
Shengliang Guan 已提交
62
 * @brief Get the statistical information of Qnode
D
dapan1121 已提交
63
 *
S
Shengliang Guan 已提交
64 65 66
 * @param pQnode The qnode object.
 * @param pLoad Statistics of the qnode.
 * @return int32_t 0 for success, -1 for failure.
D
dapan1121 已提交
67
 */
S
Shengliang Guan 已提交
68
int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad);
D
dapan1121 已提交
69 70

/**
S
Shengliang Guan 已提交
71
 * @brief Process a query or fetch message.
S
Shengliang Guan 已提交
72 73 74 75 76
 *
 * @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 已提交
77
 */
S
Shengliang Guan 已提交
78
int32_t qndProcessMsg(SQnode *pQnode, SRpcMsg *pMsg, SRpcMsg **pRsp);
D
dapan1121 已提交
79

H
refact  
Hongze Cheng 已提交
80 81 82 83 84
#ifdef __cplusplus
}
#endif

#endif /*_TD_QNODE_H_*/