mndInt.h 3.1 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"
24
#include "tqueue.h"
S
Shengliang Guan 已提交
25
#include "ttime.h"
S
Shengliang Guan 已提交
26
#include "wal.h"
S
Shengliang Guan 已提交
27

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

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

39 40 41 42 43
typedef struct {
  const char  *name;
  MndInitFp    initFp;
  MndCleanupFp cleanupFp;
} SMnodeStep;
S
Shengliang Guan 已提交
44

S
Shengliang Guan 已提交
45
typedef struct {
46
  int64_t        showId;
S
Shengliang Guan 已提交
47 48 49 50 51 52
  ShowMetaFp     metaFps[TSDB_MGMT_TABLE_MAX];
  ShowRetrieveFp retrieveFps[TSDB_MGMT_TABLE_MAX];
  ShowFreeIterFp freeIterFps[TSDB_MGMT_TABLE_MAX];
  SCacheObj     *cache;
} SShowMgmt;

S
Shengliang Guan 已提交
53 54 55 56 57
typedef struct {
  int32_t    connId;
  SCacheObj *cache;
} SProfileMgmt;

S
Shengliang Guan 已提交
58 59 60 61 62 63 64 65 66
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 已提交
67 68 69
typedef struct {
  int32_t    errCode;
  sem_t      syncSem;
S
Shengliang Guan 已提交
70
  SWal      *pWal;
S
Shengliang Guan 已提交
71 72 73 74
  SSyncNode *pSyncNode;
  ESyncState state;
} SSyncMgmt;

S
Shengliang Guan 已提交
75
typedef struct SMnode {
S
Shengliang Guan 已提交
76
  int32_t           dnodeId;
77
  int64_t           clusterId;
S
Shengliang Guan 已提交
78 79 80 81
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  tmr_h             timer;
S
Shengliang Guan 已提交
82
  tmr_h             transTimer;
L
Liu Jicong 已提交
83
  tmr_h             mqTimer;
S
Shengliang Guan 已提交
84
  char             *path;
S
Shengliang Guan 已提交
85
  SMnodeCfg         cfg;
86
  int64_t           checkTime;
87 88
  SSdb             *pSdb;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
89
  SArray           *pSteps;
S
Shengliang Guan 已提交
90
  SShowMgmt         showMgmt;
S
Shengliang Guan 已提交
91
  SProfileMgmt      profileMgmt;
S
Shengliang Guan 已提交
92
  STelemMgmt        telemMgmt;
S
Shengliang Guan 已提交
93
  SSyncMgmt         syncMgmt;
H
Hongze Cheng 已提交
94
  MndMsgFp          msgFp[TDMT_MAX];
S
Shengliang Guan 已提交
95 96 97 98
  SendReqToDnodeFp  sendReqToDnodeFp;
  SendReqToMnodeFp  sendReqToMnodeFp;
  SendRedirectRspFp sendRedirectRspFp;
  PutReqToMWriteQFp putReqToMWriteQFp;
H
Haojun Liao 已提交
99
  PutReqToMReadQFp  putReqToMReadQFp;
S
Shengliang Guan 已提交
100
} SMnode;
S
Shengliang Guan 已提交
101

S
Shengliang Guan 已提交
102 103 104 105
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 已提交
106

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

H
refact  
Hongze Cheng 已提交
109 110 111 112
#ifdef __cplusplus
}
#endif

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