TDengine/include/dnode/mnode/mnode.h

162 lines
3.9 KiB
C
Raw Normal View History

2021-09-22 05:21:07 +00:00
/*
* 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/>.
*/
2021-11-27 15:02:20 +00:00
#ifndef _TD_MND_H_
#define _TD_MND_H_
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-11-20 16:13:35 +00:00
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef struct SDnode SDnode;
typedef struct SMnode SMnode;
2021-11-05 07:42:19 +00:00
typedef struct SMnodeMsg SMnodeMsg;
2021-11-26 06:15:22 +00:00
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);
2021-11-05 07:42:19 +00:00
2021-11-20 16:13:35 +00:00
typedef struct SMnodeLoad {
2021-11-02 09:46:47 +00:00
int64_t numOfDnode;
int64_t numOfMnode;
int64_t numOfVgroup;
int64_t numOfDatabase;
int64_t numOfSuperTable;
int64_t numOfChildTable;
2021-11-29 12:24:16 +00:00
int64_t numOfNormalTable;
2021-11-02 09:46:47 +00:00
int64_t numOfColumn;
int64_t totalPoints;
int64_t totalStorage;
int64_t compStorage;
2021-11-04 12:24:34 +00:00
} SMnodeLoad;
2021-10-17 09:10:45 +00:00
2021-12-06 11:57:13 +00:00
typedef struct SMnodeCfg {
int32_t sver;
int8_t enableTelem;
int32_t statusInterval;
int32_t shellActivityTimer;
char *timezone;
char *locale;
char *charset;
char *buildinfo;
char *gitinfo;
} SMnodeCfg;
typedef struct {
2021-11-30 11:42:51 +00:00
int32_t dnodeId;
2021-12-27 02:47:14 +00:00
int64_t clusterId;
2021-11-30 11:42:51 +00:00
int8_t replica;
int8_t selfIndex;
SReplica replicas[TSDB_MAX_REPLICA];
2021-12-06 11:57:13 +00:00
SMnodeCfg cfg;
2021-11-30 11:42:51 +00:00
SDnode *pDnode;
SendMsgToDnodeFp sendMsgToDnodeFp;
SendMsgToMnodeFp sendMsgToMnodeFp;
2021-11-19 09:15:24 +00:00
SendRedirectMsgFp sendRedirectMsgFp;
2021-11-26 08:28:38 +00:00
} SMnodeOpt;
2021-11-20 16:13:35 +00:00
/* ------------------------ SMnode ------------------------ */
/**
* @brief Open a mnode.
*
2021-11-29 12:24:16 +00:00
* @param path Path of the mnode.
* @param pOption Option of the mnode.
* @return SMnode* The mnode object.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption);
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Close a mnode.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object to close.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
void mndClose(SMnode *pMnode);
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Close a mnode.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object to close.
* @param pOption Options of the mnode.
* @return int32_t 0 for success, -1 for failure.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
2021-11-20 16:13:35 +00:00
/**
* @brief Drop a mnode.
*
* @param path Path of the mnode.
*/
2021-11-29 04:09:18 +00:00
void mndDestroy(const char *path);
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Get mnode statistics info.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object.
2021-11-20 16:13:35 +00:00
* @param pLoad Statistics of the mnode.
2021-11-29 12:24:16 +00:00
* @return int32_t 0 for success, -1 for failure.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
2021-09-22 12:29:24 +00:00
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Get user authentication info.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object.
2021-11-20 16:13:35 +00:00
* @param user
* @param spi
* @param encrypt
* @param secret
* @param ckey
2021-11-29 12:24:16 +00:00
* @return int32_t 0 for success, -1 for failure.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
2021-11-04 12:24:34 +00:00
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Initialize mnode msg.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object.
* @param pMsg The request rpc msg.
* @return int32_t The created mnode msg.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg);
2021-09-22 12:29:24 +00:00
2021-11-20 16:13:35 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Cleanup mnode msg.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMsg The request msg.
2021-11-20 16:13:35 +00:00
*/
2021-11-29 04:09:18 +00:00
void mndCleanupMsg(SMnodeMsg *pMsg);
2021-11-22 02:03:41 +00:00
/**
2021-11-29 12:24:16 +00:00
* @brief Cleanup mnode msg.
2021-11-22 02:03:41 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMsg The request msg.
* @param code The error code.
2021-11-22 02:03:41 +00:00
*/
2021-11-29 04:09:18 +00:00
void mndSendRsp(SMnodeMsg *pMsg, int32_t code);
2021-09-22 12:29:24 +00:00
2021-11-20 16:13:35 +00:00
/**
2021-12-28 09:38:15 +00:00
* @brief Process the read, write, sync request.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
2021-11-20 16:13:35 +00:00
*/
2021-12-28 09:38:15 +00:00
void mndProcessMsg(SMnodeMsg *pMsg);
2021-11-20 16:13:35 +00:00
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
}
#endif
2021-11-27 15:02:20 +00:00
#endif /*_TD_MND_H_*/