mndInt.h 3.4 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"
S
Shengliang Guan 已提交
22
#include "tcache.h"
S
Shengliang Guan 已提交
23
#include "tep.h"
S
monitor  
Shengliang Guan 已提交
24
#include "tglobal.h"
25
#include "tqueue.h"
S
Shengliang Guan 已提交
26
#include "ttime.h"
S
charset  
Shengliang Guan 已提交
27
#include "version.h"
S
monitor  
Shengliang Guan 已提交
28
#include "wal.h"
S
Shengliang Guan 已提交
29

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

34
typedef int32_t (*MndMsgFp)(SMnodeMsg *pMsg);
35 36
typedef int32_t (*MndInitFp)(SMnode *pMnode);
typedef void (*MndCleanupFp)(SMnode *pMnode);
S
Shengliang Guan 已提交
37
typedef int32_t (*ShowMetaFp)(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaRsp *pMeta);
S
Shengliang Guan 已提交
38
typedef int32_t (*ShowRetrieveFp)(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
S
Shengliang Guan 已提交
39
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
S
Shengliang Guan 已提交
40

S
monitor  
Shengliang Guan 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54
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;

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 68
  ShowMetaFp     metaFps[TSDB_MGMT_TABLE_MAX];
  ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
  ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
  SCacheObj     *cache;
} SShowMgmt;

S
Shengliang Guan 已提交
69 70 71 72 73
typedef struct {
  int32_t    connId;
  SCacheObj *cache;
} SProfileMgmt;

S
Shengliang Guan 已提交
74
typedef struct {
S
Shengliang Guan 已提交
75
  bool     enable;
S
Shengliang Guan 已提交
76 77
  SRWLatch lock;
  char     email[TSDB_FQDN_LEN];
S
Shengliang Guan 已提交
78 79
} STelemMgmt;

S
Shengliang Guan 已提交
80 81 82
typedef struct {
  int32_t    errCode;
  sem_t      syncSem;
S
Shengliang Guan 已提交
83
  SWal      *pWal;
S
Shengliang Guan 已提交
84 85 86 87
  SSyncNode *pSyncNode;
  ESyncState state;
} SSyncMgmt;

S
Shengliang Guan 已提交
88
typedef struct SMnode {
S
Shengliang Guan 已提交
89
  int32_t           dnodeId;
90
  int64_t           clusterId;
S
Shengliang Guan 已提交
91 92 93 94
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  tmr_h             timer;
S
Shengliang Guan 已提交
95
  tmr_h             transTimer;
L
Liu Jicong 已提交
96
  tmr_h             mqTimer;
S
Shengliang Guan 已提交
97
  tmr_h             telemTimer;
S
Shengliang Guan 已提交
98
  char             *path;
99
  int64_t           checkTime;
100 101
  SSdb             *pSdb;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
102
  SArray           *pSteps;
S
Shengliang Guan 已提交
103
  SShowMgmt         showMgmt;
S
Shengliang Guan 已提交
104
  SProfileMgmt      profileMgmt;
S
Shengliang Guan 已提交
105
  STelemMgmt        telemMgmt;
S
Shengliang Guan 已提交
106
  SSyncMgmt         syncMgmt;
D
dapan1121 已提交
107
  SHashObj         *infosMeta;
H
Hongze Cheng 已提交
108
  MndMsgFp          msgFp[TDMT_MAX];
S
Shengliang Guan 已提交
109 110 111 112
  SendReqToDnodeFp  sendReqToDnodeFp;
  SendReqToMnodeFp  sendReqToMnodeFp;
  SendRedirectRspFp sendRedirectRspFp;
  PutReqToMWriteQFp putReqToMWriteQFp;
L
Liu Jicong 已提交
113
  PutReqToMReadQFp  putReqToMReadQFp;
S
Shengliang Guan 已提交
114
} SMnode;
S
Shengliang Guan 已提交
115

S
Shengliang Guan 已提交
116 117 118 119
int32_t mndSendReqToDnode(SMnode *pMnode, SEpSet *pEpSet, SRpcMsg *rpcMsg);
int32_t mndSendReqToMnode(SMnode *pMnode, SRpcMsg *pMsg);
void    mndSendRedirectRsp(SMnode *pMnode, SRpcMsg *pMsg);
void    mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
S
Shengliang Guan 已提交
120

S
monitor  
Shengliang Guan 已提交
121 122 123
uint64_t mndGenerateUid(char *name, int32_t len);

int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
S
Shengliang Guan 已提交
124

H
refact  
Hongze Cheng 已提交
125 126 127 128
#ifdef __cplusplus
}
#endif

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