mndInt.h 2.0 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"
21
#include "tqueue.h"
S
Shengliang Guan 已提交
22

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

S
Shengliang Guan 已提交
27
typedef int32_t (*MndMsgFp)(SMnode *pMnode, SMnodeMsg *pMsg);
28 29
typedef int32_t (*MndInitFp)(SMnode *pMnode);
typedef void (*MndCleanupFp)(SMnode *pMnode);
S
Shengliang Guan 已提交
30

31 32 33 34 35
typedef struct {
  const char  *name;
  MndInitFp    initFp;
  MndCleanupFp cleanupFp;
} SMnodeStep;
S
Shengliang Guan 已提交
36

S
Shengliang Guan 已提交
37
typedef struct SMnode {
S
Shengliang Guan 已提交
38 39 40 41 42 43
  int32_t           dnodeId;
  int64_t           clusterId;
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  tmr_h             timer;
S
Shengliang Guan 已提交
44
  char             *path;
45 46
  SSdb             *pSdb;
  SDnode           *pDnode;
S
Shengliang Guan 已提交
47
  SArray           *pSteps;
S
Shengliang Guan 已提交
48
  MndMsgFp          msgFp[TSDB_MSG_TYPE_MAX];
S
Shengliang Guan 已提交
49 50 51
  SendMsgToDnodeFp  sendMsgToDnodeFp;
  SendMsgToMnodeFp  sendMsgToMnodeFp;
  SendRedirectMsgFp sendRedirectMsgFp;
52
  PutMsgToMnodeQFp  putMsgToApplyMsgFp;
S
Shengliang Guan 已提交
53
} SMnode;
S
Shengliang Guan 已提交
54

55 56 57
tmr_h   mndGetTimer(SMnode *pMnode);
int32_t mndGetDnodeId(SMnode *pMnode);
int64_t mndGetClusterId(SMnode *pMnode);
S
Shengliang Guan 已提交
58

59 60 61 62
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 已提交
63

H
refact  
Hongze Cheng 已提交
64 65 66 67
#ifdef __cplusplus
}
#endif

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