mnode.h 4.1 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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/>.
 */

#ifndef _TD_MNODE_H_
#define _TD_MNODE_H_

#ifdef __cplusplus
extern "C" {
#endif

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
struct Dnode;

typedef struct {
  /**
   * Send messages to other dnodes, such as create vnode message.
   *
   * @param dnode, the instance of dnode module.
   * @param epSet, the endpoint list of the dnodes.
   * @param rpcMsg, message to be sent.
   */
  void (*SendMsgToDnode)(struct Dnode *dnode, struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);

  /**
   * Send messages to mnode, such as config message.
   *
   * @param dnode, the instance of dnode module.
   * @param rpcMsg, message to be sent.
   */
  void (*SendMsgToMnode)(struct Dnode *dnode, struct SRpcMsg *rpcMsg);

  /**
   * Send redirect message to dnode or shell.
   *
   * @param dnode, the instance of dnode module.
   * @param rpcMsg, message to be sent.
   * @param forShell, used to identify whether to send to shell or dnode.
   */
  void (*SendRedirectMsg)(struct Dnode *dnode, struct SRpcMsg *rpcMsg, bool forShell);

  /**
   * Get the corresponding endpoint information from dnodeId.
   *
   * @param dnode, the instance of dDnode module.
   * @param dnodeId, the id ot dnode.
   * @param ep, the endpoint of dnode.
   * @param fqdn, the fqdn of dnode.
   * @param port, the port of dnode.
   */
  void (*GetDnodeEp)(struct Dnode *dnode, int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);

} SMnodeFp;

typedef struct {
  struct Dnode *dnode;
  SMnodeFp      fp;
  char          clusterId[TSDB_CLUSTER_ID_LEN];
  int32_t       dnodeId;
} SMnodePara;
S
Shengliang Guan 已提交
71 72

/**
73 74 75 76
 * Initialize and start mnode module.
 *
 * @param para, initialization parameters.
 * @return Instance of mnode module.
S
Shengliang Guan 已提交
77
 */
78
struct Mnode *mnodeCreateInstance(SMnodePara para);
S
Shengliang Guan 已提交
79 80

/**
81 82 83
 * Stop and cleanup mnode module.
 *
 * @param mnode, instance of mnode module.
S
Shengliang Guan 已提交
84
 */
85
void mnodeCleanupInstance(struct Mnode *vnode);
S
Shengliang Guan 已提交
86 87

/**
88 89 90 91
 * Deploy mnode instances in dnode.
 *
 * @param mnode, instance of mnode module.
 * @param minfos, server information used to deploy the mnode instance.
S
Shengliang Guan 已提交
92 93
 * @return Error Code.
 */
94
int32_t mnodeDeploy(struct Mnode *mnode, struct SMInfos *minfos);
S
Shengliang Guan 已提交
95 96

/**
97 98 99
 * Delete the mnode instance deployed in dnode.
 *
 * @param mnode, instance of mnode module.
S
Shengliang Guan 已提交
100
 */
101
void mnodeUnDeploy(struct Mnode *mnode);
S
Shengliang Guan 已提交
102 103 104

/**
 * Interface for processing messages.
105 106 107 108
 *
 * @param mnode, instance of mnode module.
 * @param rpcMsg, message to be processed.
 * @return Error code.
S
Shengliang Guan 已提交
109
 */
110
void mnodeProcessMsg(struct Mnode *mnode, SRpcMsg *rpcMsg);
S
Shengliang Guan 已提交
111 112

/**
113 114 115
 * Whether the mnode is in service.
 *
 * @param mnode, instance of mnode module.
S
Shengliang Guan 已提交
116 117
 * @return Server status.
 */
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
bool mnodeIsServing(struct Mnode *mnode);

typedef struct {
  int64_t numOfDnode;
  int64_t numOfMnode;
  int64_t numOfVgroup;
  int64_t numOfDatabase;
  int64_t numOfSuperTable;
  int64_t numOfChildTable;
  int64_t numOfColumn;
  int64_t totalPoints;
  int64_t totalStorage;
  int64_t compStorage;
} SMnodeStat;

/**
 * Get the statistical information of Mnode.
 *
 * @param mnode, instance of mnode module.
 * @param stat, statistical information.
 * @return Error Code.
 */
int32_t mnodeGetStatistics(struct Mnode *mnode, SMnodeStat *stat);

/**
 * Get the statistical information of Mnode.
 *
 * @param mnode, instance of mnode module.
 * @param user, username.
 * @param spi,  security parameter index.
 * @param encrypt, encrypt algorithm.
 * @param secret, key for authentication.
 * @param ckey, ciphering key.
 * @return Error Code.
 */
int32_t mnodeRetriveAuth(struct Mnode *mnode, char *user, char *spi, char *encrypt, char *secret, char *ckey);
S
Shengliang Guan 已提交
154

H
refact  
Hongze Cheng 已提交
155 156 157 158
#ifdef __cplusplus
}
#endif

159
#endif /*_TD_MNODE_H_*/