From daafc0feb7f71df4d96e7bbdd5562e5a8df5dc93 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 29 Sep 2021 19:26:11 +0800 Subject: [PATCH] [TD-10430] interface of dnode/mnode/vnode module --- include/server/dnode/dnode.h | 34 ++++----- include/server/mnode/mnode.h | 131 +++++++++++++++++++++++++++++------ include/server/vnode/vnode.h | 94 ++++++++++++++++++++----- 3 files changed, 203 insertions(+), 56 deletions(-) diff --git a/include/server/dnode/dnode.h b/include/server/dnode/dnode.h index 711b6d92a5..08658f3542 100644 --- a/include/server/dnode/dnode.h +++ b/include/server/dnode/dnode.h @@ -21,53 +21,53 @@ extern "C" { #endif /** - * Initialize and start the dnode module + * Initialize and start the dnode module. * - * @return Instance of dnode module + * @return Instance of dnode module. */ struct Dnode *dnodeCreateInstance(); /** - * Stop and cleanup dnode module + * Stop and cleanup dnode module. * - * @param dnode Instance of dnode module + * @param dnode, instance of dnode module. */ void dnodeCleanupInstance(struct Dnode *dnode); /** * 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. + * @param dnode, the instance of Dnode module. + * @param epSet, the endpoint list of the dnodes. + * @param rpcMsg, message to be sent. */ void dnodeSendMsgToDnode(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. + * @param dnode, the instance of dnode module. + * @param rpcMsg, message to be sent. */ void dnodeSendMsgToMnode(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. + * @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 dnodeSendRedirectMsg(struct Dnode *dnode, struct SRpcMsg *rpcMsg, bool forShell); /** * Get the corresponding endpoint information from dnodeId. * - * @param dnode The instance of Dnode 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 + * @param dnode, the instance of dnode 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 dnodeGetDnodeEp(struct Dnode *dnode, int32_t dnodeId, char *ep, char *fqdn, uint16_t *port); diff --git a/include/server/mnode/mnode.h b/include/server/mnode/mnode.h index 0d2fd00ba1..d9135f00e6 100644 --- a/include/server/mnode/mnode.h +++ b/include/server/mnode/mnode.h @@ -20,49 +20,140 @@ extern "C" { #endif -struct SRpcMsg; +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; /** - * Deploy Mnode instances in Dnode. - * - * @return Error Code. + * Initialize and start mnode module. + * + * @param para, initialization parameters. + * @return Instance of mnode module. */ -int32_t mnodeDeploy(); +struct Mnode *mnodeCreateInstance(SMnodePara para); /** - * Delete the Mnode instance deployed in Dnode. + * Stop and cleanup mnode module. + * + * @param mnode, instance of mnode module. */ -void mnodeUnDeploy(); +void mnodeCleanupInstance(struct Mnode *vnode); /** - * Start Mnode service. - * + * Deploy mnode instances in dnode. + * + * @param mnode, instance of mnode module. + * @param minfos, server information used to deploy the mnode instance. * @return Error Code. */ -int32_t mnodeStart(); +int32_t mnodeDeploy(struct Mnode *mnode, struct SMInfos *minfos); /** - * Stop Mnode service. + * Delete the mnode instance deployed in dnode. + * + * @param mnode, instance of mnode module. */ -int32_t mnodeStop(); +void mnodeUnDeploy(struct Mnode *mnode); /** * Interface for processing messages. - * - * @param pMsg Message to be processed. - * @return Error code + * + * @param mnode, instance of mnode module. + * @param rpcMsg, message to be processed. + * @return Error code. */ -int32_t mnodeProcessMsg(SRpcMsg *pMsg); +void mnodeProcessMsg(struct Mnode *mnode, SRpcMsg *rpcMsg); /** - * Whether the Mnode is in service. - * + * Whether the mnode is in service. + * + * @param mnode, instance of mnode module. * @return Server status. */ -bool mnodeIsServing(); +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); #ifdef __cplusplus } #endif -#endif /*_TD_MNODE_H_*/ \ No newline at end of file +#endif /*_TD_MNODE_H_*/ diff --git a/include/server/vnode/vnode.h b/include/server/vnode/vnode.h index 4a848add59..748b93c8eb 100644 --- a/include/server/vnode/vnode.h +++ b/include/server/vnode/vnode.h @@ -20,43 +20,99 @@ extern "C" { #endif -struct SRpcMsg; +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 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); + + /** + * Get the corresponding endpoint information from dnodeId. + * + * @param dnode, the instance of dnode 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); + +} SVnodeFp; + +typedef struct { + struct Dnode *dnode; + SVnodeFp fp; +} SVnodePara; /** - * Start Initialize Vnode module. + * Start initialize vnode module. * - * @return Error Code. + * @param para, initialization parameters. + * @return Instance of vnode module. */ -int32_t vnodeInit(); - +struct Vnode *vnodeCreateInstance(SVnodePara para); + /** - * Cleanup Vnode module. + * Cleanup vnode module. + * + * @param vnode, instance of vnode module. */ -void vnodeCleanup(); - +void vnodeCleanupInstance(struct Vnode *vnode); + typedef struct { - int64_t queryMsgCount; - int64_t writeMsgCount; + int32_t unused; } SVnodeStat; - + /** - * Get the statistical information of Vnode + * Get the statistical information of vnode. * - * @param stat Statistical information. + * @param vnode, instance of vnode module. + * @param sta, statistical information. * @return Error Code. */ -int32_t vnodeGetStatistics(SVnodeStat *stat); +int32_t vnodeGetStatistics(struct Vnode *vnode, SVnodeStat *stat); -/** +/** * Interface for processing messages. * - * @param pMsg Message to be processed. - * @return Error code + * @param vnode, instance of vnode module. + * @param msg, message to be processed. + */ +void vnodeProcessMsg(struct Vnode *vnode, SRpcMsg *msg); + +/** + * Get the status of all vnodes. + * + * @param vnode, instance of vnode module. + * @param status, status msg. + */ +void vnodeGetStatus(struct Vnode *vnode, struct SStatusMsg *status); + +/** + * Set access permissions for all vnodes. + * + * @param vnode, instance of vnode module. + * @param access, access permissions of vnodes. + * @param numOfVnodes, the size of vnodes. */ -int32_t vnodeProcessMsg(SRpcMsg *pMsg); +void vnodeSetAccess(struct Vnode *vnode, struct SVgroupAccess *access, int32_t numOfVnodes); #ifdef __cplusplus } #endif -#endif /*_TD_VNODE_H_*/ \ No newline at end of file +#endif /*_TD_VNODE_H_*/ -- GitLab