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

S
monitor  
Shengliang Guan 已提交
19 20
#include "monitor.h"

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

S
Shengliang Guan 已提交
25
/* ------------------------ TYPES EXPOSED ------------------------ */
S
shm  
Shengliang Guan 已提交
26 27
typedef struct SMgmtWrapper SMgmtWrapper;
typedef struct SMnode       SMnode;
S
Shengliang Guan 已提交
28

29
typedef struct {
S
shm  
Shengliang Guan 已提交
30 31 32 33 34
  int32_t        dnodeId;
  int64_t        clusterId;
  int8_t         replica;
  int8_t         selfIndex;
  SReplica       replicas[TSDB_MAX_REPLICA];
S
shm  
Shengliang Guan 已提交
35 36 37
  SMgmtWrapper  *pWrapper;
  PutToQueueFp   putToWriteQFp;
  PutToQueueFp   putToReadQFp;
S
shm  
Shengliang Guan 已提交
38
  SendReqFp      sendReqFp;
S
shm  
Shengliang Guan 已提交
39 40
  SendMnodeReqFp sendMnodeReqFp;
  SendRspFp      sendRspFp;
S
Shengliang Guan 已提交
41
} SMnodeOpt;
S
Shengliang Guan 已提交
42 43 44 45 46

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

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

/**
S
Shengliang Guan 已提交
61
 * @brief Close a mnode.
S
Shengliang Guan 已提交
62
 *
S
Shengliang Guan 已提交
63 64 65
 * @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 已提交
66
 */
67
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
68 69

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

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

S
Shengliang Guan 已提交
88
/**
S
Shengliang Guan 已提交
89
 * @brief Get user authentication info.
S
Shengliang Guan 已提交
90
 *
S
Shengliang Guan 已提交
91
 * @param pMnode The mnode object.
S
Shengliang Guan 已提交
92 93 94 95 96
 * @param user
 * @param spi
 * @param encrypt
 * @param secret
 * @param ckey
S
Shengliang Guan 已提交
97
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
98
 */
99
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
S
Shengliang Guan 已提交
100

S
Shengliang Guan 已提交
101
/**
S
Shengliang Guan 已提交
102
 * @brief Process the read, write, sync request.
S
Shengliang Guan 已提交
103
 *
S
Shengliang Guan 已提交
104 105
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
106
 */
S
Shengliang Guan 已提交
107
int32_t mndProcessMsg(SNodeMsg *pMsg);
S
Shengliang Guan 已提交
108

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

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