mnode.h 2.5 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_H_
#define _TD_MND_H_
H
refact  
Hongze Cheng 已提交
18

S
monitor  
Shengliang Guan 已提交
19
#include "monitor.h"
L
Liu Jicong 已提交
20
#include "tmsg.h"
S
Shengliang Guan 已提交
21
#include "tmsgcb.h"
L
Liu Jicong 已提交
22
#include "trpc.h"
S
monitor  
Shengliang Guan 已提交
23

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

S
Shengliang Guan 已提交
28
/* ------------------------ TYPES EXPOSED ------------------------ */
S
Shengliang Guan 已提交
29
typedef struct SMnode SMnode;
S
Shengliang Guan 已提交
30

31
typedef struct {
32
  int32_t  dnodeId;
S
Shengliang Guan 已提交
33
  bool     standby;
S
shm  
Shengliang Guan 已提交
34
  bool     deploy;
S
Shengliang Guan 已提交
35 36 37 38
  int8_t   replica;
  int8_t   selfIndex;
  SReplica replicas[TSDB_MAX_REPLICA];
  SMsgCb   msgCb;
S
Shengliang Guan 已提交
39
} SMnodeOpt;
S
Shengliang Guan 已提交
40 41 42 43 44

/* ------------------------ SMnode ------------------------ */
/**
 * @brief Open a mnode.
 *
S
Shengliang Guan 已提交
45 46 47
 * @param path Path of the mnode.
 * @param pOption Option of the mnode.
 * @return SMnode* The mnode object.
S
Shengliang Guan 已提交
48
 */
49
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
50 51

/**
S
Shengliang Guan 已提交
52
 * @brief Close a mnode.
S
Shengliang Guan 已提交
53
 *
S
Shengliang Guan 已提交
54
 * @param pMnode The mnode object to close.
S
Shengliang Guan 已提交
55
 */
56
void mndClose(SMnode *pMnode);
S
Shengliang Guan 已提交
57 58

/**
S
Shengliang Guan 已提交
59
 * @brief Close a mnode.
S
Shengliang Guan 已提交
60
 *
S
Shengliang Guan 已提交
61 62 63
 * @param pMnode The mnode object to close.
 * @param pOption Options of the mnode.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
64
 */
65
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
66 67

/**
S
shm  
Shengliang Guan 已提交
68
 * @brief Start mnode
S
Shengliang Guan 已提交
69
 *
S
shm  
Shengliang Guan 已提交
70
 * @param pMnode The mnode object.
S
Shengliang Guan 已提交
71
 */
S
shm  
Shengliang Guan 已提交
72
int32_t mndStart(SMnode *pMnode);
S
Shengliang Guan 已提交
73
void    mndStop(SMnode *pMnode);
S
Shengliang Guan 已提交
74 75

/**
S
monitor  
Shengliang Guan 已提交
76
 * @brief Get mnode monitor info.
S
Shengliang Guan 已提交
77
 *
S
Shengliang Guan 已提交
78
 * @param pMnode The mnode object.
79 80 81
 * @param pCluster
 * @param pVgroup
 * @param pGrant
S
Shengliang Guan 已提交
82
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
83
 */
84
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pCluster, SMonVgroupInfo *pVgroup, SMonGrantInfo *pGrant);
S
Shengliang Guan 已提交
85
int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
S
Shengliang Guan 已提交
86

S
Shengliang Guan 已提交
87
/**
S
Shengliang Guan 已提交
88
 * @brief Process the read, write, sync request.
S
Shengliang Guan 已提交
89
 *
S
Shengliang Guan 已提交
90 91
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
92
 */
S
Shengliang Guan 已提交
93
int32_t mndProcessMsg(SRpcMsg *pMsg);
M
Minghao Li 已提交
94
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
M
Minghao Li 已提交
95

S
Shengliang Guan 已提交
96 97 98 99 100
/**
 * @brief Generate machine code
 */
void mndGenerateMachineCode();

H
refact  
Hongze Cheng 已提交
101 102 103 104
#ifdef __cplusplus
}
#endif

S
Shengliang Guan 已提交
105
#endif /*_TD_MND_H_*/