TDengine/include/dnode/mnode/mnode.h

127 lines
3 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
2022-03-02 09:48:39 +00:00
#include "monitor.h"
2022-03-24 03:34:43 +00:00
#include "tmsg.h"
2022-03-21 11:08:25 +00:00
#include "tmsgcb.h"
2022-03-24 03:34:43 +00:00
#include "trpc.h"
#include "sync.h"
2022-03-02 09:48:39 +00:00
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2021-11-20 16:13:35 +00:00
/* ------------------------ TYPES EXPOSED ------------------------ */
2022-03-21 11:08:25 +00:00
typedef struct SMnode SMnode;
2021-11-05 07:42:19 +00:00
typedef struct {
2022-05-25 08:41:38 +00:00
int32_t dnodeId;
2022-04-01 08:36:36 +00:00
bool deploy;
int8_t selfIndex;
int8_t numOfReplicas;
2023-04-18 11:03:45 +00:00
int8_t numOfTotalReplicas;
SReplica replicas[TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA];
int32_t nodeRoles[TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA];
2022-03-21 11:08:25 +00:00
SMsgCb msgCb;
2023-04-18 11:03:45 +00:00
int64_t lastIndex;
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);
void mndPreClose(SMnode *pMnode);
2021-11-20 16:13:35 +00:00
/**
2022-03-19 16:25:37 +00:00
* @brief Start mnode
2021-11-20 16:13:35 +00:00
*
2022-03-19 16:25:37 +00:00
* @param pMnode The mnode object.
2021-11-20 16:13:35 +00:00
*/
2022-03-19 16:25:37 +00:00
int32_t mndStart(SMnode *pMnode);
2022-06-14 08:01:32 +00:00
/**
* @brief Stop mnode
*
* @param pMnode The mnode object.
*/
void mndStop(SMnode *pMnode);
2021-11-20 16:13:35 +00:00
2023-04-18 11:03:45 +00:00
int32_t mndIsCatchUp(SMnode *pMnode);
ESyncRole mndGetRole(SMnode *pMnode);
int64_t mndGetTerm(SMnode *pMnode);
int32_t mndGetArbToken(SMnode *pMnode, char *outToken);
2023-04-18 11:03:45 +00:00
2021-11-20 16:13:35 +00:00
/**
2022-03-02 09:48:39 +00:00
* @brief Get mnode monitor info.
2021-11-20 16:13:35 +00:00
*
2021-11-29 12:24:16 +00:00
* @param pMnode The mnode object.
2022-04-14 10:28:05 +00:00
* @param pCluster
* @param pVgroup
2022-06-23 13:09:50 +00:00
* @param pStbInfo
2022-04-14 10:28:05 +00:00
* @param pGrant
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
*/
2022-06-23 13:09:50 +00:00
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
SMonStbInfo *pStbInfo, SMonGrantInfo *pGrantInfo);
2022-06-14 08:01:32 +00:00
/**
* @brief Get mnode loads for status msg.
*
* @param pMnode The mnode object.
* @param pLoad
* @return int32_t 0 for success, -1 for failure.
*/
2022-04-19 13:39:42 +00:00
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
2021-11-04 12:24:34 +00:00
2021-11-20 16:13:35 +00:00
/**
2022-06-14 08:01:32 +00:00
* @brief Process the rpc, 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
*/
2022-05-28 04:56:33 +00:00
int32_t mndProcessRpcMsg(SRpcMsg *pMsg);
2022-05-21 14:15:23 +00:00
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg);
void mndPostProcessQueryMsg(SRpcMsg *pMsg);
2022-05-21 13:26:27 +00:00
2022-04-14 05:44:40 +00:00
/**
* @brief Generate machine code
*/
void mndGenerateMachineCode();
2022-09-26 08:18:48 +00:00
void mndDumpSdb();
2021-09-22 05:21:07 +00:00
#ifdef __cplusplus
}
#endif
2021-11-27 15:02:20 +00:00
#endif /*_TD_MND_H_*/