2021-09-22 09:27:48 +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_INT_H_
|
|
|
|
|
#define _TD_MND_INT_H_
|
2021-09-22 09:27:48 +00:00
|
|
|
|
2021-11-27 14:56:18 +00:00
|
|
|
#include "mndDef.h"
|
2022-01-03 09:44:47 +00:00
|
|
|
|
2021-11-09 06:27:17 +00:00
|
|
|
#include "sdb.h"
|
2022-05-30 05:14:48 +00:00
|
|
|
#include "sync.h"
|
2021-12-02 11:56:43 +00:00
|
|
|
#include "tcache.h"
|
2022-03-04 05:25:39 +00:00
|
|
|
#include "tdatablock.h"
|
2022-03-02 09:48:39 +00:00
|
|
|
#include "tglobal.h"
|
2022-07-18 05:22:21 +00:00
|
|
|
#include "tgrant.h"
|
2021-11-29 04:09:18 +00:00
|
|
|
#include "tqueue.h"
|
2021-12-09 08:47:23 +00:00
|
|
|
#include "ttime.h"
|
2022-02-24 06:31:36 +00:00
|
|
|
#include "version.h"
|
2022-03-02 09:48:39 +00:00
|
|
|
#include "wal.h"
|
2021-10-16 07:16:05 +00:00
|
|
|
|
2021-09-22 09:27:48 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-05-22 04:34:22 +00:00
|
|
|
// clang-format off
|
2022-06-21 07:05:31 +00:00
|
|
|
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
|
|
|
|
|
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
|
|
|
|
|
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
|
|
|
|
|
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
|
|
|
|
|
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
|
|
|
|
|
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
|
|
|
|
|
|
2023-02-23 09:54:51 +00:00
|
|
|
#define mGFatal(param, ...) { if (mDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);}}
|
|
|
|
|
#define mGError(param, ...) { if (mDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);}}
|
|
|
|
|
#define mGWarn(param, ...) { if (mDebugFlag & DEBUG_WARN){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);}}
|
|
|
|
|
#define mGInfo(param, ...) { if (mDebugFlag & DEBUG_INFO){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}}
|
|
|
|
|
#define mGDebug(param, ...) { if (mDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}}
|
|
|
|
|
#define mGTrace(param, ...) { if (mDebugFlag & DEBUG_TRACE){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}}
|
2022-05-22 04:34:22 +00:00
|
|
|
// clang-format on
|
2022-03-04 06:34:35 +00:00
|
|
|
|
2022-04-13 02:48:26 +00:00
|
|
|
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
2022-10-13 03:56:16 +00:00
|
|
|
#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
|
|
|
|
#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
|
2022-04-13 02:48:26 +00:00
|
|
|
|
2022-05-16 06:55:31 +00:00
|
|
|
typedef int32_t (*MndMsgFp)(SRpcMsg *pMsg);
|
2024-06-28 07:11:44 +00:00
|
|
|
typedef int32_t (*MndMsgFpExt)(SRpcMsg *pMsg, SQueueInfo* pInfo);
|
2021-11-29 04:09:18 +00:00
|
|
|
typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
|
|
|
|
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
2022-05-16 06:55:31 +00:00
|
|
|
typedef int32_t (*ShowRetrieveFp)(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
|
2021-12-02 11:56:43 +00:00
|
|
|
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
|
2023-02-16 00:55:13 +00:00
|
|
|
typedef struct SQueueWorker SQHandle;
|
2022-03-25 05:27:14 +00:00
|
|
|
|
2021-11-29 04:09:18 +00:00
|
|
|
typedef struct {
|
2022-07-15 06:26:18 +00:00
|
|
|
const char *name;
|
2021-11-29 04:09:18 +00:00
|
|
|
MndInitFp initFp;
|
|
|
|
|
MndCleanupFp cleanupFp;
|
|
|
|
|
} SMnodeStep;
|
2021-11-19 09:15:24 +00:00
|
|
|
|
2021-12-02 11:56:43 +00:00
|
|
|
typedef struct {
|
2021-12-30 07:19:09 +00:00
|
|
|
int64_t showId;
|
2021-12-02 11:56:43 +00:00
|
|
|
ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
|
|
|
|
|
ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
|
2022-07-15 06:26:18 +00:00
|
|
|
SCacheObj *cache;
|
2021-12-02 11:56:43 +00:00
|
|
|
} SShowMgmt;
|
|
|
|
|
|
2021-12-03 06:36:41 +00:00
|
|
|
typedef struct {
|
2022-06-15 12:59:33 +00:00
|
|
|
SCacheObj *connCache;
|
2022-06-21 10:31:50 +00:00
|
|
|
SCacheObj *appCache;
|
2021-12-03 06:36:41 +00:00
|
|
|
} SProfileMgmt;
|
|
|
|
|
|
2021-12-06 11:57:13 +00:00
|
|
|
typedef struct {
|
2022-10-28 04:14:49 +00:00
|
|
|
TdThreadMutex lock;
|
2023-02-23 09:54:51 +00:00
|
|
|
char email[TSDB_FQDN_LEN];
|
2021-12-06 11:57:13 +00:00
|
|
|
} STelemMgmt;
|
|
|
|
|
|
2021-12-25 06:40:43 +00:00
|
|
|
typedef struct {
|
2022-12-13 02:18:00 +00:00
|
|
|
tsem_t syncSem;
|
|
|
|
|
int64_t sync;
|
|
|
|
|
int32_t errCode;
|
|
|
|
|
int32_t transId;
|
2022-12-13 03:11:22 +00:00
|
|
|
int32_t transSec;
|
2022-12-14 01:14:54 +00:00
|
|
|
int64_t transSeq;
|
2022-12-13 02:18:00 +00:00
|
|
|
TdThreadMutex lock;
|
|
|
|
|
int8_t selfIndex;
|
2023-04-18 11:03:45 +00:00
|
|
|
int8_t numOfTotalReplicas;
|
2022-12-13 02:18:00 +00:00
|
|
|
int8_t numOfReplicas;
|
2023-04-18 11:03:45 +00:00
|
|
|
SReplica replicas[TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA];
|
|
|
|
|
ESyncRole nodeRoles[TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA];
|
|
|
|
|
SyncIndex lastIndex;
|
2021-12-25 06:40:43 +00:00
|
|
|
} SSyncMgmt;
|
|
|
|
|
|
2022-03-03 12:23:53 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int64_t expireTimeMS;
|
|
|
|
|
int64_t timeseriesAllowed;
|
|
|
|
|
} SGrantInfo;
|
|
|
|
|
|
2024-03-31 16:49:25 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int8_t encrypting;
|
|
|
|
|
int16_t nEncrypt;
|
|
|
|
|
int16_t nSuccess;
|
|
|
|
|
int16_t nFailed;
|
|
|
|
|
} SEncryptMgmt;
|
|
|
|
|
|
2022-04-26 08:44:45 +00:00
|
|
|
typedef struct SMnode {
|
2022-05-28 03:11:48 +00:00
|
|
|
int32_t selfDnodeId;
|
|
|
|
|
int64_t clusterId;
|
|
|
|
|
TdThread thread;
|
|
|
|
|
TdThreadRwlock lock;
|
2022-05-28 04:56:33 +00:00
|
|
|
int32_t rpcRef;
|
|
|
|
|
int32_t syncRef;
|
2022-05-28 03:11:48 +00:00
|
|
|
bool stopped;
|
|
|
|
|
bool restored;
|
|
|
|
|
bool deploy;
|
2022-07-15 06:26:18 +00:00
|
|
|
char *path;
|
2022-05-28 03:11:48 +00:00
|
|
|
int64_t checkTime;
|
2023-03-22 08:08:16 +00:00
|
|
|
SyncIndex applied;
|
2022-07-15 06:26:18 +00:00
|
|
|
SSdb *pSdb;
|
|
|
|
|
SArray *pSteps;
|
|
|
|
|
SQHandle *pQuery;
|
|
|
|
|
SHashObj *infosMeta;
|
|
|
|
|
SHashObj *perfsMeta;
|
|
|
|
|
SWal *pWal;
|
2022-05-28 03:11:48 +00:00
|
|
|
SShowMgmt showMgmt;
|
|
|
|
|
SProfileMgmt profileMgmt;
|
|
|
|
|
STelemMgmt telemMgmt;
|
|
|
|
|
SSyncMgmt syncMgmt;
|
2024-03-31 16:49:25 +00:00
|
|
|
SEncryptMgmt encryptMgmt;
|
2022-05-28 03:11:48 +00:00
|
|
|
SGrantInfo grant;
|
|
|
|
|
MndMsgFp msgFp[TDMT_MAX];
|
2024-06-28 07:11:44 +00:00
|
|
|
MndMsgFpExt msgFpExt[TDMT_MAX];
|
2022-05-28 03:11:48 +00:00
|
|
|
SMsgCb msgCb;
|
2023-09-08 03:49:12 +00:00
|
|
|
int64_t ipWhiteVer;
|
2022-04-26 08:44:45 +00:00
|
|
|
} SMnode;
|
2021-11-02 09:46:47 +00:00
|
|
|
|
2022-03-23 09:53:00 +00:00
|
|
|
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
2024-06-28 07:11:44 +00:00
|
|
|
void mndSetMsgHandleExt(SMnode *pMnode, tmsg_t msgType, MndMsgFpExt fp);
|
2022-07-14 09:00:46 +00:00
|
|
|
int64_t mndGenerateUid(const char *name, int32_t len);
|
2021-12-12 02:46:49 +00:00
|
|
|
|
2022-10-14 09:59:09 +00:00
|
|
|
void mndSetRestored(SMnode *pMnode, bool restored);
|
|
|
|
|
bool mndGetRestored(SMnode *pMnode);
|
|
|
|
|
void mndSetStop(SMnode *pMnode);
|
|
|
|
|
bool mndGetStop(SMnode *pMnode);
|
2022-05-28 04:56:33 +00:00
|
|
|
|
2023-09-08 03:49:12 +00:00
|
|
|
SArray *mndGetAllDnodeFqdns(SMnode *pMnode);
|
|
|
|
|
|
2021-09-22 09:27:48 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-27 15:02:20 +00:00
|
|
|
#endif /*_TD_MND_INT_H_*/
|