提交 72777848 编写于 作者: H Hongze Cheng

refact

上级 84fb0da7
...@@ -17,9 +17,10 @@ ...@@ -17,9 +17,10 @@
#define _TD_VNODE_H_ #define _TD_VNODE_H_
#include "os.h" #include "os.h"
#include "trequest.h" #include "trpc.h"
#include "meta.h" #include "meta.h"
#include "tarray.h"
#include "tq.h" #include "tq.h"
#include "tsdb.h" #include "tsdb.h"
...@@ -32,17 +33,71 @@ typedef struct SVnode SVnode; ...@@ -32,17 +33,71 @@ typedef struct SVnode SVnode;
typedef struct SVnodeOptions SVnodeOptions; typedef struct SVnodeOptions SVnodeOptions;
/* ------------------------ SVnode ------------------------ */ /* ------------------------ 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); SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions);
void vnodeClose(SVnode *pVnode);
void vnodeDestroy(const char *path); /**
int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch); * @brief Close a VNODE
int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest); *
int vnodeProcessReadReq(SVnode *pVnode, SRequest *pReq); * @param pVnode The vnode object
int vnodeProcessSyncReq(SVnode *pVnode, SRequest *pReq); */
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 ------------------------ */ /* ------------------------ 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 DEFINITIONS ------------------------ */
struct SVnodeOptions { struct SVnodeOptions {
......
...@@ -15,24 +15,24 @@ ...@@ -15,24 +15,24 @@
#include "vnodeDef.h" #include "vnodeDef.h"
int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { int vnodeProcessWMsgs(SVnode *pVnode, SArray *pMsgs) {
/* TODO */ /* TODO */
return 0; return 0;
} }
int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
int reqType; /* TODO */ int reqType; /* TODO */
size_t reqSize; /* TODO */ size_t reqSize; /* TODO */
uint64_t reqVersion = 0; /* TODO */ uint64_t reqVersion = 0; /* TODO */
int code = 0; int code = 0;
// Copy the request to vnode buffer // Copy the request to vnode buffer
SRequest *pReq = mMalloc(pVnode->inuse, reqSize); void *pReq = mMalloc(pVnode->inuse, reqSize);
if (pReq == NULL) { if (pReq == NULL) {
// TODO: handle error // TODO: handle error
} }
memcpy(pReq, pRequest, reqSize); memcpy(pReq, pMsg, reqSize);
// Push the request to TQ so consumers can consume // Push the request to TQ so consumers can consume
tqPushMsg(pVnode->pTq, pReq, 0); tqPushMsg(pVnode->pTq, pReq, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册