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"
|
2024-11-04 08:16:24 +00:00
|
|
|
#include "sync.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"
|
2025-07-16 06:42:16 +00:00
|
|
|
#include "tqueue.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
|
|
|
|
2021-09-29 11:26:11 +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;
|
2022-10-14 09:59:09 +00:00
|
|
|
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);
|
2022-07-12 06:46:52 +00:00
|
|
|
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
|
|
|
|
2024-11-04 08:16:24 +00:00
|
|
|
int32_t mndIsCatchUp(SMnode *pMnode);
|
2023-04-24 05:38:55 +00:00
|
|
|
ESyncRole mndGetRole(SMnode *pMnode);
|
2024-03-15 01:14:54 +00:00
|
|
|
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);
|
2025-09-08 01:02:28 +00:00
|
|
|
int32_t mndResetTimer(SMnode *pMnode);
|
2024-05-28 07:13:58 +00:00
|
|
|
int64_t mndGetRoleTimeMs(SMnode *pMnode);
|
|
|
|
|
|
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
|
|
|
*/
|
2024-11-04 08:16:24 +00:00
|
|
|
int32_t mndProcessRpcMsg(SRpcMsg *pMsg, SQueueInfo *pQueueInfo);
|
2022-05-21 14:15:23 +00:00
|
|
|
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
|
2025-09-29 02:01:33 +00:00
|
|
|
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg, int32_t* qType);
|
2022-06-21 01:48:31 +00:00
|
|
|
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();
|
|
|
|
|
|
2024-09-20 06:17:33 +00:00
|
|
|
int32_t mndDumpSdb();
|
2022-09-26 08:18:48 +00:00
|
|
|
|
2024-09-20 06:17:33 +00:00
|
|
|
int32_t mndDeleteTrans();
|
2024-08-28 06:52:38 +00:00
|
|
|
|
2025-11-04 01:26:24 +00:00
|
|
|
int32_t mndModifySdb(char *path);
|
|
|
|
|
|
2021-09-22 05:21:07 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-27 15:02:20 +00:00
|
|
|
#endif /*_TD_MND_H_*/
|