mnode.h 4.5 KB
Newer Older
H
refact  
Hongze Cheng 已提交
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/>.
 */

S
Shengliang Guan 已提交
16 17
#ifndef _TD_MND_H_
#define _TD_MND_H_
H
refact  
Hongze Cheng 已提交
18 19 20 21 22

#ifdef __cplusplus
extern "C" {
#endif

S
Shengliang Guan 已提交
23 24 25
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef struct SDnode    SDnode;
typedef struct SMnode    SMnode;
S
Shengliang Guan 已提交
26
typedef struct SMnodeMsg SMnodeMsg;
27 28 29 30
typedef void (*SendMsgToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
typedef void (*SendMsgToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
typedef void (*SendRedirectMsgFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
typedef int32_t (*PutMsgToMnodeQFp)(SDnode *pDnode, SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
31

S
Shengliang Guan 已提交
32
typedef struct SMnodeLoad {
S
Shengliang Guan 已提交
33 34 35 36 37 38
  int64_t numOfDnode;
  int64_t numOfMnode;
  int64_t numOfVgroup;
  int64_t numOfDatabase;
  int64_t numOfSuperTable;
  int64_t numOfChildTable;
S
Shengliang Guan 已提交
39
  int64_t numOfNormalTable;
S
Shengliang Guan 已提交
40 41 42 43
  int64_t numOfColumn;
  int64_t totalPoints;
  int64_t totalStorage;
  int64_t compStorage;
S
Shengliang Guan 已提交
44
} SMnodeLoad;
S
Shengliang Guan 已提交
45

46
typedef struct {
S
Shengliang Guan 已提交
47
  int32_t           dnodeId;
S
Shengliang Guan 已提交
48
  int32_t           clusterId;
S
Shengliang Guan 已提交
49 50 51 52 53 54 55
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  SDnode           *pDnode;
  PutMsgToMnodeQFp  putMsgToApplyMsgFp;
  SendMsgToDnodeFp  sendMsgToDnodeFp;
  SendMsgToMnodeFp  sendMsgToMnodeFp;
S
Shengliang Guan 已提交
56
  SendRedirectMsgFp sendRedirectMsgFp;
S
Shengliang Guan 已提交
57 58 59 60 61 62
  int32_t           sver;
  int32_t           statusInterval;
  int32_t           mnodeEqualVnodeNum;
  char             *timezone;
  char             *locale;
  char             *charset;
S
Shengliang Guan 已提交
63
} SMnodeOpt;
S
Shengliang Guan 已提交
64 65 66 67 68

/* ------------------------ SMnode ------------------------ */
/**
 * @brief Open a mnode.
 *
S
Shengliang Guan 已提交
69 70 71
 * @param path Path of the mnode.
 * @param pOption Option of the mnode.
 * @return SMnode* The mnode object.
S
Shengliang Guan 已提交
72
 */
73
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
74 75

/**
S
Shengliang Guan 已提交
76
 * @brief Close a mnode.
S
Shengliang Guan 已提交
77
 *
S
Shengliang Guan 已提交
78
 * @param pMnode The mnode object to close.
S
Shengliang Guan 已提交
79
 */
80
void mndClose(SMnode *pMnode);
S
Shengliang Guan 已提交
81 82

/**
S
Shengliang Guan 已提交
83
 * @brief Close a mnode.
S
Shengliang Guan 已提交
84
 *
S
Shengliang Guan 已提交
85 86 87
 * @param pMnode The mnode object to close.
 * @param pOption Options of the mnode.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
88
 */
89
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
90 91 92 93 94 95

/**
 * @brief Drop a mnode.
 *
 * @param path Path of the mnode.
 */
96
void mndDestroy(const char *path);
S
Shengliang Guan 已提交
97 98

/**
S
Shengliang Guan 已提交
99
 * @brief Get mnode statistics info.
S
Shengliang Guan 已提交
100
 *
S
Shengliang Guan 已提交
101
 * @param pMnode The mnode object.
S
Shengliang Guan 已提交
102
 * @param pLoad Statistics of the mnode.
S
Shengliang Guan 已提交
103
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
104
 */
105
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
S
Shengliang Guan 已提交
106

S
Shengliang Guan 已提交
107
/**
S
Shengliang Guan 已提交
108
 * @brief Get user authentication info.
S
Shengliang Guan 已提交
109
 *
S
Shengliang Guan 已提交
110
 * @param pMnode The mnode object.
S
Shengliang Guan 已提交
111 112 113 114 115
 * @param user
 * @param spi
 * @param encrypt
 * @param secret
 * @param ckey
S
Shengliang Guan 已提交
116
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
117
 */
118
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
S
Shengliang Guan 已提交
119

S
Shengliang Guan 已提交
120
/**
S
Shengliang Guan 已提交
121
 * @brief Initialize mnode msg.
S
Shengliang Guan 已提交
122
 *
S
Shengliang Guan 已提交
123 124 125
 * @param pMnode The mnode object.
 * @param pMsg The request rpc msg.
 * @return int32_t The created mnode msg.
S
Shengliang Guan 已提交
126
 */
127
SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg);
S
Shengliang Guan 已提交
128

S
Shengliang Guan 已提交
129
/**
S
Shengliang Guan 已提交
130
 * @brief Cleanup mnode msg.
S
Shengliang Guan 已提交
131
 *
S
Shengliang Guan 已提交
132
 * @param pMsg The request msg.
S
Shengliang Guan 已提交
133
 */
134
void mndCleanupMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
135 136

/**
S
Shengliang Guan 已提交
137
 * @brief Cleanup mnode msg.
S
Shengliang Guan 已提交
138
 *
S
Shengliang Guan 已提交
139 140
 * @param pMsg The request msg.
 * @param code The error code.
S
Shengliang Guan 已提交
141
 */
142
void mndSendRsp(SMnodeMsg *pMsg, int32_t code);
S
Shengliang Guan 已提交
143

S
Shengliang Guan 已提交
144
/**
S
Shengliang Guan 已提交
145
 * @brief Process the read request.
S
Shengliang Guan 已提交
146
 *
S
Shengliang Guan 已提交
147 148
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
149
 */
150
void mndProcessReadMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
151 152

/**
S
Shengliang Guan 已提交
153
 * @brief Process the write request.
S
Shengliang Guan 已提交
154
 *
S
Shengliang Guan 已提交
155 156
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
157
 */
158
void mndProcessWriteMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
159 160

/**
S
Shengliang Guan 已提交
161
 * @brief Process the sync request.
S
Shengliang Guan 已提交
162
 *
S
Shengliang Guan 已提交
163 164
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
165
 */
166
void mndProcessSyncMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
167 168

/**
S
Shengliang Guan 已提交
169
 * @brief Process the apply request.
S
Shengliang Guan 已提交
170
 *
S
Shengliang Guan 已提交
171 172
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
173
 */
174
void mndProcessApplyMsg(SMnodeMsg *pMsg);
175

H
refact  
Hongze Cheng 已提交
176 177 178 179
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
180
#endif /*_TD_MND_H_*/