From e26fbd80fda7b069d0338de4976d556242e071ff Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 8 Nov 2021 11:43:39 +0800 Subject: [PATCH] integrate nuraft --- CMakeLists.txt | 5 +++++ cmake/cmake.options | 6 +++++ cmake/nuraft_CMakeLists.txt.in | 12 ++++++++++ deps/CMakeLists.txt | 6 +++++ include/server/vnode/vnode.h | 2 +- source/dnode/vnode/impl/src/vnodeWrite.c | 28 +++--------------------- 6 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 cmake/nuraft_CMakeLists.txt.in diff --git a/CMakeLists.txt b/CMakeLists.txt index abb39c310a..ce3a4014ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ if(${BUILD_WITH_LUCENE}) cat("${CMAKE_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${DEPS_TMP_FILE}) endif(${BUILD_WITH_LUCENE}) +## NuRaft +if(${BUILD_WITH_NURAFT}) + cat("${CMAKE_SUPPORT_DIR}/nuraft_CMakeLists.txt.in" ${DEPS_TMP_FILE}) +endif(${BUILD_WITH_NURAFT}) + ## download dependencies configure_file(${DEPS_TMP_FILE} "${CMAKE_SOURCE_DIR}/deps/deps-download/CMakeLists.txt") execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . diff --git a/cmake/cmake.options b/cmake/cmake.options index c1964762c7..1d789dd75e 100644 --- a/cmake/cmake.options +++ b/cmake/cmake.options @@ -25,6 +25,12 @@ option( OFF ) +option( + BUILD_WITH_NURAFT + "If build with NuRaft" + OFF +) + option( BUILD_DEPENDENCY_TESTS "If build dependency tests" diff --git a/cmake/nuraft_CMakeLists.txt.in b/cmake/nuraft_CMakeLists.txt.in new file mode 100644 index 0000000000..ba31480850 --- /dev/null +++ b/cmake/nuraft_CMakeLists.txt.in @@ -0,0 +1,12 @@ + +# NuRaft +ExternalProject_Add(NuRaft + GIT_REPOSITORY https://github.com/eBay/NuRaft.git + GIT_TAG v1.3.0 + SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/nuraft" + BINARY_DIR "${CMAKE_SOURCE_DIR}/deps/nuraft" + CONFIGURE_COMMAND "./prepare.sh" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) \ No newline at end of file diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index e35417b4c5..0dcb7a240c 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -67,6 +67,12 @@ if(${BUILD_WITH_LUCENE}) add_subdirectory(lucene) endif(${BUILD_WITH_LUCENE}) +# NuRaft +if(${BUILD_WITH_NURAFT}) + add_subdirectory(nuraft) +endif(${BUILD_WITH_NURAFT}) + + # ================================================================================================ # DEPENDENCY TEST # ================================================================================================ diff --git a/include/server/vnode/vnode.h b/include/server/vnode/vnode.h index 227bfe6594..2b678751f6 100644 --- a/include/server/vnode/vnode.h +++ b/include/server/vnode/vnode.h @@ -31,7 +31,7 @@ SVnode *vnodeOpen(const char *path, const SVnodeOptions *pVnodeOptions); void vnodeClose(SVnode *pVnode); void vnodeDestroy(const char *path); int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch); -int vnodeApplyWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch); +int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest); int vnodeProcessReadReq(SVnode *pVnode, SRequest *pReq); int vnodeProcessSyncReq(SVnode *pVnode, SRequest *pReq); diff --git a/source/dnode/vnode/impl/src/vnodeWrite.c b/source/dnode/vnode/impl/src/vnodeWrite.c index 179ff42cd9..486ff9c634 100644 --- a/source/dnode/vnode/impl/src/vnodeWrite.c +++ b/source/dnode/vnode/impl/src/vnodeWrite.c @@ -15,36 +15,14 @@ #include "vnodeDef.h" -static int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest); - int vnodeProcessWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { /* TODO */ return 0; } -int vnodeApplyWriteReqs(SVnode *pVnode, SReqBatch *pReqBatch) { - SReqBatchIter rbIter; - - tdInitRBIter(&rbIter, pReqBatch); - - for (;;) { - const SRequest *pReq = tdRBIterNext(&rbIter); - if (pReq == NULL) { - break; - } - - if (vnodeApplyWriteRequest(pVnode, pReq) < 0) { - // TODO - } - } - - tdClearRBIter(&rbIter); - +int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { + /* TODO */ return 0; } -/* ------------------------ STATIC METHODS ------------------------ */ -static int vnodeApplyWriteRequest(SVnode *pVnode, const SRequest *pRequest) { - /* TODO */ - return 0; -} \ No newline at end of file +/* ------------------------ STATIC METHODS ------------------------ */ \ No newline at end of file -- GitLab