mndInt.h 3.6 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * 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/>.
 */

S
Shengliang Guan 已提交
16 17
#ifndef _TD_MND_INT_H_
#define _TD_MND_INT_H_
H
refact  
Hongze Cheng 已提交
18

S
Shengliang Guan 已提交
19
#include "mndDef.h"
S
Shengliang Guan 已提交
20

S
Shengliang Guan 已提交
21
#include "sdb.h"
22
#include "syncTools.h"
S
Shengliang Guan 已提交
23
#include "tcache.h"
H
Haojun Liao 已提交
24
#include "tdatablock.h"
S
monitor  
Shengliang Guan 已提交
25
#include "tglobal.h"
26
#include "tqueue.h"
S
Shengliang Guan 已提交
27
#include "ttime.h"
S
charset  
Shengliang Guan 已提交
28
#include "version.h"
S
monitor  
Shengliang Guan 已提交
29
#include "wal.h"
S
Shengliang Guan 已提交
30

H
refact  
Hongze Cheng 已提交
31 32 33 34
#ifdef __cplusplus
extern "C" {
#endif

35
// clang-format off
36 37 38 39 40 41
#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__); }}
42
// clang-format on
43

D
dapan1121 已提交
44 45
#define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
#define SYSTABLE_SCH_DB_NAME_LEN    ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
46
#define SYSTABLE_SCH_COL_NAME_LEN   ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE)
D
dapan1121 已提交
47

S
Shengliang Guan 已提交
48
typedef int32_t (*MndMsgFp)(SRpcMsg *pMsg);
49 50
typedef int32_t (*MndInitFp)(SMnode *pMnode);
typedef void (*MndCleanupFp)(SMnode *pMnode);
S
Shengliang Guan 已提交
51
typedef int32_t (*ShowRetrieveFp)(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
S
Shengliang Guan 已提交
52
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
D
dapan1121 已提交
53
typedef struct SQWorker SQHandle;
D
dapan1121 已提交
54

55 56 57 58 59
typedef struct {
  const char  *name;
  MndInitFp    initFp;
  MndCleanupFp cleanupFp;
} SMnodeStep;
S
Shengliang Guan 已提交
60

S
Shengliang Guan 已提交
61
typedef struct {
62
  int64_t        showId;
S
Shengliang Guan 已提交
63 64 65 66 67
  ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
  ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
  SCacheObj     *cache;
} SShowMgmt;

S
Shengliang Guan 已提交
68 69 70 71
typedef struct {
  SCacheObj *cache;
} SProfileMgmt;

S
Shengliang Guan 已提交
72
typedef struct {
S
Shengliang Guan 已提交
73 74
  SRWLatch lock;
  char     email[TSDB_FQDN_LEN];
S
Shengliang Guan 已提交
75 76
} STelemMgmt;

S
Shengliang Guan 已提交
77
typedef struct {
78
  SWal      *pWal;
S
Shengliang Guan 已提交
79
  sem_t      syncSem;
80
  int64_t    sync;
S
Shengliang Guan 已提交
81
  bool       standby;
S
Shengliang Guan 已提交
82 83
  bool       restored;
  int32_t    errCode;
S
Shengliang Guan 已提交
84 85
} SSyncMgmt;

S
Shengliang Guan 已提交
86 87 88 89 90
typedef struct {
  int64_t expireTimeMS;
  int64_t timeseriesAllowed;
} SGrantInfo;

91
typedef struct SMnode {
92
  int32_t       selfDnodeId;
93
  int64_t       clusterId;
S
Shengliang Guan 已提交
94
  TdThread      thread;
95
  bool          deploy;
S
Shengliang Guan 已提交
96
  bool          stopped;
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  int8_t        replica;
  int8_t        selfIndex;
  SReplica      replicas[TSDB_MAX_REPLICA];
  char         *path;
  int64_t       checkTime;
  SSdb         *pSdb;
  SMgmtWrapper *pWrapper;
  SArray       *pSteps;
  SQHandle     *pQuery;
  SShowMgmt     showMgmt;
  SProfileMgmt  profileMgmt;
  STelemMgmt    telemMgmt;
  SSyncMgmt     syncMgmt;
  SHashObj     *infosMeta;
  SHashObj     *perfsMeta;
  SGrantInfo    grant;
  MndMsgFp      msgFp[TDMT_MAX];
  SMsgCb        msgCb;
} SMnode;
S
Shengliang Guan 已提交
116

S
sma  
Shengliang Guan 已提交
117 118
void    mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
int64_t mndGenerateUid(char *name, int32_t len);
S
Shengliang Guan 已提交
119

H
refact  
Hongze Cheng 已提交
120 121 122 123
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
124
#endif /*_TD_MND_INT_H_*/