mnode.h 3.4 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

S
Shengliang Guan 已提交
23 24
typedef enum { MN_STATUS_UNINIT = 0, MN_STATUS_INIT = 1, MN_STATUS_READY = 2, MN_STATUS_CLOSING = 3 } EMnStatus;

25 26 27 28 29 30 31
typedef struct {
  /**
   * Send messages to other dnodes, such as create vnode message.
   *
   * @param epSet, the endpoint list of the dnodes.
   * @param rpcMsg, message to be sent.
   */
32
  void (*SendMsgToDnode)(struct SRpcEpSet *epSet, struct SRpcMsg *rpcMsg);
33 34 35 36 37 38

  /**
   * Send messages to mnode, such as config message.
   *
   * @param rpcMsg, message to be sent.
   */
39
  void (*SendMsgToMnode)(struct SRpcMsg *rpcMsg);
40 41 42 43 44 45 46

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

S
Shengliang Guan 已提交
49 50 51 52 53 54 55 56 57 58
  /**
   * 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)(int32_t dnodeId, char *ep, char *fqdn, uint16_t *port);
59 60 61
} SMnodeFp;

typedef struct {
S
Shengliang Guan 已提交
62
  SMnodeFp fp;
S
Shengliang Guan 已提交
63
  int64_t  clusterId;
S
Shengliang Guan 已提交
64
  int32_t  dnodeId;
65
} SMnodePara;
S
Shengliang Guan 已提交
66 67

/**
68 69 70
 * Initialize and start mnode module.
 *
 * @param para, initialization parameters.
71
 * @return Error code.
S
Shengliang Guan 已提交
72
 */
73
int32_t mnodeInit(SMnodePara para);
S
Shengliang Guan 已提交
74 75

/**
76
 * Stop and cleanup mnode module.
S
Shengliang Guan 已提交
77
 */
78
void mnodeCleanup();
S
Shengliang Guan 已提交
79 80

/**
81 82
 * Deploy mnode instances in dnode.
 *
S
Shengliang Guan 已提交
83 84
 * @return Error Code.
 */
S
Shengliang Guan 已提交
85
int32_t mnodeDeploy();
S
Shengliang Guan 已提交
86 87

/**
88
 * Delete the mnode instance deployed in dnode.
S
Shengliang Guan 已提交
89
 */
90
void mnodeUnDeploy();
S
Shengliang Guan 已提交
91 92

/**
93 94
 * Whether the mnode is in service.
 *
S
Shengliang Guan 已提交
95 96
 * @return Server status.
 */
S
Shengliang Guan 已提交
97
EMnStatus mnodeGetStatus();
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

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 stat, statistical information.
 * @return Error Code.
 */
118
int32_t mnodeGetStatistics(SMnodeStat *stat);
119 120

/**
S
Shengliang Guan 已提交
121
 * Get the auth information of Mnode.
122 123 124 125 126 127 128 129
 *
 * @param user, username.
 * @param spi,  security parameter index.
 * @param encrypt, encrypt algorithm.
 * @param secret, key for authentication.
 * @param ckey, ciphering key.
 * @return Error Code.
 */
130
int32_t mnodeRetriveAuth(char *user, char *spi, char *encrypt, char *secret, char *ckey);
S
Shengliang Guan 已提交
131

132 133 134 135 136 137
/**
 * Interface for processing messages.
 *
 * @param rpcMsg, message to be processed.
 * @return Error code.
 */
138
void mnodeProcessMsg(SRpcMsg *rpcMsg);
139

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

144
#endif /*_TD_MNODE_H_*/