提交 1d7b85d9 编写于 作者: H Hongze Cheng

refact

上级 e4955083
......@@ -16,13 +16,14 @@
#ifndef _TD_VNODE_COMMIT_H_
#define _TD_VNODE_COMMIT_H_
#include "vnodeInt.h"
#include "vnode.h"
#ifdef __cplusplus
extern "C" {
#endif
int vnodeAsyncCommit(SVnode *pVnode);
bool vnodeShouldCommit(SVnode *pVnode);
int vnodeAsyncCommit(SVnode *pVnode);
#ifdef __cplusplus
}
......
......@@ -16,10 +16,12 @@
#ifndef _TD_VNODE_DEF_H_
#define _TD_VNODE_DEF_H_
#include "mallocator.h"
#include "vnode.h"
#include "vnodeAllocatorPool.h"
#include "vnodeOptions.h"
#include "vnodeStateMgr.h"
#include "vnodeCommit.h"
#ifdef __cplusplus
extern "C" {
......@@ -30,7 +32,7 @@ struct SVnode {
SVnodeOptions options;
SVState state;
SVAllocatorPool pool;
SVMemAllocator* inuse;
SMemAllocator* inuse;
SMeta* pMeta;
STsdb* pTsdb;
STQ* pTq;
......
......@@ -13,13 +13,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
#include "vnodeDef.h"
static int vnodeStartCommit(SVnode *pVnode);
static int vnodeEndCommit(SVnode *pVnode);
bool vnodeShouldCommit(SVnode *pVnode) { return false; }
int vnodeAsyncCommit(SVnode *pVnode) {
#if 0
#if 0
if (vnodeStartCommit(pVnode) < 0) {
// TODO
}
......
......@@ -21,9 +21,39 @@ int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) {
}
int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) {
int type;
/* TODO */
return 0;
int reqType; /* TODO */
size_t reqSize; /* TODO */
int code = 0;
// Copy the request to vnode buffer
SRequest *pReq = mMalloc(pVnode->inuse, reqSize);
if (pReq == NULL) {
// TODO: handle error
}
// Push the request to TQ so consumers can consume
tqPushMsg(pVnode->pTq, pReq, 0);
// Process the request
switch (reqType) {
case TSDB_MSG_TYPE_CREATE_TABLE:
code = metaCreateTable(pVnode->pMeta, NULL /* TODO */);
break;
case TSDB_MSG_TYPE_DROP_TABLE:
code = metaDropTable(pVnode->pMeta, 0 /* TODO */);
break;
/* TODO */
default:
break;
}
if (vnodeShouldCommit(pVnode)) {
if (vnodeAsyncCommit(pVnode) < 0) {
// TODO: handle error
}
}
return code;
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册