From 79006358d7e2860b084134f9a313d8ba6c47e8f5 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 14 Dec 2021 09:56:24 +0800 Subject: [PATCH] more --- include/dnode/vnode/vnode.h | 4 +++- source/dnode/vnode/impl/inc/vnodeCommit.h | 3 +++ source/dnode/vnode/impl/src/vnodeCommit.c | 9 +++++++++ source/dnode/vnode/impl/src/vnodeMain.c | 8 +++++++- source/dnode/vnode/impl/test/vnodeApiTests.cpp | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 007ce83812..8458ad9da3 100644 --- a/include/dnode/vnode/vnode.h +++ b/include/dnode/vnode/vnode.h @@ -68,9 +68,11 @@ typedef struct SVnodeCfg { /** * @brief Initialize the vnode module * + * @param nthreads number of commit threads. 0 for no threads and + * a schedule queue should be given (TODO) * @return int 0 for success and -1 for failure */ -int vnodeInit(); +int vnodeInit(uint16_t nthreads); /** * @brief clear a vnode diff --git a/source/dnode/vnode/impl/inc/vnodeCommit.h b/source/dnode/vnode/impl/inc/vnodeCommit.h index a60e8feac2..8f0af27513 100644 --- a/source/dnode/vnode/impl/inc/vnodeCommit.h +++ b/source/dnode/vnode/impl/inc/vnodeCommit.h @@ -22,6 +22,9 @@ extern "C" { #endif +int vnodeInitCommit(uint16_t nthreads); +void vnodeClearCommit(); + #define vnodeShouldCommit vnodeBufPoolIsFull int vnodeAsyncCommit(SVnode *pVnode); diff --git a/source/dnode/vnode/impl/src/vnodeCommit.c b/source/dnode/vnode/impl/src/vnodeCommit.c index cac7999f59..944fe80b31 100644 --- a/source/dnode/vnode/impl/src/vnodeCommit.c +++ b/source/dnode/vnode/impl/src/vnodeCommit.c @@ -18,6 +18,15 @@ static int vnodeStartCommit(SVnode *pVnode); static int vnodeEndCommit(SVnode *pVnode); +int vnodeInitCommit(uint16_t nthreads) { + // TODO + return 0; +} + +void vnodeClearCommit() { + // TODO +} + int vnodeAsyncCommit(SVnode *pVnode) { #if 0 if (vnodeStartCommit(pVnode) < 0) { diff --git a/source/dnode/vnode/impl/src/vnodeMain.c b/source/dnode/vnode/impl/src/vnodeMain.c index 9b94b4a361..63fc0d52f0 100644 --- a/source/dnode/vnode/impl/src/vnodeMain.c +++ b/source/dnode/vnode/impl/src/vnodeMain.c @@ -24,7 +24,7 @@ static void vnodeCloseImpl(SVnode *pVnode); TD_DEF_MOD_INIT_FLAG(vnode); TD_DEF_MOD_CLEAR_FLAG(vnode); -int vnodeInit() { +int vnodeInit(uint16_t nthreads) { if (TD_CHECK_AND_SET_MODE_INIT(vnode) == TD_MOD_INITIALIZED) { return 0; } @@ -33,6 +33,10 @@ int vnodeInit() { return -1; } + if (vnodeInitCommit(nthreads) < 0) { + return -1; + } + return 0; } @@ -42,6 +46,8 @@ void vnodeClear() { } walCleanUp(); + + vnodeClearCommit(); } SVnode *vnodeOpen(const char *path, const SVnodeCfg *pVnodeCfg) { diff --git a/source/dnode/vnode/impl/test/vnodeApiTests.cpp b/source/dnode/vnode/impl/test/vnodeApiTests.cpp index ac2ccbc132..a25b04e161 100644 --- a/source/dnode/vnode/impl/test/vnodeApiTests.cpp +++ b/source/dnode/vnode/impl/test/vnodeApiTests.cpp @@ -92,7 +92,7 @@ TEST(vnodeApiTest, test_create_table_encode_and_decode_function) { #endif TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) { - GTEST_ASSERT_GE(vnodeInit(), 0); + GTEST_ASSERT_GE(vnodeInit(2), 0); // Create and open a vnode SVnode *pVnode = vnodeOpen("vnode1", NULL); -- GitLab