diff --git a/CMakeLists.txt b/CMakeLists.txt index abb39c310ad0e2a8d464153e4542f6bd9514206e..ce3a4014edc94c84d3bee45798c8a083c51af71c 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 c1964762c7e386b7408b52e9adac9017c3e50e4f..1d789dd75e6bec5fc972c2ef7cf660a5bc3ff606 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 0000000000000000000000000000000000000000..ba31480850763f484cbd94a630999578b71f6a9a --- /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 e35417b4c5c5f3dc42676648a3801804c9ea15f4..0dcb7a240c431c4a8b238a408c8624ebf3864e69 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 227bfe659495cd9cd1a7df0557f09c09d0366e36..2b678751f6c620bad7d95e3a4a14b71e68d13009 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 179ff42cd966b1fca7cafccbf1d8a59f1f903db9..486ff9c634c3e995eaf06bf652d4b9dacec96299 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