diff --git a/include/server/vnode/vnode.h b/include/server/vnode/vnode.h index 29e14a673a21c26251c615be7c5c3ae161b50377..1b1e1c1b0f69c417a5b221ff0453b3b013498734 100644 --- a/include/server/vnode/vnode.h +++ b/include/server/vnode/vnode.h @@ -17,9 +17,10 @@ #define _TD_VNODE_H_ #include "os.h" -#include "trequest.h" +#include "trpc.h" #include "meta.h" +#include "tarray.h" #include "tq.h" #include "tsdb.h" @@ -32,17 +33,71 @@ typedef struct SVnode SVnode; typedef struct SVnodeOptions SVnodeOptions; /* ------------------------ SVnode ------------------------ */ +/** + * @brief Open a VNODE. + * + * @param path path of the vnode + * @param pVnodeOptions options of the vnode + * @return SVnode* The vnode object + */ SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions); -void vnodeClose(SVnode *pVnode); -void vnodeDestroy(const char *path); -int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch); -int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest); -int vnodeProcessReadReq(SVnode *pVnode, SRequest *pReq); -int vnodeProcessSyncReq(SVnode *pVnode, SRequest *pReq); + +/** + * @brief Close a VNODE + * + * @param pVnode The vnode object + */ +void vnodeClose(SVnode *pVnode); + +/** + * @brief Destroy a VNODE. + * + * @param path Path of the VNODE. + */ +void vnodeDestroy(const char *path); + +/** + * @brief Process an array of write messages. + * + * @param pVnode The vnode object. + * @param pMsgs The array of SRpcMsg + * @return int 0 for success, -1 for failure + */ +int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs); + +/** + * @brief Apply a write request message. + * + * @param pVnode The vnode object. + * @param pMsg The request message + * @return int 0 for success, -1 for failure + */ +int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); + +/** + * @brief Process the sync request + * + * @param pVnode + * @param pMsg + * @param pRsp + * @return int + */ +int vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp); /* ------------------------ SVnodeOptions ------------------------ */ -void vnodeOptionsInit(SVnodeOptions *); -void vnodeOptionsClear(SVnodeOptions *); +/** + * @brief Initialize VNODE options. + * + * @param pOptions The options object to be initialized. It should not be NULL. + */ +void vnodeOptionsInit(SVnodeOptions *pOptions); + +/** + * @brief Clear VNODE options. + * + * @param pOptions Options to clear. + */ +void vnodeOptionsClear(SVnodeOptions *pOptions); /* ------------------------ STRUCT DEFINITIONS ------------------------ */ struct SVnodeOptions { diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index f3204cfd3706861299a7064f1a66b938be152d78..3d200b28d5d9598566119eb522d97baca65a74a1 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -15,24 +15,24 @@ #include "vnodeDef.h" -int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { +int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) { /* TODO */ return 0; } -int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { +int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { int reqType; /* TODO */ size_t reqSize; /* TODO */ uint64_t reqVersion = 0; /* TODO */ int code = 0; // Copy the request to vnode buffer - SRequest *pReq = mMalloc(pVnode->inuse, reqSize); + void *pReq = mMalloc(pVnode->inuse, reqSize); if (pReq == NULL) { // TODO: handle error } - memcpy(pReq, pRequest, reqSize); + memcpy(pReq, pMsg, reqSize); // Push the request to TQ so consumers can consume tqPushMsg(pVnode->pTq, pReq, 0);