mndInt.h 2.8 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
#include "sdb.h"
S
Shengliang Guan 已提交
21
#include "tcache.h"
22
#include "tqueue.h"
S
Shengliang Guan 已提交
23
#include "ttime.h"
S
Shengliang Guan 已提交
24

H
refact  
Hongze Cheng 已提交
25 26 27 28
#ifdef __cplusplus
extern "C" {
#endif

29
typedef int32_t (*MndMsgFp)(SMnodeMsg *pMsg);
30 31
typedef int32_t (*MndInitFp)(SMnode *pMnode);
typedef void (*MndCleanupFp)(SMnode *pMnode);
S
Shengliang Guan 已提交
32 33
typedef int32_t (*ShowMetaFp)(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMeta);
typedef int32_t (*ShowRetrieveFp)(SMnodeMsg *pMsg, SShowObj *pShow, char *data, int32_t rows);
S
Shengliang Guan 已提交
34
typedef void (*ShowFreeIterFp)(SMnode *pMnode, void *pIter);
S
Shengliang Guan 已提交
35

36 37 38 39 40
typedef struct {
  const char  *name;
  MndInitFp    initFp;
  MndCleanupFp cleanupFp;
} SMnodeStep;
S
Shengliang Guan 已提交
41

S
Shengliang Guan 已提交
42 43 44 45 46 47 48 49
typedef struct {
  int32_t        showId;
  ShowMetaFp     metaFps[TSDB_MGMT_TABLE_MAX];
  ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
  ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
  SCacheObj     *cache;
} SShowMgmt;

S
Shengliang Guan 已提交
50 51 52 53 54
typedef struct {
  int32_t    connId;
  SCacheObj *cache;
} SProfileMgmt;

S
Shengliang Guan 已提交
55 56 57 58 59 60 61 62 63
typedef struct {
  int8_t           enable;
  pthread_mutex_t  lock;
  pthread_cond_t   cond;
  volatile int32_t exit;
  pthread_t        thread;
  char             email[TSDB_FQDN_LEN];
} STelemMgmt;

S
Shengliang Guan 已提交
64
typedef struct SMnode {
S
Shengliang Guan 已提交
65
  int32_t           dnodeId;
S
Shengliang Guan 已提交
66
  int32_t           clusterId;
S
Shengliang Guan 已提交
67 68 69 70
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  tmr_h             timer;
S
Shengliang Guan 已提交
71
  char             *path;
S
Shengliang Guan 已提交
72
  SMnodeCfg         cfg;
73
  int64_t           checkTime;
74 75
  SSdb             *pSdb;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
76
  SArray           *pSteps;
S
Shengliang Guan 已提交
77
  SShowMgmt         showMgmt;
S
Shengliang Guan 已提交
78
  SProfileMgmt      profileMgmt;
S
Shengliang Guan 已提交
79
  STelemMgmt        telemMgmt;
H
Hongze Cheng 已提交
80
  MndMsgFp          msgFp[TDMT_MAX];
S
Shengliang Guan 已提交
81 82 83
  SendMsgToDnodeFp  sendMsgToDnodeFp;
  SendMsgToMnodeFp  sendMsgToMnodeFp;
  SendRedirectMsgFp sendRedirectMsgFp;
84
  PutMsgToMnodeQFp  putMsgToApplyMsgFp;
S
Shengliang Guan 已提交
85
} SMnode;
S
Shengliang Guan 已提交
86

87 88 89
void mndSendMsgToDnode(SMnode *pMnode, SEpSet *pEpSet, SRpcMsg *rpcMsg);
void mndSendMsgToMnode(SMnode *pMnode, SRpcMsg *pMsg);
void mndSendRedirectMsg(SMnode *pMnode, SRpcMsg *pMsg);
90
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
S
Shengliang Guan 已提交
91

S
Shengliang Guan 已提交
92 93
uint64_t mndGenerateUid(char *name, int32_t len) ;

H
refact  
Hongze Cheng 已提交
94 95 96 97
#ifdef __cplusplus
}
#endif

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