diff --git a/include/dnode/vnode/vnode.h b/include/dnode/vnode/vnode.h index 007ce838128d6894aa89e8a07b783459806221ff..8458ad9da38d009524f8eee25d902ca305c0cdb2 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 a60e8feac21fcc6361405fb67247e77d8739d7dd..8f0af27513e46f75f3fbe53f81ecb78e4fa6a12a 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 cac7999f59c8fcb70308c64a79f0edcc5fa7a9ac..944fe80b3121bca4a8f7dcac4c6a04df5e0146e9 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 9b94b4a361c8274563554c36ae52b6fc36d258f6..63fc0d52f016d437749b4af46be260027b2b7bb3 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 ac2ccbc13290c092b7fb54ebf16984a47d88837b..a25b04e16108c71a5d017f3b25fac8730cbd88fe 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);