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 74
  SSdb             *pSdb;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
75
  SArray           *pSteps;
S
Shengliang Guan 已提交
76
  SShowMgmt         showMgmt;
S
Shengliang Guan 已提交
77
  SProfileMgmt      profileMgmt;
S
Shengliang Guan 已提交
78
  STelemMgmt        telemMgmt;
S
Shengliang Guan 已提交
79
  MndMsgFp          msgFp[TSDB_MSG_TYPE_MAX];
S
Shengliang Guan 已提交
80 81 82
  SendMsgToDnodeFp  sendMsgToDnodeFp;
  SendMsgToMnodeFp  sendMsgToMnodeFp;
  SendRedirectMsgFp sendRedirectMsgFp;
83
  PutMsgToMnodeQFp  putMsgToApplyMsgFp;
S
Shengliang Guan 已提交
84
} SMnode;
S
Shengliang Guan 已提交
85

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

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

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

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