From 5704d5e2ee63b700dd62b17d4adda8423e1d4bcb Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 8 Nov 2021 13:40:45 +0800 Subject: [PATCH] refact --- source/dnode/vnode/impl/inc/vnodeRequest.h | 27 ++++++++++++++++++++++ source/dnode/vnode/impl/src/vnodeMain.c | 24 ++++++++++++++++++- source/dnode/vnode/impl/src/vnodeOptions.c | 1 + source/dnode/vnode/impl/src/vnodeRequest.c | 14 +++++++++++ source/dnode/vnode/impl/src/vnodeWrite.c | 1 + source/dnode/vnode/meta/src/metaOptions.c | 6 ++--- 6 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 source/dnode/vnode/impl/inc/vnodeRequest.h create mode 100644 source/dnode/vnode/impl/src/vnodeRequest.c diff --git a/source/dnode/vnode/impl/inc/vnodeRequest.h b/source/dnode/vnode/impl/inc/vnodeRequest.h new file mode 100644 index 0000000000..af909fb636 --- /dev/null +++ b/source/dnode/vnode/impl/inc/vnodeRequest.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_VNODE_REQUEST_H_ +#define _TD_VNODE_REQUEST_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_VNODE_REQUEST_H_*/ \ No newline at end of file diff --git a/source/dnode/vnode/impl/src/vnodeMain.c b/source/dnode/vnode/impl/src/vnodeMain.c index cc9a1d76bc..392f8a2ba8 100644 --- a/source/dnode/vnode/impl/src/vnodeMain.c +++ b/source/dnode/vnode/impl/src/vnodeMain.c @@ -85,10 +85,32 @@ static void vnodeFree(SVnode *pVnode) { } static int vnodeOpenImpl(SVnode *pVnode) { + char dir[TSDB_FILENAME_LEN]; + + // Open meta + sprintf(dir, "%s/meta", pVnode->path); + if (metaOpen(dir, &(pVnode->options.metaOptions)) < 0) { + // TODO: handle error + return -1; + } + + // Open tsdb + sprintf(dir, "%s/tsdb", pVnode->path); + if (tsdbOpen(dir, &(pVnode->options.tsdbOptions)) < 0) { + // TODO: handle error + return -1; + } + + // TODO: Open TQ + // TODO return 0; } static void vnodeCloseImpl(SVnode *pVnode) { - // TODO + if (pVnode) { + // TODO: Close TQ + tsdbClose(pVnode->pTsdb); + metaClose(pVnode->pMeta); + } } \ No newline at end of file diff --git a/source/dnode/vnode/impl/src/vnodeOptions.c b/source/dnode/vnode/impl/src/vnodeOptions.c index d5f986d439..5f519416b9 100644 --- a/source/dnode/vnode/impl/src/vnodeOptions.c +++ b/source/dnode/vnode/impl/src/vnodeOptions.c @@ -18,6 +18,7 @@ const SVnodeOptions defaultVnodeOptions = {0}; /* TODO */ void vnodeOptionsInit(SVnodeOptions *pVnodeOptions) { /* TODO */ + vnodeOptionsCopy(pVnodeOptions, &defaultVnodeOptions); } void vnodeOptionsClear(SVnodeOptions *pVnodeOptions) { /* TODO */ diff --git a/source/dnode/vnode/impl/src/vnodeRequest.c b/source/dnode/vnode/impl/src/vnodeRequest.c new file mode 100644 index 0000000000..6dea4a4e57 --- /dev/null +++ b/source/dnode/vnode/impl/src/vnodeRequest.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ \ No newline at end of file diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index 486ff9c634..401c2add9c 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -21,6 +21,7 @@ int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { } int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { + int type; /* TODO */ return 0; } diff --git a/source/dnode/vnode/meta/src/metaOptions.c b/source/dnode/vnode/meta/src/metaOptions.c index 0f6ba9a9fb..f92cd73cae 100644 --- a/source/dnode/vnode/meta/src/metaOptions.c +++ b/source/dnode/vnode/meta/src/metaOptions.c @@ -13,11 +13,9 @@ * along with this program. If not, see . */ -#include "meta.h" +#include "metaDef.h" -const static SMetaOptions defaultMetaOptions = {.lruCacheSize = 0}; - -static void metaOptionsCopy(SMetaOptions *pDest, const SMetaOptions *pSrc); +const SMetaOptions defaultMetaOptions = {.lruCacheSize = 0}; /* ------------------------ EXPOSED METHODS ------------------------ */ void metaOptionsInit(SMetaOptions *pMetaOptions) { metaOptionsCopy(pMetaOptions, &defaultMetaOptions); } -- GitLab