refact
This commit is contained in:
parent
e495508337
commit
1d7b85d930
|
@ -16,13 +16,14 @@
|
||||||
#ifndef _TD_VNODE_COMMIT_H_
|
#ifndef _TD_VNODE_COMMIT_H_
|
||||||
#define _TD_VNODE_COMMIT_H_
|
#define _TD_VNODE_COMMIT_H_
|
||||||
|
|
||||||
#include "vnodeInt.h"
|
#include "vnode.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int vnodeAsyncCommit(SVnode *pVnode);
|
bool vnodeShouldCommit(SVnode *pVnode);
|
||||||
|
int vnodeAsyncCommit(SVnode *pVnode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,10 +16,12 @@
|
||||||
#ifndef _TD_VNODE_DEF_H_
|
#ifndef _TD_VNODE_DEF_H_
|
||||||
#define _TD_VNODE_DEF_H_
|
#define _TD_VNODE_DEF_H_
|
||||||
|
|
||||||
|
#include "mallocator.h"
|
||||||
#include "vnode.h"
|
#include "vnode.h"
|
||||||
#include "vnodeAllocatorPool.h"
|
#include "vnodeAllocatorPool.h"
|
||||||
#include "vnodeOptions.h"
|
#include "vnodeOptions.h"
|
||||||
#include "vnodeStateMgr.h"
|
#include "vnodeStateMgr.h"
|
||||||
|
#include "vnodeCommit.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,7 +32,7 @@ struct SVnode {
|
||||||
SVnodeOptions options;
|
SVnodeOptions options;
|
||||||
SVState state;
|
SVState state;
|
||||||
SVAllocatorPool pool;
|
SVAllocatorPool pool;
|
||||||
SVMemAllocator* inuse;
|
SMemAllocator* inuse;
|
||||||
SMeta* pMeta;
|
SMeta* pMeta;
|
||||||
STsdb* pTsdb;
|
STsdb* pTsdb;
|
||||||
STQ* pTq;
|
STQ* pTq;
|
||||||
|
|
|
@ -13,13 +13,15 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* 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 vnodeStartCommit(SVnode *pVnode);
|
||||||
static int vnodeEndCommit(SVnode *pVnode);
|
static int vnodeEndCommit(SVnode *pVnode);
|
||||||
|
|
||||||
|
bool vnodeShouldCommit(SVnode *pVnode) { return false; }
|
||||||
|
|
||||||
int vnodeAsyncCommit(SVnode *pVnode) {
|
int vnodeAsyncCommit(SVnode *pVnode) {
|
||||||
#if 0
|
#if 0
|
||||||
if (vnodeStartCommit(pVnode) < 0) {
|
if (vnodeStartCommit(pVnode) < 0) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,39 @@ int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) {
|
int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) {
|
||||||
int type;
|
int reqType; /* TODO */
|
||||||
/* TODO */
|
size_t reqSize; /* TODO */
|
||||||
return 0;
|
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 ------------------------ */
|
/* ------------------------ STATIC METHODS ------------------------ */
|
Loading…
Reference in New Issue