From 2b5e0592c4d4efc7dd8adc1f4ec4d02b00a3f8c9 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 24 Nov 2021 16:29:02 +0800 Subject: [PATCH] refact --- include/dnode/vnode/tq/tq.h | 8 ++-- include/dnode/vnode/tsdb/tsdb.h | 12 ++--- include/dnode/vnode/vnode.h | 58 ++++++++++------------- source/dnode/vnode/impl/src/vnodeMain.c | 4 +- source/dnode/vnode/tq/src/tq.c | 2 +- source/dnode/vnode/tsdb/inc/tsdbDef.h | 2 +- source/dnode/vnode/tsdb/inc/tsdbOptions.h | 6 +-- source/dnode/vnode/tsdb/src/tsdbMain.c | 6 +-- source/dnode/vnode/tsdb/src/tsdbOptions.c | 10 ++-- 9 files changed, 50 insertions(+), 58 deletions(-) diff --git a/include/dnode/vnode/tq/tq.h b/include/dnode/vnode/tq/tq.h index 2785b6de96..85533f65bc 100644 --- a/include/dnode/vnode/tq/tq.h +++ b/include/dnode/vnode/tq/tq.h @@ -161,9 +161,9 @@ typedef struct TqLogReader { int64_t (*logGetLastVer)(void* logHandle); } TqLogReader; -typedef struct TqConfig { +typedef struct STqCfg { // TODO -} TqConfig; +} STqCfg; typedef struct TqMemRef { SMemAllocatorFactory *pAlloctorFactory; @@ -256,14 +256,14 @@ typedef struct STQ { // the collection of group handle // the handle of kvstore char* path; - TqConfig* tqConfig; + STqCfg* tqConfig; TqLogReader* tqLogReader; TqMemRef tqMemRef; TqMetaStore* tqMeta; } STQ; // open in each vnode -STQ* tqOpen(const char* path, TqConfig* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac); +STQ* tqOpen(const char* path, STqCfg* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac); void tqDestroy(STQ*); // void* will be replace by a msg type diff --git a/include/dnode/vnode/tsdb/tsdb.h b/include/dnode/vnode/tsdb/tsdb.h index e486da5419..d74a828538 100644 --- a/include/dnode/vnode/tsdb/tsdb.h +++ b/include/dnode/vnode/tsdb/tsdb.h @@ -22,21 +22,21 @@ extern "C" { // TYPES EXPOSED typedef struct STsdb STsdb; -typedef struct STsdbOptions STsdbOptions; +typedef struct STsdbCfg STsdbCfg; typedef struct STsdbMemAllocator STsdbMemAllocator; // STsdb -STsdb *tsdbOpen(const char *path, const STsdbOptions *); +STsdb *tsdbOpen(const char *path, const STsdbCfg *); void tsdbClose(STsdb *); void tsdbRemove(const char *path); int tsdbInsertData(STsdb *pTsdb, void *); -// STsdbOptions -int tsdbOptionsInit(STsdbOptions *); -void tsdbOptionsClear(STsdbOptions *); +// STsdbCfg +int tsdbOptionsInit(STsdbCfg *); +void tsdbOptionsClear(STsdbCfg *); /* ------------------------ STRUCT DEFINITIONS ------------------------ */ -struct STsdbOptions { +struct STsdbCfg { uint64_t lruCacheSize; /* TODO */ }; diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index febcdafacd..cc74f8e433 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -23,6 +23,7 @@ #include "tarray.h" #include "tq.h" #include "tsdb.h" +#include "wal.h" #ifdef __cplusplus extern "C" { @@ -102,43 +103,34 @@ void vnodeOptionsClear(SVnodeCfg *pOptions); /* ------------------------ STRUCT DEFINITIONS ------------------------ */ struct SVnodeCfg { - /** - * @brief write buffer size in BYTES - * - */ - uint64_t wsize; - - /** - * @brief time to live of tables in this vnode - * in SECONDS - * - */ + /** vnode buffer pool options */ + struct { + /** write buffer size */ + uint64_t wsize; + /** use heap allocator or arena allocator */ + bool isHeapAllocator; + }; + + /** time to live of tables in this vnode * uint32_t ttl; - /** - * @brief if time-series requests eventual consistency - * - */ + /** data to keep in this vnode */ + uint32_t keep; + + /** if TS data is eventually consistency */ bool isWeak; - /** - * @brief if the allocator is heap allcator or arena allocator - * - */ - bool isHeapAllocator; - - /** - * @brief TSDB options - * - */ - STsdbOptions tsdbOptions; - - /** - * @brief META options - * - */ - SMetaCfg metaOptions; - // STqOptions tqOptions; // TODO + /** TSDB config */ + STsdbCfg tsdbCfg; + + /** META config */ + SMetaCfg metaCfg; + + /** TQ config */ + STqCfg tqCfg; + + /** WAL config */ + SWalCfg walCfg; }; /* ------------------------ FOR COMPILE ------------------------ */ diff --git a/source/dnode/vnode/impl/src/vnodeMain.c b/source/dnode/vnode/impl/src/vnodeMain.c index 9ced3b9304..74a7ea61b0 100644 --- a/source/dnode/vnode/impl/src/vnodeMain.c +++ b/source/dnode/vnode/impl/src/vnodeMain.c @@ -94,7 +94,7 @@ static int vnodeOpenImpl(SVnode *pVnode) { // Open meta sprintf(dir, "%s/meta", pVnode->path); - pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaOptions)); + pVnode->pMeta = metaOpen(dir, &(pVnode->config.metaCfg)); if (pVnode->pMeta == NULL) { // TODO: handle error return -1; @@ -102,7 +102,7 @@ static int vnodeOpenImpl(SVnode *pVnode) { // Open tsdb sprintf(dir, "%s/tsdb", pVnode->path); - pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbOptions)); + pVnode->pTsdb = tsdbOpen(dir, &(pVnode->config.tsdbCfg)); if (pVnode->pTsdb == NULL) { // TODO: handle error return -1; diff --git a/source/dnode/vnode/tq/src/tq.c b/source/dnode/vnode/tq/src/tq.c index 099d540c20..c5f2252c72 100644 --- a/source/dnode/vnode/tq/src/tq.c +++ b/source/dnode/vnode/tq/src/tq.c @@ -40,7 +40,7 @@ void* tqSerializeBufItem(TqBufferItem* bufItem, void* ptr); const void* tqDeserializeBufHandle(const void* pBytes, TqBufferHandle* bufHandle); const void* tqDeserializeBufItem(const void* pBytes, TqBufferItem* bufItem); -STQ* tqOpen(const char* path, TqConfig* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac) { +STQ* tqOpen(const char* path, STqCfg* tqConfig, TqLogReader* tqLogReader, SMemAllocatorFactory *allocFac) { STQ* pTq = malloc(sizeof(STQ)); if(pTq == NULL) { //TODO: memory error diff --git a/source/dnode/vnode/tsdb/inc/tsdbDef.h b/source/dnode/vnode/tsdb/inc/tsdbDef.h index ca3d0319c1..0a57f5f670 100644 --- a/source/dnode/vnode/tsdb/inc/tsdbDef.h +++ b/source/dnode/vnode/tsdb/inc/tsdbDef.h @@ -28,7 +28,7 @@ extern "C" { struct STsdb { char * path; - STsdbOptions options; + STsdbCfg options; SMemAllocatorFactory *pmaf; }; diff --git a/source/dnode/vnode/tsdb/inc/tsdbOptions.h b/source/dnode/vnode/tsdb/inc/tsdbOptions.h index ffd409099a..46607ea2fe 100644 --- a/source/dnode/vnode/tsdb/inc/tsdbOptions.h +++ b/source/dnode/vnode/tsdb/inc/tsdbOptions.h @@ -20,10 +20,10 @@ extern "C" { #endif -extern const STsdbOptions defautlTsdbOptions; +extern const STsdbCfg defautlTsdbOptions; -int tsdbValidateOptions(const STsdbOptions *); -void tsdbOptionsCopy(STsdbOptions *pDest, const STsdbOptions *pSrc); +int tsdbValidateOptions(const STsdbCfg *); +void tsdbOptionsCopy(STsdbCfg *pDest, const STsdbCfg *pSrc); #ifdef __cplusplus } diff --git a/source/dnode/vnode/tsdb/src/tsdbMain.c b/source/dnode/vnode/tsdb/src/tsdbMain.c index 10b6c2aa65..2fe7a61930 100644 --- a/source/dnode/vnode/tsdb/src/tsdbMain.c +++ b/source/dnode/vnode/tsdb/src/tsdbMain.c @@ -15,12 +15,12 @@ #include "tsdbDef.h" -static STsdb *tsdbNew(const char *path, const STsdbOptions *pTsdbOptions); +static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions); static void tsdbFree(STsdb *pTsdb); static int tsdbOpenImpl(STsdb *pTsdb); static void tsdbCloseImpl(STsdb *pTsdb); -STsdb *tsdbOpen(const char *path, const STsdbOptions *pTsdbOptions) { +STsdb *tsdbOpen(const char *path, const STsdbCfg *pTsdbOptions) { STsdb *pTsdb = NULL; // Set default TSDB Options @@ -62,7 +62,7 @@ void tsdbClose(STsdb *pTsdb) { void tsdbRemove(const char *path) { taosRemoveDir(path); } /* ------------------------ STATIC METHODS ------------------------ */ -static STsdb *tsdbNew(const char *path, const STsdbOptions *pTsdbOptions) { +static STsdb *tsdbNew(const char *path, const STsdbCfg *pTsdbOptions) { STsdb *pTsdb = NULL; pTsdb = (STsdb *)calloc(1, sizeof(STsdb)); diff --git a/source/dnode/vnode/tsdb/src/tsdbOptions.c b/source/dnode/vnode/tsdb/src/tsdbOptions.c index 3a1102f048..1c2b3c640a 100644 --- a/source/dnode/vnode/tsdb/src/tsdbOptions.c +++ b/source/dnode/vnode/tsdb/src/tsdbOptions.c @@ -15,20 +15,20 @@ #include "tsdbDef.h" -const STsdbOptions defautlTsdbOptions = {.lruCacheSize = 0}; +const STsdbCfg defautlTsdbOptions = {.lruCacheSize = 0}; -int tsdbOptionsInit(STsdbOptions *pTsdbOptions) { +int tsdbOptionsInit(STsdbCfg *pTsdbOptions) { // TODO return 0; } -void tsdbOptionsClear(STsdbOptions *pTsdbOptions) { +void tsdbOptionsClear(STsdbCfg *pTsdbOptions) { // TODO } -int tsdbValidateOptions(const STsdbOptions *pTsdbOptions) { +int tsdbValidateOptions(const STsdbCfg *pTsdbOptions) { // TODO return 0; } -void tsdbOptionsCopy(STsdbOptions *pDest, const STsdbOptions *pSrc) { memcpy(pDest, pSrc, sizeof(STsdbOptions)); } \ No newline at end of file +void tsdbOptionsCopy(STsdbCfg *pDest, const STsdbCfg *pSrc) { memcpy(pDest, pSrc, sizeof(STsdbCfg)); } \ No newline at end of file -- GitLab