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"
|
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"
|
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-03-04 06:34:35 +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__); }}
|
|
|
|
|
|
2022-03-15 12:53:29 +00:00
|
|
|
typedef int32_t (*MndMsgFp)(SNodeMsg *pMsg);
|
2021-11-29 04:09:18 +00:00
|
|
|
typedef int32_t (*MndInitFp)(SMnode *pMnode);
|
|
|
|
|
typedef void (*MndCleanupFp)(SMnode *pMnode);
|
2022-03-15 12:53:29 +00:00
|
|
|
typedef int32_t (*ShowMetaFp)(SNodeMsg *pMsg, SShowObj *pShow, STableMetaRsp *pMeta);
|
|
|
|
|
typedef int32_t (*ShowRetrieveFp)(SNodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
|
2021-12-02 11:56:43 +00:00
|
|
|
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
|
2021-11-19 06:46:06 +00:00
|
|
|
|
2022-03-02 09:48:39 +00:00
|
|
|
typedef struct SMnodeLoad {
|
|
|
|
|
int64_t numOfDnode;
|
|
|
|
|
int64_t numOfMnode;
|
|
|
|
|
int64_t numOfVgroup;
|
|
|
|
|
int64_t numOfDatabase;
|
|
|
|
|
int64_t numOfSuperTable;
|
|
|
|
|
int64_t numOfChildTable;
|
|
|
|
|
int64_t numOfNormalTable;
|
|
|
|
|
int64_t numOfColumn;
|
|
|
|
|
int64_t totalPoints;
|
|
|
|
|
int64_t totalStorage;
|
|
|
|
|
int64_t compStorage;
|
|
|
|
|
} SMnodeLoad;
|
|
|
|
|
|
2022-03-25 05:27:14 +00:00
|
|
|
typedef struct SQWorkerMgmt SQHandle;
|
|
|
|
|
|
2021-11-29 04:09:18 +00:00
|
|
|
typedef struct {
|
|
|
|
|
const char *name;
|
|
|
|
|
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
|
|
|
ShowMetaFp metaFps[TSDB_MGMT_TABLE_MAX];
|
|
|
|
|
ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
|
|
|
|
|
ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
|
|
|
|
|
SCacheObj *cache;
|
|
|
|
|
} SShowMgmt;
|
|
|
|
|
|
2021-12-03 06:36:41 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int32_t connId;
|
|
|
|
|
SCacheObj *cache;
|
|
|
|
|
} SProfileMgmt;
|
|
|
|
|
|
2021-12-06 11:57:13 +00:00
|
|
|
typedef struct {
|
2022-02-22 11:49:11 +00:00
|
|
|
bool enable;
|
2022-02-18 09:29:38 +00:00
|
|
|
SRWLatch lock;
|
|
|
|
|
char email[TSDB_FQDN_LEN];
|
2021-12-06 11:57:13 +00:00
|
|
|
} STelemMgmt;
|
|
|
|
|
|
2021-12-25 06:40:43 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int32_t errCode;
|
|
|
|
|
sem_t syncSem;
|
2022-01-03 09:44:47 +00:00
|
|
|
SWal *pWal;
|
2021-12-25 06:40:43 +00:00
|
|
|
SSyncNode *pSyncNode;
|
|
|
|
|
ESyncState state;
|
|
|
|
|
} SSyncMgmt;
|
|
|
|
|
|
2022-03-03 12:23:53 +00:00
|
|
|
typedef struct {
|
|
|
|
|
int64_t expireTimeMS;
|
|
|
|
|
int64_t timeseriesAllowed;
|
|
|
|
|
} SGrantInfo;
|
|
|
|
|
|
2021-11-19 06:46:06 +00:00
|
|
|
typedef struct SMnode {
|
2021-11-20 16:13:35 +00:00
|
|
|
int32_t dnodeId;
|
2021-12-27 02:57:31 +00:00
|
|
|
int64_t clusterId;
|
2021-11-20 16:13:35 +00:00
|
|
|
int8_t replica;
|
|
|
|
|
int8_t selfIndex;
|
|
|
|
|
SReplica replicas[TSDB_MAX_REPLICA];
|
|
|
|
|
tmr_h timer;
|
2021-12-26 15:46:22 +00:00
|
|
|
tmr_h transTimer;
|
2022-01-20 01:49:27 +00:00
|
|
|
tmr_h mqTimer;
|
2022-02-18 09:17:22 +00:00
|
|
|
tmr_h telemTimer;
|
2021-11-29 11:35:42 +00:00
|
|
|
char *path;
|
2021-12-20 11:44:12 +00:00
|
|
|
int64_t checkTime;
|
2021-11-29 04:09:18 +00:00
|
|
|
SSdb *pSdb;
|
2022-03-16 13:18:54 +00:00
|
|
|
SMgmtWrapper *pWrapper;
|
2021-11-29 11:35:42 +00:00
|
|
|
SArray *pSteps;
|
2022-03-25 05:27:14 +00:00
|
|
|
SQHandle *pQuery;
|
2021-12-02 11:56:43 +00:00
|
|
|
SShowMgmt showMgmt;
|
2021-12-03 06:36:41 +00:00
|
|
|
SProfileMgmt profileMgmt;
|
2021-12-06 11:57:13 +00:00
|
|
|
STelemMgmt telemMgmt;
|
2021-12-25 06:40:43 +00:00
|
|
|
SSyncMgmt syncMgmt;
|
2022-02-24 11:45:05 +00:00
|
|
|
SHashObj *infosMeta;
|
2022-03-03 12:23:53 +00:00
|
|
|
SGrantInfo grant;
|
2021-12-24 07:00:51 +00:00
|
|
|
MndMsgFp msgFp[TDMT_MAX];
|
2022-03-25 05:27:14 +00:00
|
|
|
SMsgCb msgCb;
|
2021-11-19 06:46:06 +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);
|
|
|
|
|
int64_t mndGenerateUid(char *name, int32_t len);
|
|
|
|
|
void mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
|
2021-12-12 02:46:49 +00:00
|
|
|
|
2021-09-22 09:27:48 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-11-27 15:02:20 +00:00
|
|
|
#endif /*_TD_MND_INT_H_*/
|