mnode.h 3.7 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 26 27
/* ------------------------ TYPES EXPOSED ------------------------ */
typedef struct SDnode    SDnode;
typedef struct SMnode    SMnode;
S
Shengliang Guan 已提交
28
typedef struct SMnodeMsg SMnodeMsg;
S
Shengliang Guan 已提交
29 30 31
typedef int32_t (*SendReqToDnodeFp)(SDnode *pDnode, struct SEpSet *epSet, struct SRpcMsg *rpcMsg);
typedef int32_t (*SendReqToMnodeFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
typedef int32_t (*PutReqToMWriteQFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
L
Liu Jicong 已提交
32
typedef int32_t (*PutReqToMReadQFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
S
Shengliang Guan 已提交
33
typedef void (*SendRedirectRspFp)(SDnode *pDnode, struct SRpcMsg *rpcMsg);
S
Shengliang Guan 已提交
34

35
typedef struct {
S
Shengliang Guan 已提交
36
  int32_t           dnodeId;
S
Shengliang Guan 已提交
37
  int64_t           clusterId;
S
Shengliang Guan 已提交
38 39 40 41
  int8_t            replica;
  int8_t            selfIndex;
  SReplica          replicas[TSDB_MAX_REPLICA];
  SDnode           *pDnode;
S
Shengliang Guan 已提交
42
  PutReqToMWriteQFp putReqToMWriteQFp;
L
Liu Jicong 已提交
43
  PutReqToMReadQFp  putReqToMReadQFp;
S
Shengliang Guan 已提交
44 45 46
  SendReqToDnodeFp  sendReqToDnodeFp;
  SendReqToMnodeFp  sendReqToMnodeFp;
  SendRedirectRspFp sendRedirectRspFp;
S
Shengliang Guan 已提交
47
} SMnodeOpt;
S
Shengliang Guan 已提交
48 49 50 51 52

/* ------------------------ SMnode ------------------------ */
/**
 * @brief Open a mnode.
 *
S
Shengliang Guan 已提交
53 54 55
 * @param path Path of the mnode.
 * @param pOption Option of the mnode.
 * @return SMnode* The mnode object.
S
Shengliang Guan 已提交
56
 */
57
SMnode *mndOpen(const char *path, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
58 59

/**
S
Shengliang Guan 已提交
60
 * @brief Close a mnode.
S
Shengliang Guan 已提交
61
 *
S
Shengliang Guan 已提交
62
 * @param pMnode The mnode object to close.
S
Shengliang Guan 已提交
63
 */
64
void mndClose(SMnode *pMnode);
S
Shengliang Guan 已提交
65 66

/**
S
Shengliang Guan 已提交
67
 * @brief Close a mnode.
S
Shengliang Guan 已提交
68
 *
S
Shengliang Guan 已提交
69 70 71
 * @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 已提交
72
 */
73
int32_t mndAlter(SMnode *pMnode, const SMnodeOpt *pOption);
S
Shengliang Guan 已提交
74 75 76 77 78 79

/**
 * @brief Drop a mnode.
 *
 * @param path Path of the mnode.
 */
80
void mndDestroy(const char *path);
S
Shengliang Guan 已提交
81 82

/**
S
monitor  
Shengliang Guan 已提交
83
 * @brief Get mnode monitor info.
S
Shengliang Guan 已提交
84
 *
S
Shengliang Guan 已提交
85
 * @param pMnode The mnode object.
S
monitor  
Shengliang Guan 已提交
86 87 88
 * @param pClusterInfo
 * @param pVgroupInfo
 * @param pGrantInfo
S
Shengliang Guan 已提交
89
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
90
 */
S
monitor  
Shengliang Guan 已提交
91 92
int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgroupInfo *pVgroupInfo,
                          SMonGrantInfo *pGrantInfo);
S
Shengliang Guan 已提交
93

S
Shengliang Guan 已提交
94
/**
S
Shengliang Guan 已提交
95
 * @brief Get user authentication info.
S
Shengliang Guan 已提交
96
 *
S
Shengliang Guan 已提交
97
 * @param pMnode The mnode object.
S
Shengliang Guan 已提交
98 99 100 101 102
 * @param user
 * @param spi
 * @param encrypt
 * @param secret
 * @param ckey
S
Shengliang Guan 已提交
103
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
104
 */
105
int32_t mndRetriveAuth(SMnode *pMnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
S
Shengliang Guan 已提交
106

S
Shengliang Guan 已提交
107
/**
S
Shengliang Guan 已提交
108
 * @brief Initialize mnode msg.
S
Shengliang Guan 已提交
109
 *
S
Shengliang Guan 已提交
110 111 112
 * @param pMnode The mnode object.
 * @param pMsg The request rpc msg.
 * @return int32_t The created mnode msg.
S
Shengliang Guan 已提交
113
 */
114
SMnodeMsg *mndInitMsg(SMnode *pMnode, SRpcMsg *pRpcMsg);
S
Shengliang Guan 已提交
115

S
Shengliang Guan 已提交
116
/**
S
Shengliang Guan 已提交
117
 * @brief Cleanup mnode msg.
S
Shengliang Guan 已提交
118
 *
S
Shengliang Guan 已提交
119
 * @param pMsg The request msg.
S
Shengliang Guan 已提交
120
 */
121
void mndCleanupMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
122 123

/**
S
Shengliang Guan 已提交
124
 * @brief Cleanup mnode msg.
S
Shengliang Guan 已提交
125
 *
S
Shengliang Guan 已提交
126 127
 * @param pMsg The request msg.
 * @param code The error code.
S
Shengliang Guan 已提交
128
 */
129
void mndSendRsp(SMnodeMsg *pMsg, int32_t code);
S
Shengliang Guan 已提交
130

S
Shengliang Guan 已提交
131
/**
S
Shengliang Guan 已提交
132
 * @brief Process the read, write, sync request.
S
Shengliang Guan 已提交
133
 *
S
Shengliang Guan 已提交
134 135
 * @param pMsg The request msg.
 * @return int32_t 0 for success, -1 for failure.
S
Shengliang Guan 已提交
136
 */
S
Shengliang Guan 已提交
137
void mndProcessMsg(SMnodeMsg *pMsg);
S
Shengliang Guan 已提交
138

H
refact  
Hongze Cheng 已提交
139 140 141 142
#ifdef __cplusplus
}
#endif

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