diff --git a/CMakeLists.txt b/CMakeLists.txt index df07059..179461c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,10 +56,12 @@ endif() ## include the Protobuf generation code include(ProtobufGen) include(DownloadBoost) +include(DownloadFizz) include(DownloadFolly) include(DownloadWangle) include(DownloadZookeeper) - +include(DownloadCyrusSasl) +include(DownloadDoubleConversion) set(PROJECT_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/dependencies") set(BOOST_MIN_VERSION "1.6.1") @@ -82,16 +84,22 @@ if (DOWNLOAD_DEPENDENCIES) set(PROTOBUF_PROTOC_EXECUTABLE "${Protobuf_BINARY_DIR}/bin/protoc" CACHE STRING "" FORCE) ## Add CMAKE_MODULE_PATHS - + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost/local") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/zookeeper/local") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/protobuf/local") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/folly/local") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/wangle/local") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/fizz/local") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sasl2/local") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/doubleconversion/local") else() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/zookeeper/system") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/folly/system") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/wangle/system") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/fizz/system") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sasl2/system") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/doubleconversion/system") endif(DOWNLOAD_DEPENDENCIES) ## Build Apache HBase components that are necessary for this project @@ -136,9 +144,8 @@ if(COMPILER_SUPPORTS_CXX14) elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") else() - message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no c++14 support. Please use a different C++ compiler.") + message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} does not have C++14 support. Please use a different C++ compiler.") endif() - set(HBASE_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/hbase") set(HBASE_PROTO_GEN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/hbase/if") set(HBASE_PROTO_GEN_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/hbase/if") @@ -155,12 +162,13 @@ if (OPENSSL_FOUND) else () message( FATAL_ERROR "OpenSSL was not found. Please install OpenSSL" ) endif (OPENSSL_FOUND) -## Download Facebook Folly and build locally - - +## Download dependencies and build locally if (DOWNLOAD_DEPENDENCIES) download_boost(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} "${BOOST_LIBS}") + download_doubleconversion(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + download_cyrus_sasl(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) download_folly(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + download_fizz(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) download_wangle(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) download_zookeeper(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) endif(DOWNLOAD_DEPENDENCIES) @@ -173,6 +181,7 @@ find_package(LibEvent REQUIRED) find_package(Gflags REQUIRED) if (DOWNLOAD_DEPENDENCIES) find_package(Sodium REQUIRED) + find_package(Fizz REQUIRED) endif(DOWNLOAD_DEPENDENCIES) find_package(Folly REQUIRED) find_package(Krb5 REQUIRED) @@ -206,7 +215,9 @@ include_directories(${Boost_INCLUDE_DIR}) include_directories(${KRB5_INCLUDE_DIRS}) include_directories(${JAVA_INCLUDE_DIRS}) include_directories(${FOLLY_INCLUDE_DIR}) +include_directories(${FIZZ_INCLUDE_DIR}) include_directories(${WANGLE_INCLUDE_DIR}) +include_directories(${DOUBLE_CONVERSION_INCLUDE_DIR}) ### create a directory for the hbase protobuf headers. ### this is helpful so that when we include it, later, we can generate ### the protocol buffer source/headers without polluting our tree. @@ -243,12 +254,9 @@ add_library(hbaseclient-static STATIC ${PROTO_SOURCES} ${CLIENT_SRC} ${CONNECTIO set_target_properties(hbaseclient-static PROPERTIES LINKER_LANGUAGE CXX) SET_TARGET_PROPERTIES(hbaseclient-static PROPERTIES OUTPUT_NAME hbaseclient CLEAN_DIRECT_OUTPUT 1) set_target_properties(hbaseclient-static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libs") -target_link_libraries(hbaseclient-static ${Boost_LIBRARIES}) -target_link_libraries(hbaseclient-static ${SASL_LIBS}) -target_link_libraries(hbaseclient-static ${GFLAGS_SHARED_LIB}) -target_link_libraries(hbaseclient-static ${KRB5_LIBRARIES}) target_link_libraries(hbaseclient-static ${WANGLE_LIBRARIES}) if (DOWNLOAD_DEPENDENCIES) + target_link_libraries(hbaseclient-static ${FIZZ_LIBRARIES}) target_link_libraries(hbaseclient-static ${sodium_LIBRARY_RELEASE}) endif(DOWNLOAD_DEPENDENCIES) target_link_libraries(hbaseclient-static ${FOLLY_LIBRARIES}) @@ -258,17 +266,21 @@ target_link_libraries(hbaseclient-static ${PROTOBUF_LIBRARY}) target_link_libraries(hbaseclient-static ${DOUBLE_CONVERSION_LIBRARY}) target_link_libraries(hbaseclient-static ${ZOOKEEPER_LIBRARIES}) target_link_libraries(hbaseclient-static ${OPENSSL_LIBRARIES}) +target_link_libraries(hbaseclient-static ${Boost_LIBRARIES}) +target_link_libraries(hbaseclient-static ${SASL_LIBS}) +target_link_libraries(hbaseclient-static ${GFLAGS_SHARED_LIB}) +target_link_libraries(hbaseclient-static ${KRB5_LIBRARIES}) target_link_libraries(hbaseclient-static ${CMAKE_DL_LIBS}) +target_link_libraries(hbaseclient-static ${CMAKE_THREAD_LIBS_INIT}) add_library(hbaseclient-shared SHARED ${PROTO_SOURCES} ${CLIENT_SRC} ${CONNECTION_SRC} ${EXCEPTION_SRC} ${PROTO_SRC} ${SECURITY_SRC} ${SRDE_SRC} ${UTILS_SRC}) set_target_properties(hbaseclient-shared PROPERTIES LINKER_LANGUAGE CXX) SET_TARGET_PROPERTIES(hbaseclient-shared PROPERTIES COMPILE_FLAGS " -fPIC") SET_TARGET_PROPERTIES(hbaseclient-shared PROPERTIES OUTPUT_NAME hbaseclient CLEAN_DIRECT_OUTPUT 1) set_target_properties(hbaseclient-shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libs") -target_link_libraries(hbaseclient-shared ${PROTOBUF_LIBRARY}) -target_link_libraries(hbaseclient-shared ${Boost_LIBRARIES}) target_link_libraries(hbaseclient-shared ${WANGLE_LIBRARIES}) if (DOWNLOAD_DEPENDENCIES) + target_link_libraries(hbaseclient-shared ${FIZZ_LIBRARIES}) target_link_libraries(hbaseclient-shared ${sodium_LIBRARY_RELEASE}) endif(DOWNLOAD_DEPENDENCIES) target_link_libraries(hbaseclient-shared ${FOLLY_LIBRARIES}) @@ -280,27 +292,19 @@ target_link_libraries(hbaseclient-shared ${OPENSSL_LIBRARIES}) target_link_libraries(hbaseclient-shared ${LIB_EVENT_LIBRARY}) target_link_libraries(hbaseclient-shared ${ZOOKEEPER_LIBRARIES}) target_link_libraries(hbaseclient-shared ${DOUBLE_CONVERSION_LIBRARY}) +target_link_libraries(hbaseclient-shared ${PROTOBUF_LIBRARY}) +target_link_libraries(hbaseclient-shared ${Boost_LIBRARIES}) target_link_libraries(hbaseclient-shared ${CMAKE_DL_LIBS}) +target_link_libraries(hbaseclient-static ${CMAKE_THREAD_LIBS_INIT}) + add_executable(simple-client "${HBASE_SRC_DIR}/examples/simple-client.cc") set_target_properties(simple-client PROPERTIES COMPILE_FLAGS " ") set_target_properties(simple-client PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin/examples") -target_link_libraries(simple-client ${PROTOBUF_LIBRARY}) -target_link_libraries(simple-client ${Boost_LIBRARIES}) -target_link_libraries(simple-client ${SASL_LIBS}) -target_link_libraries(simple-client ${GFLAGS_SHARED_LIB}) -target_link_libraries(simple-client ${KRB5_LIBRARIES}) -target_link_libraries(simple-client ${ZOOKEEPER_LIBRARIES}) -target_link_libraries(simple-client hbaseclient-static ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(simple-client hbaseclient-static) add_executable(load-client "${HBASE_SRC_DIR}/examples/load-client.cc") set_target_properties(load-client PROPERTIES COMPILE_FLAGS " ") set_target_properties(load-client PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin/examples") -target_link_libraries(load-client ${PROTOBUF_LIBRARY}) -target_link_libraries(load-client ${Boost_LIBRARIES}) -target_link_libraries(load-client ${SASL_LIBS}) -target_link_libraries(load-client ${GFLAGS_SHARED_LIB}) -target_link_libraries(load-client ${KRB5_LIBRARIES}) -target_link_libraries(load-client ${ZOOKEEPER_LIBRARIES}) -target_link_libraries(load-client hbaseclient-static ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(load-client hbaseclient-static) if (JNI_FOUND) message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}") message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}") @@ -314,12 +318,21 @@ add_custom_target( COMMAND ${CMAKE_SOURCE_DIR}/bin/cpplint.sh) if (DOWNLOAD_DEPENDENCIES) + add_dependencies(hbaseclient-static Protobuf) + add_dependencies(hbaseclient-shared Protobuf) + ## everything relies on folly. fizz relies on folly. wangle + ## relies on folly and fizz add_dependencies(facebook-folly-proj boost) add_dependencies(hbaseclient-static boost) add_dependencies(hbaseclient-shared boost) - add_dependencies(hbaseclient-static Protobuf) - add_dependencies(hbaseclient-shared Protobuf) + add_dependencies(hbaseclient-static cyrussasl) + add_dependencies(hbaseclient-shared cyrussasl) + add_dependencies(facebook-folly-proj boost) + add_dependencies(facebook-folly-proj doubleconversion-proj) add_dependencies(facebook-wangle-proj facebook-folly-proj) + add_dependencies(facebook-fizz-proj facebook-folly-proj) + add_dependencies(facebook-wangle-proj facebook-folly-proj) + add_dependencies(facebook-wangle-proj facebook-fizz-proj) add_dependencies(hbaseclient-static facebook-wangle-proj) add_dependencies(hbaseclient-shared facebook-wangle-proj) add_dependencies(hbaseclient-static zookeeper) diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake index 4808fc3..7af57b2 100644 --- a/cmake/BuildTests.cmake +++ b/cmake/BuildTests.cmake @@ -39,32 +39,16 @@ target_include_directories(testutil PRIVATE BEFORE${Zookeeper_INCLUDE_DIRS}) target_include_directories(testutil PRIVATE BEFORE${KRB5_INCLUDE_DIRS}) target_include_directories(testutil PRIVATE BEFORE${Java_INCLUDE_DIRS}) target_include_directories(testutil PRIVATE BEFORE${FOLLY_INCLUDE_DIRS}) -target_link_libraries(testutil hbaseclient-static ${CMAKE_THREAD_LIBS_INIT} ${Java_LIBRARIES} ${JNI_LIBRARIES} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${GFLAGS_SHARED_LIB} ${GMOCK_SHARED_LIB} ${GTEST_BOTH_LIBRARIES} ${SASL_LIBS} ${GFLAGS_SHARED_LIB} ${KRB5_LIBRARIES} ${OPENSSL_LIBRARIES} ${Zookeeper_LIBRARIES}) +target_link_libraries(testutil hbaseclient-static ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} ${Java_LIBRARIES} ${JNI_LIBRARIES} ${PROTOBUF_LIBRARY} ${Boost_LIBRARIES} ${GFLAGS_SHARED_LIB} ${GMOCK_SHARED_LIB} ${GTEST_BOTH_LIBRARIES} ${KRB5_LIBRARIES} ${SASL_LIBS} ${GFLAGS_SHARED_LIB} ${OPENSSL_LIBRARIES} ${Zookeeper_LIBRARIES}) function(createTests testName) - message ("-- Including Test: ${testName}") + message (STATUS "Including Test: ${testName}") target_include_directories(${testName} PRIVATE BEFORE "include") target_include_directories(${testName} PRIVATE BEFORE "${Java_INCLUDE_DIRS}") target_include_directories(${testName} PRIVATE BEFORE "${JNI_INCLUDE_DIRS}") target_include_directories(${testName} PRIVATE BEFORE "${Boost_INCLUDE_DIR}") target_include_directories(${testName} PRIVATE BEFORE "${GTEST_INCLUDE_DIRS}") target_include_directories(${testName} PRIVATE BEFORE "${OPENSSL_INCLUDE_DIR}") - - - #target_link_libraries(${testName} ${PROTOBUF_LIBRARY}) - #${PROTOBUF_LIBRARY} - - target_link_libraries(${testName} hbaseclient-static testutil ${CMAKE_DL_LIBS} - ${Java_LIBRARIES} - ${JNI_LIBRARIES} - ${Boost_LIBRARIES} - ${GFLAGS_SHARED_LIB} - ${GTEST_BOTH_LIBRARIES} - ${SASL_LIBS} - ${GFLAGS_SHARED_LIB} - ${KRB5_LIBRARIES} - ${ZOOKEEPER_LIBRARIES} ${OPENSSL_LIBRARIES} - ${GLOG_SHARED_LIB} - ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(${testName} testutil) endfunction() enable_testing(test) SET(TEST_DIR ${CMAKE_SOURCE_DIR}/src/test) diff --git a/cmake/DownloadBoost.cmake b/cmake/DownloadBoost.cmake index 388a511..92da50f 100644 --- a/cmake/DownloadBoost.cmake +++ b/cmake/DownloadBoost.cmake @@ -49,4 +49,7 @@ function(download_boost SOURCE_DIR BUILD_DIR BOOST_LIBS) INSTALL_COMMAND "" ) set(BOOST_ROOT ${BOOST_INSTALL_DIR} PARENT_SCOPE) + set(BOOST_INCLUDEDIR ${BOOST_ROOT}/include PARENT_SCOPE) + set(BOOST_LIBRARYDIR ${BOOST_ROOT}/lib PARENT_SCOPE) + set(Boost_FIND_COMPONENTS ${BOOST_LIBS} PARENT_SCOPE) endfunction(download_boost) diff --git a/cmake/DownloadCyrusSasl.cmake b/cmake/DownloadCyrusSasl.cmake new file mode 100644 index 0000000..c67fae7 --- /dev/null +++ b/cmake/DownloadCyrusSasl.cmake @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +## Download Cyrus SASL +## SOURCE_DIR is typically the cmake source directory +## BINARY_DIR is the build directory, typically 'build' + +function(download_cyrus_sasl SOURCE_DIR BUILD_DIR) + ExternalProject_Add( + cyrussasl + URL "https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.27/cyrus-sasl-2.1.27.tar.gz" + PREFIX "${BUILD_DIR}/dependencies" + SOURCE_DIR "${BUILD_DIR}/dependencies/cyrussasl-src" + BINARY_DIR ${BUILD_DIR}/dependencies/cyrussasl-src/ + CONFIGURE_COMMAND ./configure --enable-static --with-pic --prefix=${BUILD_DIR}/dependencies/cyrussasl-install + "CFLAGS=-fPIC" + "CXXFLAGS=${CMAKE_CXX_FLAGS} -fPIC" + ) + set(SASL2_DIR "${BUILD_DIR}/dependencies/cyrussasl-install/" CACHE STRING "" FORCE) +endfunction(download_cyrus_sasl) diff --git a/cmake/DownloadDoubleConversion.cmake b/cmake/DownloadDoubleConversion.cmake new file mode 100644 index 0000000..db99893 --- /dev/null +++ b/cmake/DownloadDoubleConversion.cmake @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +## Download Double Conversion library. +## SOURCE_DIR is typically the cmake source directory +function(download_doubleconversion SOURCE_DIR BUILD_DIR) + + ExternalProject_Add( + doubleconversion-proj + PREFIX "${BUILD_DIR}/dependencies" + GIT_REPOSITORY "https://github.com/google/double-conversion.git" + GIT_TAG "b1d531bfb130e7149ffe24bb0f1c5c01f20c3a5f" ## Commit hash from master + SOURCE_DIR "${BUILD_DIR}/dependencies/doubleconversion-proj-src" + CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/dependencies/doubleconversion-proj-install" -DCMAKE_POSITION_INDEPENDENT_CODE=ON "${BUILD_ARGS}") + + set(DOUBLE_CONVERSION_ROOT_DIR "${BUILD_DIR}/dependencies/doubleconversion-proj-install" CACHE STRING "" FORCE) +endfunction(download_doubleconversion) diff --git a/cmake/DownloadFizz.cmake b/cmake/DownloadFizz.cmake new file mode 100644 index 0000000..7bf6fc9 --- /dev/null +++ b/cmake/DownloadFizz.cmake @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +## Download facebook's fizz library. +## SOURCE_DIR is typically the cmake source directory +## BINARY_DIR is the build directory, typically 'build' + +function(download_fizz SOURCE_DIR BUILD_DIR) + ExternalProject_Add( + facebook-fizz-proj + GIT_REPOSITORY "https://github.com/facebookincubator/fizz.git" + PREFIX "${BUILD_DIR}/dependencies" + GIT_TAG "v2020.05.18.00" + SOURCE_DIR "${BUILD_DIR}/dependencies/facebook-fizz-proj-src" + PATCH_COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/folly/local/FindFolly.cmake" ${BUILD_DIR}/dependencies/facebook-fizz-proj-src/fizz/cmake/ + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/doubleconversion/local/FindDoubleConversion.cmake" ${BUILD_DIR}/dependencies/facebook-fizz-proj-src/fizz/cmake + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost/local/FindBoost.cmake" ${BUILD_DIR}/dependencies/facebook-fizz-proj-src/fizz/cmake + COMMAND patch ${BUILD_DIR}/dependencies/facebook-fizz-proj-src/fizz/CMakeLists.txt "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/fizz.v2020.05.18.00.cmake" + INSTALL_DIR "${BUILD_DIR}/dependencies/facebook-fizz-proj-install" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -DBUILD_EXAMPLES=OFF -DCMAKE_CROSSCOMPILING=ON -DBUILD_TESTS=OFF -DBOOST_ROOT=${BOOST_ROOT} -DFOLLY_ROOT_DIR=${FOLLY_ROOT_DIR} -DDOUBLE_CONVERSION_ROOT_DIR=${DOUBLE_CONVERSION_ROOT_DIR} -DBYPRODUCT_PREFIX=${BYPRODUCT_PREFIX} -DBYPRODUCT_SUFFIX=${BYPRODUCT_SUFFIX} -DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR}/dependencies/facebook-fizz-proj-install ${BUILD_DIR}/dependencies/facebook-fizz-proj-src/fizz # Tell CMake to use subdirectory as source. + ) + set(FIZZ_ROOT_DIR "${BUILD_DIR}/dependencies/facebook-fizz-proj-install" CACHE STRING "" FORCE) +endfunction(download_fizz) diff --git a/cmake/DownloadFolly.cmake b/cmake/DownloadFolly.cmake index 1ff5556..76d4b63 100644 --- a/cmake/DownloadFolly.cmake +++ b/cmake/DownloadFolly.cmake @@ -17,32 +17,27 @@ ## Download facebook's folly library. ## SOURCE_DIR is typically the cmake source directory -## BUILD_DIR is the build directory, typically 'build' - function(download_folly SOURCE_DIR BUILD_DIR) - - if (DOWNLOAD_DEPENDENCIES) - # Add custom boost include and lib paths. - set(CFLAGS "-fPIC -I${BOOST_ROOT}/include -lboost_context -lboost_coroutine -l${CMAKE_DL_LIBS}") - set(CXXFLAGS "${CMAKE_CXX_FLAGS} -fPIC -I${BOOST_ROOT}/include -lboost_context -lboost_coroutine -l${CMAKE_DL_LIBS}") - set(LDFLAGS "-L${BOOST_ROOT}/lib") - set(CONFIGURE_CMD ./configure --prefix=${BUILD_DIR}/dependencies/facebook-folly-proj-install - --with-boost-libdir=${BOOST_ROOT}/lib CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS} LDFLAGS=${LDFLAGS}) - else() - set(CFLAGS "-fPIC -lboost_context -lboost_coroutine -l${CMAKE_DL_LIBS}") - set(CXXFLAGS "${CMAKE_CXX_FLAGS} -fPIC -lboost_context -lboost_coroutine -l${CMAKE_DL_LIBS}") - set(CONFIGURE_CMD ./configure --prefix=${BUILD_DIR}/dependencies/facebook-folly-proj-install CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}) - endif() ExternalProject_Add( - facebook-folly-proj - # TODO: Source version information from cmake file. - URL "https://github.com/facebook/folly/archive/v2017.09.04.00.tar.gz" - PREFIX "${BUILD_DIR}/dependencies" - SOURCE_DIR "${BUILD_DIR}/dependencies/facebook-folly-proj-src" - BINARY_DIR ${BUILD_DIR}/dependencies/facebook-folly-proj-src/folly - CONFIGURE_COMMAND autoreconf -ivf COMMAND ${CONFIGURE_CMD} - UPDATE_COMMAND "" + facebook-folly-proj + PREFIX "${BUILD_DIR}/dependencies" + GIT_REPOSITORY "https://github.com/facebook/folly.git" + GIT_TAG "v2020.05.18.00" + SOURCE_DIR "${BUILD_DIR}/dependencies/facebook-folly-proj-src" + PATCH_COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/doubleconversion/local/FindDoubleConversion.cmake" ${BUILD_DIR}/dependencies/facebook-folly-proj-src/CMake + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost/local/FindBoost.cmake" ${BUILD_DIR}/dependencies/facebook-folly-proj-src/CMake + CMAKE_ARGS ${PASSTHROUGH_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX=${BUILD_DIR}/dependencies/facebook-folly-proj-install + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DDOUBLE_CONVERSION_ROOT_DIR=${DOUBLE_CONVERSION_ROOT_DIR} + -DBYPRODUCT_PREFIX=${BYPRODUCT_PREFIX} + -DBYPRODUCT_SUFFIX=${BYPRODUCT_SUFFIX} + -DBOOST_ROOT=${BOOST_ROOT} + -DBOOST_INCLUDEDIR=${BOOST_ROOT}/include + -DBOOST_LIBRARYDIR=${BOOST_ROOT}/lib + -DBOOST_LIBRARIES=${BOOST_LIBRARIES} + "${BUILD_ARGS}" ) set(FOLLY_ROOT_DIR "${BUILD_DIR}/dependencies/facebook-folly-proj-install" CACHE STRING "" FORCE) endfunction(download_folly) diff --git a/cmake/DownloadProject.cmake b/cmake/DownloadProject.cmake index fc98afe..2e18284 100644 --- a/cmake/DownloadProject.cmake +++ b/cmake/DownloadProject.cmake @@ -110,7 +110,6 @@ set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}") include(CMakeParseArguments) function(download_project) - set(options QUIET IS_AUTOGEN IS_MAVEN) set(oneValueArgs PROJ @@ -188,8 +187,7 @@ function(download_project) if(result) file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt") message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}") - endif() - + endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result ${OUTPUT_QUIET} diff --git a/cmake/DownloadWangle.cmake b/cmake/DownloadWangle.cmake index 74c97a6..c01bf6c 100644 --- a/cmake/DownloadWangle.cmake +++ b/cmake/DownloadWangle.cmake @@ -23,21 +23,24 @@ function(download_wangle SOURCE_DIR BUILD_DIR) set(WANGLE_DOWNLOAD_DIR "${BUILD_DIR}/dependencies/facebook-wangle-proj-download") set(WANGLE_SOURCE_DIR "${BUILD_DIR}/dependencies/facebook-wangle-proj-src") set(WANGLE_INSTALL_DIR "${BUILD_DIR}/dependencies/facebook-wangle-proj-install") - if (DOWNLOAD_DEPENDENCIES) - set(PATCH_FOLLY ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/cmake/folly/local/FindFolly.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost/local/FindBoost.cmake" "${WANGLE_SOURCE_DIR}/wangle/cmake") - else() - set(PATCH_FOLLY "") - endif() - - ExternalProject_Add( - facebook-wangle-proj - URL "https://github.com/facebook/wangle/archive/v2017.09.04.00.tar.gz" - PREFIX "${BUILD_DIR}/dependencies" - DOWNLOAD_DIR ${WANGLE_DOWNLOAD_DIR} - SOURCE_DIR ${WANGLE_SOURCE_DIR} - PATCH_COMMAND ${PATCH_FOLLY} - INSTALL_DIR ${WANGLE_INSTALL_DIR} - CONFIGURE_COMMAND ${CMAKE_COMMAND} -DBUILD_EXAMPLES=OFF -DCMAKE_CROSSCOMPILING=ON -DBUILD_TESTS=OFF -DFOLLY_ROOT_DIR=${FOLLY_ROOT_DIR} -DBOOST_ROOT=${BOOST_ROOT} -DCMAKE_INSTALL_PREFIX:PATH=${WANGLE_INSTALL_DIR} "${WANGLE_SOURCE_DIR}/wangle" # Tell CMake to use subdirectory as source. - ) - set(WANGLE_ROOT_DIR ${WANGLE_INSTALL_DIR} CACHE STRING "" FORCE) + ExternalProject_Add( + facebook-wangle-proj + GIT_REPOSITORY "https://github.com/facebook/wangle.git" + GIT_TAG "v2020.05.18.00" + SOURCE_DIR "${BUILD_DIR}/dependencies/facebook-wangle-proj-src" + PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cmake/folly/local/FindFolly.cmake ${WANGLE_SOURCE_DIR}/wangle/cmake/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cmake/fizz/local/FindFizz.cmake ${WANGLE_SOURCE_DIR}/wangle/cmake/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cmake/boost/local/FindBoost.cmake ${WANGLE_SOURCE_DIR}/wangle/cmake/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/cmake/doubleconversion/local/FindDoubleConversion.cmake ${WANGLE_SOURCE_DIR}/wangle/cmake/ + COMMAND patch ${WANGLE_SOURCE_DIR}/wangle/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/wangle.v2020.05.18.00.cmake + INSTALL_DIR "${WANGLE_INSTALL_DIR}" + CONFIGURE_COMMAND ${CMAKE_COMMAND} -DBUILD_EXAMPLES=OFF -DCMAKE_CROSSCOMPILING=ON -DBUILD_TESTS=OFF -DFIZZ_ROOT_DIR=${FIZZ_ROOT_DIR} -DBOOST_ROOT=${BOOST_ROOT} -DFOLLY_ROOT_DIR=${FOLLY_ROOT_DIR} -DDOUBLE_CONVERSION_ROOT_DIR=${DOUBLE_CONVERSION_ROOT_DIR} -DBYPRODUCT_PREFIX=${BYPRODUCT_PREFIX} -DCMAKE_INSTALL_PREFIX:PATH=${WANGLE_INSTALL_DIR} + -DBOOST_ROOT=${BOOST_ROOT} + -DBOOST_INCLUDEDIR=${BOOST_ROOT}/include + -DBOOST_LIBRARYDIR=${BOOST_ROOT}/lib + -DBOOST_LIBRARIES=${BOOST_LIBRARIES} + ${WANGLE_SOURCE_DIR}/wangle # Tell CMake to use subdirectory as source. + ) + + set(WANGLE_ROOT_DIR "${WANGLE_INSTALL_DIR}" CACHE STRING "" FORCE) endfunction(download_wangle) diff --git a/cmake/FindKrb5.cmake b/cmake/FindKrb5.cmake index e4c6fb8..cd992cd 100644 --- a/cmake/FindKrb5.cmake +++ b/cmake/FindKrb5.cmake @@ -19,10 +19,15 @@ find_path(KRB5_ROOT_DIR NAMES include/krb5/krb5.h ) +find_library(GSSAPI_KRB5_LIBRARY gssapi_krb5) + find_library(KRB5_LIBRARIES NAMES krb5 HINTS ${KRB5_ROOT_DIR}/lib ) + +find_library(GSSAPI_KRB5_LIBRARY gssapi_krb5) + find_path(KRB5_INCLUDE_DIR NAMES krb5/krb5.h HINTS ${KRB5_ROOT_DIR}/include @@ -32,9 +37,10 @@ find_package_handle_standard_args(krb5 DEFAULT_MSG KRB5_LIBRARIES KRB5_INCLUDE_DIR ) +set(KRB5_LIBRARIES "${KRB5_LIBRARIES}" "${GSSAPI_KRB5_LIBRARY}") if (KRB5_LIBRARIES) set(KRB5_FOUND "true") - message("-- KRB5 Libs Found, ${KRB5_LIBRARIES}") + message(STATUS "KRB5 Libs Found, ${KRB5_LIBRARIES}") endif() mark_as_advanced( KRB5_ROOT_DIR diff --git a/cmake/ProtobufGen.cmake b/cmake/ProtobufGen.cmake index 07e57d0..a44e443 100644 --- a/cmake/ProtobufGen.cmake +++ b/cmake/ProtobufGen.cmake @@ -36,6 +36,7 @@ function(generate_protobuf_src SRCS HDRS HDR_DIR PROTO_PATH) set(${SRCS}) set(${HDRS}) foreach(FIL ${ARGN}) + message("Generating ${FIL} with ${PROTOBUF_PROTOC_EXECUTABLE}") get_filename_component(ABS_FIL ${FIL} ABSOLUTE) get_filename_component(FIL_WE ${FIL} NAME_WE) ## get the directory where our protobufs are stored diff --git a/cmake/boost/local/FindBoost.cmake b/cmake/boost/local/FindBoost.cmake index 60d7ee0..0d5ca19 100644 --- a/cmake/boost/local/FindBoost.cmake +++ b/cmake/boost/local/FindBoost.cmake @@ -23,8 +23,12 @@ set(Boost_INCLUDE_DIR "${BOOST_ROOT}/include" CACHE STRING "" FORCE) set(Boost_LIBRARIES "" CACHE STRING "" FORCE) foreach(COMPONENT ${Boost_FIND_COMPONENTS}) list(APPEND Boost_LIBRARIES "${BOOST_ROOT}/lib/${BYPRODUCT_PREFIX}boost_${COMPONENT}${BYPRODUCT_SUFFIX}") + set(Boost_${COMPONENT} "${BOOST_ROOT}/lib/${BYPRODUCT_PREFIX}boost_${COMPONENT}${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + message(STATUS "Found Boost_${COMPONENT} at ${BOOST_ROOT}/lib/${BYPRODUCT_PREFIX}boost_${COMPONENT}${BYPRODUCT_SUFFIX}" ) endforeach() +set(Boost_LIBRARIES "${Boost_LIBRARIES}" CACHE STRING "" FORCE) + set(Boost_FOUND "true" CACHE STRING "" FORCE) mark_as_advanced( @@ -33,4 +37,4 @@ mark_as_advanced( Boost_INCLUDE_DIRS Boost_LIBRARIES ) -message("-- Boost found, ${Boost_LIBRARIES}") +message(STATUS "Boost found, ${Boost_LIBRARIES}") diff --git a/cmake/doubleconversion/local/FindDoubleConversion.cmake b/cmake/doubleconversion/local/FindDoubleConversion.cmake new file mode 100644 index 0000000..aa98b95 --- /dev/null +++ b/cmake/doubleconversion/local/FindDoubleConversion.cmake @@ -0,0 +1,28 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(DOUBLE_CONVERSION_FOUND "true" CACHE STRING "" FORCE) +set(DOUBLE_CONVERSION_INCLUDE_DIR "${DOUBLE_CONVERSION_ROOT_DIR}/include" CACHE STRING "" FORCE) +set(DOUBLE_CONVERSION_INCLUDE_DIRS "${DOUBLE_CONVERSION_INCLUDE_DIR}" CACHE STRING "" FORCE) +set(DOUBLE_CONVERSION_LIBRARY "${DOUBLE_CONVERSION_ROOT_DIR}/lib/${BYPRODUCT_PREFIX}double-conversion${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + + +mark_as_advanced( + DOUBLE_CONVERSION_ROOT_DIR + DOUBLE_CONVERSION_FOUND + DOUBLE_CONVERSION_LIBRARY + DOUBLE_CONVERSION_INCLUDE_DIR + DOUBLE_CONVERSION_INCLUDE_DIRS +) +message(STATUS "DoubleConversion found, ${DOUBLE_CONVERSION_LIBRARY}") diff --git a/cmake/FindDoubleConversion.cmake b/cmake/doubleconversion/system/FindDoubleConversion.cmake similarity index 100% rename from cmake/FindDoubleConversion.cmake rename to cmake/doubleconversion/system/FindDoubleConversion.cmake diff --git a/cmake/fizz/local/FindFizz.cmake b/cmake/fizz/local/FindFizz.cmake new file mode 100644 index 0000000..6f29ecd --- /dev/null +++ b/cmake/fizz/local/FindFizz.cmake @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Stubs to allow us to find FIZZ libs + +set(FIZZ_FOUND "true" CACHE STRING "" FORCE) +set(FIZZ_INCLUDE_DIR "${FIZZ_ROOT_DIR}/include" CACHE STRING "" FORCE) +set(FIZZ_LIBRARIES "${FIZZ_ROOT_DIR}/lib/${BYPRODUCT_PREFIX}fizz${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) + + +mark_as_advanced( + FIZZ_ROOT_DIR + FIZZ_LIBRARIES + FIZZ_BENCHMARK_LIBRARIES + FIZZ_INCLUDE_DIR +) +message(STATUS "Fizz found, ${FIZZ_LIBRARIES}") \ No newline at end of file diff --git a/cmake/folly/local/FindFolly.cmake b/cmake/folly/local/FindFolly.cmake index 63fb190..be9fb34 100644 --- a/cmake/folly/local/FindFolly.cmake +++ b/cmake/folly/local/FindFolly.cmake @@ -18,18 +18,16 @@ # Stubs to allow us to find folly libs set(FOLLY_FOUND "true" CACHE STRING "" FORCE) -set(FOLLY_INCLUDE_DIRS "${FOLLY_ROOT_DIR}/include" CACHE STRING "" FORCE) set(FOLLY_INCLUDE_DIR "${FOLLY_ROOT_DIR}/include" CACHE STRING "" FORCE) ## Given that folly is an older dependency, and the way it is built has evolved, newer ## versions of folly won't require an SO. For now it is far easier to link against the .so (BYPRODUCT_SHARED_SUFFIX) -set(FOLLY_LIBRARIES "${FOLLY_ROOT_DIR}/lib/${BYPRODUCT_PREFIX}folly${BYPRODUCT_SHARED_SUFFIX}" CACHE STRING "" FORCE) +set(FOLLY_LIBRARIES "${FOLLY_ROOT_DIR}/lib/${BYPRODUCT_PREFIX}folly${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) mark_as_advanced( - FOLLY_INCLUDE - FOLLY_INCLUDE_DIRS + FOLLY_ROOT_DIR FOLLY_INCLUDE_DIR FOLLY_LIBRARIES ) -message("-- FOLLY found, ${FOLLY_LIBRARIES}") \ No newline at end of file +message(STATUS "FOLLY found, ${FOLLY_LIBRARIES}") \ No newline at end of file diff --git a/cmake/patches/fizz.v2020.05.18.00.cmake b/cmake/patches/fizz.v2020.05.18.00.cmake new file mode 100644 index 0000000..5601e9e --- /dev/null +++ b/cmake/patches/fizz.v2020.05.18.00.cmake @@ -0,0 +1,22 @@ +36c36,37 +< find_package(folly CONFIG REQUIRED) +--- +> find_package(Folly REQUIRED) +> find_package(Boost REQUIRED) +46a48,55 +> +> if(NOT APPLE) +> if(NOT WIN32) +> set(WHOLE_ARCHIVE "-Wl,--whole-archive") +> set(NO_WHOLE_ARCHIVE "-Wl,--no-whole-archive") +> endif() +> endif() +> +204a214 +> ${Boost_INCLUDE_DIRS} +216a227 +> ${Boost_LIBRARIES} +220a232 +> ${WHOLE_ARCHIVE} +221a234 +> ${NO_WHOLE_ARCHIVE} diff --git a/cmake/patches/wangle.v2020.05.18.00.cmake b/cmake/patches/wangle.v2020.05.18.00.cmake index c4e022c..48412d2 100644 --- a/cmake/patches/wangle.v2020.05.18.00.cmake +++ b/cmake/patches/wangle.v2020.05.18.00.cmake @@ -1,9 +1,10 @@ -49c49 +45a46 +> find_package(Boost REQUIRED) +49c50 < find_package(folly CONFIG REQUIRED) --- > find_package(Folly REQUIRED) -51c51 +51c52 < find_package(fizz CONFIG REQUIRED) --- > find_package(Fizz REQUIRED) - diff --git a/cmake/sasl2/local/FindSasl2.cmake b/cmake/sasl2/local/FindSasl2.cmake new file mode 100644 index 0000000..9eef5a5 --- /dev/null +++ b/cmake/sasl2/local/FindSasl2.cmake @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Stubs to allow us to find folly libs + +set(SASL2_FOUND "true" CACHE STRING "" FORCE) +set(SASL2_INCLUDE_DIR "${SASL2_DIR}/include" CACHE STRING "" FORCE) +set(SASL_INCLUDE_DIRS "${SASL2_INCLUDE_DIR}" CACHE STRING "" FORCE) +set(SASL2_LIBRARIES "${SASL2_DIR}/lib/sasl2/${BYPRODUCT_PREFIX}gs2${BYPRODUCT_SUFFIX}" "${SASL2_DIR}/lib/sasl2/${BYPRODUCT_PREFIX}gssapiv2${BYPRODUCT_SUFFIX}" "${SASL2_DIR}/lib/${BYPRODUCT_PREFIX}sasl2${BYPRODUCT_SUFFIX}" CACHE STRING "" FORCE) +set(SASL_LIBS "${SASL2_LIBRARIES}" CACHE STRING "" FORCE) + +mark_as_advanced( + SASL2_FOUND + WANGLE_LIBRARIES + SASL2_INCLUDE_DIR + SASL_INCLUDE_DIRS + SASL2_LIBRARIES + SASL_LIBS +) + message(STATUS "SASL2 found, ${SASL2_LIBRARIES}") \ No newline at end of file diff --git a/cmake/FindSasl2.cmake b/cmake/sasl2/system/FindSasl2.cmake similarity index 100% rename from cmake/FindSasl2.cmake rename to cmake/sasl2/system/FindSasl2.cmake diff --git a/docker-files/Dockerfile b/docker-files/Dockerfile index 82545d7..f8857cc 100644 --- a/docker-files/Dockerfile +++ b/docker-files/Dockerfile @@ -30,30 +30,25 @@ ENV JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/" RUN apt-get update && \ apt-get install -y vim maven inetutils-ping python-pip doxygen graphviz clang-format valgrind \ wget libgflags-dev libgoogle-glog-dev dh-autoreconf pkg-config libssl-dev build-essential \ - libevent-dev cmake libkrb5-dev git openjdk-8-jdk curl unzip google-mock libsodium-dev libdouble-conversion-dev && \ + libevent-dev cmake libkrb5-dev git openjdk-8-jdk curl unzip google-mock libsodium-dev && \ pip install yapf && \ apt-get -qq clean && \ apt-get -y -qq autoremove && \ rm -rf /var/lib/{apt,dpkg,cache,log}/ && \ rm -rf /tmp/* -RUN wget https://github.com/cyrusimap/cyrus-sasl/releases/download/cyrus-sasl-2.1.26/cyrus-sasl-2.1.26.tar.gz ; \ - tar zxf cyrus-sasl-2.1.26.tar.gz ; \ - cd cyrus-sasl-2.1.26 ; \ - ./configure ; \ - make -j4; \ - make install ;\ - cp /usr/local/lib/sasl2/* /usr/lib/sasl2/ - ## Install Google Test to support RUN wget https://github.com/google/googletest/archive/release-1.8.0.tar.gz && \ tar zxf release-1.8.0.tar.gz && \ rm -f release-1.8.0.tar.gz && \ mv googletest-release-1.8.0 gtest && \ - cd gtest && \ - cmake . && \ - make -j4 && \ - make install + cd gtest && cmake . && make -j4 && make install + +## xenial has no libfmt-dev package in apt +RUN wget https://github.com/fmtlib/fmt/archive/7.0.0.tar.gz && \ + tar zxf 7.0.0.tar.gz && rm -f 7.0.0.tar.gz && \ + cd fmt-7.0.0 && \ + cmake . -DCMAKE_BUILD_TYPE=Release -DFMT_TEST=OFF && make -j4 && make install RUN apt-get update && \ apt-get install -y debconf-utils && \ diff --git a/include/hbase/client/async-batch-rpc-retrying-caller.h b/include/hbase/client/async-batch-rpc-retrying-caller.h index f2e11d5..0ac9391 100644 --- a/include/hbase/client/async-batch-rpc-retrying-caller.h +++ b/include/hbase/client/async-batch-rpc-retrying-caller.h @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include @@ -178,7 +178,7 @@ class AsyncBatchRpcRetryingCaller { std::shared_ptr location_cache_ = nullptr; std::shared_ptr rpc_client_ = nullptr; - std::shared_ptr cpu_pool_ = nullptr; + std::shared_ptr cpu_pool_ = nullptr; std::recursive_mutex multi_mutex_; }; diff --git a/include/hbase/client/async-client-scanner.h b/include/hbase/client/async-client-scanner.h index 4a560c4..c3ea8c4 100644 --- a/include/hbase/client/async-client-scanner.h +++ b/include/hbase/client/async-client-scanner.h @@ -19,7 +19,6 @@ #pragma once #include -#include #include #include #include diff --git a/include/hbase/client/async-connection.h b/include/hbase/client/async-connection.h index 1f1c226..deca611 100644 --- a/include/hbase/client/async-connection.h +++ b/include/hbase/client/async-connection.h @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -53,9 +53,9 @@ class AsyncConnection { virtual std::shared_ptr rpc_client() = 0; virtual std::shared_ptr region_locator() = 0; virtual std::shared_ptr CreateRpcController() = 0; - virtual std::shared_ptr cpu_executor() = 0; - virtual std::shared_ptr io_executor() = 0; - virtual std::shared_ptr retry_executor() = 0; + virtual std::shared_ptr cpu_executor() = 0; + virtual std::shared_ptr io_executor() = 0; + virtual std::shared_ptr retry_executor() = 0; virtual void Close() = 0; }; @@ -84,9 +84,9 @@ class AsyncConnectionImpl : public AsyncConnection, std::shared_ptr CreateRpcController() override { return std::make_shared(); } - std::shared_ptr cpu_executor() override { return cpu_executor_; } - std::shared_ptr io_executor() override { return io_executor_; } - std::shared_ptr retry_executor() override { + std::shared_ptr cpu_executor() override { return cpu_executor_; } + std::shared_ptr io_executor() override { return io_executor_; } + std::shared_ptr retry_executor() override { return retry_executor_; } @@ -107,9 +107,9 @@ class AsyncConnectionImpl : public AsyncConnection, std::shared_ptr connection_conf_; std::shared_ptr caller_factory_; std::shared_ptr retry_timer_; - std::shared_ptr cpu_executor_; - std::shared_ptr io_executor_; - std::shared_ptr retry_executor_; + std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr retry_executor_; std::shared_ptr location_cache_; std::shared_ptr rpc_client_; bool is_closed_ = false; diff --git a/include/hbase/client/async-rpc-retrying-caller-factory.h b/include/hbase/client/async-rpc-retrying-caller-factory.h index 2cc94f4..1277681 100644 --- a/include/hbase/client/async-rpc-retrying-caller-factory.h +++ b/include/hbase/client/async-rpc-retrying-caller-factory.h @@ -18,7 +18,6 @@ */ #pragma once -#include #include #include #include diff --git a/include/hbase/client/async-scan-rpc-retrying-caller.h b/include/hbase/client/async-scan-rpc-retrying-caller.h index 332d5bd..ee18968 100644 --- a/include/hbase/client/async-scan-rpc-retrying-caller.h +++ b/include/hbase/client/async-scan-rpc-retrying-caller.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/include/hbase/client/async-table-result-scanner.h b/include/hbase/client/async-table-result-scanner.h index d67ab3f..6cdd8b4 100644 --- a/include/hbase/client/async-table-result-scanner.h +++ b/include/hbase/client/async-table-result-scanner.h @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/hbase/client/configuration.h b/include/hbase/client/configuration.h index 06f9c79..95f29c6 100644 --- a/include/hbase/client/configuration.h +++ b/include/hbase/client/configuration.h @@ -28,8 +28,6 @@ namespace hbase { -template -using optional = boost::optional; class Configuration { public: diff --git a/include/hbase/client/hbase-configuration-loader.h b/include/hbase/client/hbase-configuration-loader.h index d46217d..d0839d6 100644 --- a/include/hbase/client/hbase-configuration-loader.h +++ b/include/hbase/client/hbase-configuration-loader.h @@ -132,7 +132,7 @@ class HBaseConfigurationLoader { * @param final_text value of final node true or false if present */ bool UpdateMapWithValue(ConfigMap &map, const std::string &key, const std::string &value, - boost::optional final_text); + optional final_text); }; } /* namespace hbase */ diff --git a/include/hbase/client/location-cache.h b/include/hbase/client/location-cache.h index a800642..7b6b22c 100644 --- a/include/hbase/client/location-cache.h +++ b/include/hbase/client/location-cache.h @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -88,8 +88,8 @@ class LocationCache : public AsyncRegionLocator { * @param io_executor executor used to talk to the network */ LocationCache(std::shared_ptr conf, - std::shared_ptr io_executor, - std::shared_ptr cpu_executor, + std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr cp); /** * Destructor. @@ -202,8 +202,8 @@ class LocationCache : public AsyncRegionLocator { /* data */ std::shared_ptr conf_; std::string zk_quorum_; - std::shared_ptr io_executor_; - std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr cpu_executor_; std::shared_ptr> meta_promise_; std::recursive_mutex meta_lock_; MetaUtil meta_util_; diff --git a/include/hbase/client/raw-scan-result-consumer.h b/include/hbase/client/raw-scan-result-consumer.h index ad0cbe3..edbb0c7 100644 --- a/include/hbase/client/raw-scan-result-consumer.h +++ b/include/hbase/client/raw-scan-result-consumer.h @@ -19,7 +19,6 @@ #pragma once #include -#include #include #include #include diff --git a/include/hbase/client/request-converter.h b/include/hbase/client/request-converter.h index 9c671c8..e80625b 100644 --- a/include/hbase/client/request-converter.h +++ b/include/hbase/client/request-converter.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "hbase/connection/request.h" #include "hbase/client/action.h" #include "hbase/client/append.h" diff --git a/include/hbase/client/scan-result-cache.h b/include/hbase/client/scan-result-cache.h index 8b1bc11..27a303a 100644 --- a/include/hbase/client/scan-result-cache.h +++ b/include/hbase/client/scan-result-cache.h @@ -18,7 +18,7 @@ */ #pragma once -#include +#include #include #include #include diff --git a/include/hbase/connection/client-dispatcher.h b/include/hbase/connection/client-dispatcher.h index 33384a7..097478f 100644 --- a/include/hbase/connection/client-dispatcher.h +++ b/include/hbase/connection/client-dispatcher.h @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include diff --git a/include/hbase/connection/connection-factory.h b/include/hbase/connection/connection-factory.h index 14b7fda..02eb303 100644 --- a/include/hbase/connection/connection-factory.h +++ b/include/hbase/connection/connection-factory.h @@ -18,8 +18,8 @@ */ #pragma once -#include -#include +#include +#include #include #include @@ -46,8 +46,8 @@ class ConnectionFactory { * Constructor. * There should only be one ConnectionFactory per client. */ - ConnectionFactory(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, + ConnectionFactory(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); @@ -69,15 +69,15 @@ class ConnectionFactory { std::shared_ptr> client_bootstrap, const std::string &hostname, uint16_t port); - std::shared_ptr io_executor() { return io_executor_; } + std::shared_ptr io_executor() { return io_executor_; } - std::shared_ptr cpu_executor() { return cpu_executor_; } + std::shared_ptr cpu_executor() { return cpu_executor_; } private: std::chrono::nanoseconds connect_timeout_; std::shared_ptr conf_; - std::shared_ptr io_executor_; - std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr cpu_executor_; std::shared_ptr pipeline_factory_; }; } // namespace hbase diff --git a/include/hbase/connection/connection-pool.h b/include/hbase/connection/connection-pool.h index 1198c33..ccabde7 100644 --- a/include/hbase/connection/connection-pool.h +++ b/include/hbase/connection/connection-pool.h @@ -42,8 +42,8 @@ namespace hbase { class ConnectionPool { public: /** Create connection pool wit default connection factory */ - ConnectionPool(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, + ConnectionPool(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); diff --git a/include/hbase/connection/rpc-client.h b/include/hbase/connection/rpc-client.h index 1189410..2b4a921 100644 --- a/include/hbase/connection/rpc-client.h +++ b/include/hbase/connection/rpc-client.h @@ -36,8 +36,8 @@ namespace hbase { class RpcClient { public: - RpcClient(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, + RpcClient(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, std::chrono::nanoseconds connect_timeout = std::chrono::nanoseconds(0)); @@ -77,7 +77,7 @@ class RpcClient { private: std::shared_ptr cp_; - std::shared_ptr io_executor_; + std::shared_ptr io_executor_; std::shared_ptr conf_; }; } // namespace hbase diff --git a/include/hbase/connection/rpc-connection.h b/include/hbase/connection/rpc-connection.h index cbbac63..6c15b14 100644 --- a/include/hbase/connection/rpc-connection.h +++ b/include/hbase/connection/rpc-connection.h @@ -69,8 +69,8 @@ class RpcConnection : public std::enable_shared_from_this { private: std::recursive_mutex mutex_; - std::shared_ptr io_executor_; - std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr cpu_executor_; std::shared_ptr connection_id_; std::shared_ptr hbase_service_; std::shared_ptr cf_; diff --git a/include/hbase/connection/rpc-test-server.h b/include/hbase/connection/rpc-test-server.h index 76ab8ba..c9a6a8a 100644 --- a/include/hbase/connection/rpc-test-server.h +++ b/include/hbase/connection/rpc-test-server.h @@ -18,7 +18,7 @@ */ #pragma once #include -#include +#include #include #include diff --git a/include/hbase/utils/optional.h b/include/hbase/utils/optional.h index c43fd56..f257b44 100644 --- a/include/hbase/utils/optional.h +++ b/include/hbase/utils/optional.h @@ -18,9 +18,8 @@ */ #pragma once - -#include #include +#include namespace hbase { diff --git a/src/hbase/client/async-batch-rpc-retrying-caller.cc b/src/hbase/client/async-batch-rpc-retrying-caller.cc index 6699b90..b159cfc 100644 --- a/src/hbase/client/async-batch-rpc-retrying-caller.cc +++ b/src/hbase/client/async-batch-rpc-retrying-caller.cc @@ -70,7 +70,8 @@ AsyncBatchRpcRetryingCaller::~AsyncBatchRpcRetryingCaller() {} template Future>> AsyncBatchRpcRetryingCaller::Call() { GroupAndSend(actions_, 1); - return collectAll(action2futures_); + // use the executor to convert he SemiFuture to a Future. + return collectAll(action2futures_).via(cpu_pool_.get()); } template @@ -238,8 +239,7 @@ AsyncBatchRpcRetryingCaller::GetRegionLocations( locs.push_back(location_cache_->LocateRegion(*table_name_, action->action()->row(), RegionLocateType::kCurrent, locate_timeout_ns)); } - - return collectAll(locs); + return collectAll(locs).via(cpu_pool_.get()); } template @@ -257,7 +257,7 @@ void AsyncBatchRpcRetryingCaller::GroupAndSend( } GetRegionLocations(actions, locate_timeout_ns) - .then([=](std::vector>> &loc) { + .thenValue([&](std::vector>> loc) { std::lock_guard lck(multi_mutex_); ActionsByServer actions_by_server; std::vector> locate_failed; @@ -305,7 +305,7 @@ void AsyncBatchRpcRetryingCaller::GroupAndSend( TryResubmit(locate_failed, tries); } }) - .onError([=](const folly::exception_wrapper &ew) { + .thenError(folly::tag_t{},[&](const folly::exception_wrapper &ew) { VLOG(1) << "GetRegionLocations() exception: " << ew.what().toStdString() << "tries: " << tries << "; max_attempts_: " << max_attempts_; std::lock_guard lck(multi_mutex_); @@ -331,7 +331,7 @@ AsyncBatchRpcRetryingCaller::GetMultiResponse(const ActionsByServer & multi_calls.push_back( rpc_client_->AsyncCall(host, port, std::move(multi_req), user, "ClientService")); } - return collectAll(multi_calls); + return collectAll(multi_calls).via(cpu_pool_.get()); } template @@ -362,7 +362,7 @@ void AsyncBatchRpcRetryingCaller::Send(const ActionsByServer &actions std::move(RequestConverter::ToMultiRequest(action_by_server.second->actions_by_region()))); GetMultiResponse(actions_by_server) - .then([=](const std::vector>> &completed_responses) { + .thenValue([&](const std::vector>> &completed_responses) { std::lock_guard lck(multi_mutex_); uint64_t num = 0; for (const auto &action_by_server : actions_by_server) { @@ -382,7 +382,7 @@ void AsyncBatchRpcRetryingCaller::Send(const ActionsByServer &actions num++; } }) - .onError([=](const folly::exception_wrapper &ew) { + .thenError(folly::tag_t{},[&](const folly::exception_wrapper &ew) { VLOG(1) << "GetMultiResponse() exception: " << ew.what().toStdString(); std::lock_guard lck(multi_mutex_); for (const auto &action_by_server : actions_by_server) { diff --git a/src/hbase/client/async-client-scanner.cc b/src/hbase/client/async-client-scanner.cc index 50c01ee..5785e2a 100644 --- a/src/hbase/client/async-client-scanner.cc +++ b/src/hbase/client/async-client-scanner.cc @@ -59,7 +59,7 @@ folly::Future> AsyncClientScanner::CallOpen return rpc_client ->AsyncCall(loc->server_name().host_name(), loc->server_name().port(), std::move(preq), security::User::defaultUser(), "ClientService") - .then([self, loc, controller, rpc_client](const std::unique_ptr& presp) { + .thenValue([self, loc, controller, rpc_client](const std::unique_ptr& presp) { VLOG(5) << "Scan Response:" << presp->DebugString(); return std::make_shared(rpc_client, presp, loc, controller); }); @@ -88,16 +88,16 @@ void AsyncClientScanner::OpenScanner() { ->Build(); caller->Call() - .then([this, self](std::shared_ptr resp) { + .thenValue([this, self](std::shared_ptr resp) { VLOG(3) << "Opened scanner with id:" << resp->scan_resp_->scanner_id() << ", region:" << resp->region_location_->DebugString() << ", starting scan"; StartScan(resp); }) - .onError([this, self](const folly::exception_wrapper& e) { + .thenError(folly::tag_t{},[this,self](const folly::exception_wrapper &e) { VLOG(3) << "Open scan request received error:" << e.what(); consumer_->OnError(e); }) - .then([caller, self](const auto r) { return r; }); + .thenValue([caller, self](const auto r) { return r; }); } void AsyncClientScanner::StartScan(std::shared_ptr resp) { @@ -119,7 +119,7 @@ void AsyncClientScanner::StartScan(std::shared_ptr resp) { ->Build(); caller->Start(resp->controller_, resp->scan_resp_, resp->cell_scanner_) - .then([caller, self](const bool has_more) { + .thenValue([caller, self](const bool has_more) { if (has_more) { // open the next scanner on the next region. self->OpenScanner(); @@ -127,8 +127,8 @@ void AsyncClientScanner::StartScan(std::shared_ptr resp) { self->consumer_->OnComplete(); } }) - .onError([caller, self](const folly::exception_wrapper& e) { self->consumer_->OnError(e); }) - .then([caller, self](const auto r) { return r; }); + .thenError(folly::tag_t{},[caller, self](const folly::exception_wrapper& e) { self->consumer_->OnError(e); }) + .thenValue([caller, self](const auto r) { return r; }); } RegionLocateType AsyncClientScanner::GetLocateType(const Scan& scan) { diff --git a/src/hbase/client/async-connection.cc b/src/hbase/client/async-connection.cc index f1bdebc..84456fe 100644 --- a/src/hbase/client/async-connection.cc +++ b/src/hbase/client/async-connection.cc @@ -27,14 +27,14 @@ void AsyncConnectionImpl::Init() { // start thread pools auto io_threads = conf_->GetInt(kClientIoThreadPoolSize, sysconf(_SC_NPROCESSORS_ONLN)); auto cpu_threads = conf_->GetInt(kClientCpuThreadPoolSize, 2 * sysconf(_SC_NPROCESSORS_ONLN)); - cpu_executor_ = std::make_shared(cpu_threads); - io_executor_ = std::make_shared(io_threads); + cpu_executor_ = std::make_shared(cpu_threads); + io_executor_ = std::make_shared(io_threads); /* * We need a retry_executor for a thread pool of size 1 due to a possible bug in wangle/folly. * Otherwise, Assertion 'isInEventBaseThread()' always fails. See the comments * in async-rpc-retrying-caller.cc. */ - retry_executor_ = std::make_shared(1); + retry_executor_ = std::make_shared(1); retry_timer_ = folly::HHWheelTimer::newTimer(retry_executor_->getEventBase()); std::shared_ptr codec = nullptr; diff --git a/src/hbase/client/async-rpc-retrying-caller.cc b/src/hbase/client/async-rpc-retrying-caller.cc index 35cb08e..8c9c8e4 100644 --- a/src/hbase/client/async-rpc-retrying-caller.cc +++ b/src/hbase/client/async-rpc-retrying-caller.cc @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include "hbase/connection/rpc-client.h" @@ -91,8 +91,8 @@ void AsyncSingleRequestRpcRetryingCaller::LocateThenCall() { conn_->region_locator() ->LocateRegion(*table_name_, row_, locate_type_, locate_timeout_ns) - .then([this](std::shared_ptr loc) { Call(*loc); }) - .onError([this](const exception_wrapper& e) { + .thenValue([this](std::shared_ptr loc) { Call(*loc); }) + .thenError(folly::tag_t{},[this](const exception_wrapper& e) { OnError(e, [this, e]() -> std::string { return "Locate '" + row_ + "' in " + table_name_->namespace_() + "::" + @@ -179,8 +179,8 @@ void AsyncSingleRequestRpcRetryingCaller::Call(const RegionLocation& loc) // Otherwise, it may get deleted underneat us. We are just copying for now. auto loc_ptr = std::make_shared(loc); callable_(controller_, loc_ptr, rpc_client) - .then([loc_ptr, this](const RESP& resp) { this->promise_->setValue(std::move(resp)); }) - .onError([&, loc_ptr, this](const exception_wrapper& e) { + .thenValue([loc_ptr, this](const RESP& resp) { this->promise_->setValue(std::move(resp)); }) + .thenError(folly::tag_t{},[&, loc_ptr, this](const exception_wrapper& e) { OnError( e, [&, this, e]() -> std::string { diff --git a/src/hbase/client/async-scan-rpc-retrying-caller.cc b/src/hbase/client/async-scan-rpc-retrying-caller.cc index 2189128..19fd19a 100644 --- a/src/hbase/client/async-scan-rpc-retrying-caller.cc +++ b/src/hbase/client/async-scan-rpc-retrying-caller.cc @@ -407,11 +407,11 @@ void AsyncScanRpcRetryingCaller::Call() { region_location_->server_name().port(), std::move(req), security::User::defaultUser(), "ClientService") .via(conn_->cpu_executor().get()) - .then([self, this](const std::unique_ptr& resp) { + .thenValue([self, this](const std::unique_ptr& resp) { auto scan_resp = std::static_pointer_cast(resp->resp_msg()); return OnComplete(controller_, scan_resp, resp->cell_scanner()); }) - .onError([self, this](const folly::exception_wrapper& e) { OnError(e); }); + .thenError(folly::tag_t{},[self, this](const folly::exception_wrapper& e) { OnError(e); }); } void AsyncScanRpcRetryingCaller::CloseScanner() { @@ -426,7 +426,7 @@ void AsyncScanRpcRetryingCaller::CloseScanner() { ->AsyncCall(region_location_->server_name().host_name(), region_location_->server_name().port(), std::move(req), security::User::defaultUser(), "ClientService") - .onError([self, this](const folly::exception_wrapper& e) -> std::unique_ptr { + .thenError(folly::tag_t{},[self, this](const folly::exception_wrapper& e) -> std::unique_ptr { LOG(WARNING) << "Call to " + region_location_->server_name().ShortDebugString() + " for closing scanner_id = " + folly::to(scanner_id_) + " for " + region_location_->region_info().ShortDebugString() + diff --git a/src/hbase/client/configuration.cc b/src/hbase/client/configuration.cc index 385ea6a..ace976a 100644 --- a/src/hbase/client/configuration.cc +++ b/src/hbase/client/configuration.cc @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include namespace hbase { @@ -161,7 +161,7 @@ optional Configuration::GetInt(const std::string &key) const { throw std::runtime_error(blex.what()); } } - return none; + return optional(); } int32_t Configuration::GetInt(const std::string &key, int32_t default_value) const { @@ -177,7 +177,7 @@ optional Configuration::GetLong(const std::string &key) const { throw std::runtime_error(blex.what()); } } - return none; + return optional(); } int64_t Configuration::GetLong(const std::string &key, int64_t default_value) const { @@ -193,7 +193,7 @@ optional Configuration::GetDouble(const std::string &key) const { throw std::runtime_error(blex.what()); } } - return none; + return optional(); } double Configuration::GetDouble(const std::string &key, double default_value) const { @@ -214,7 +214,7 @@ optional Configuration::GetBool(const std::string &key) const { throw std::runtime_error(what.str()); } } - return none; + return optional(); } bool Configuration::GetBool(const std::string &key, bool default_value) const { diff --git a/src/hbase/client/hbase-configuration-loader.cc b/src/hbase/client/hbase-configuration-loader.cc index 2233794..a72545a 100644 --- a/src/hbase/client/hbase-configuration-loader.cc +++ b/src/hbase/client/hbase-configuration-loader.cc @@ -151,7 +151,7 @@ optional HBaseConfigurationLoader::LoadResources( if (success) { return Configuration(conf_property); } else { - return none; + return optional(); } } @@ -174,8 +174,8 @@ bool HBaseConfigurationLoader::LoadProperties(const std::string &file, ConfigMap std::string name_node = v.second.get("name"); std::string value_node = v.second.get("value"); if ((name_node.size() > 0) && (value_node.size() > 0)) { - boost::optional final_node = v.second.get_optional("final"); - UpdateMapWithValue(property_map, name_node, value_node, final_node); + auto final_node = v.second.get_optional("final"); + UpdateMapWithValue(property_map, name_node, value_node, final_node.get()); } } } @@ -188,16 +188,16 @@ bool HBaseConfigurationLoader::LoadProperties(const std::string &file, ConfigMap bool HBaseConfigurationLoader::UpdateMapWithValue(ConfigMap &map, const std::string &key, const std::string &value, - boost::optional final_text) { + optional final_text) { auto map_value = map.find(key); if (map_value != map.end() && map_value->second.final) { return false; } bool final_value = false; - if (nullptr != final_text.get_ptr()) { - if (is_valid_bool(final_text.get())) { - final_value = str_to_bool(final_text.get()); + if (final_text) { + if (is_valid_bool(final_text.value())) { + final_value = str_to_bool(final_text.value()); } } diff --git a/src/hbase/client/location-cache.cc b/src/hbase/client/location-cache.cc index cf1d8ef..4fe73ef 100644 --- a/src/hbase/client/location-cache.cc +++ b/src/hbase/client/location-cache.cc @@ -19,10 +19,10 @@ #include "hbase/client/location-cache.h" #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -45,8 +45,8 @@ using hbase::pb::TableName; namespace hbase { LocationCache::LocationCache(std::shared_ptr conf, - std::shared_ptr io_executor, - std::shared_ptr cpu_executor, + std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr cp) : conf_(conf), io_executor_(io_executor), @@ -85,7 +85,7 @@ folly::Future LocationCache::LocateMeta() { if (meta_promise_ == nullptr) { this->RefreshMetaLocation(); } - return meta_promise_->getFuture().onError([&](const folly::exception_wrapper &ew) { + return meta_promise_->getFuture().thenError(folly::tag_t{},[&](const folly::exception_wrapper &ew) { auto promise = InvalidateMeta(); if (promise) { promise->setException(ew); @@ -149,25 +149,25 @@ folly::Future> LocationCache::LocateFromMeta( const TableName &tn, const std::string &row) { return this->LocateMeta() .via(cpu_executor_.get()) - .then([this](ServerName sn) { + .thenValue([this](ServerName sn) { // TODO: use RpcClient? auto remote_id = std::make_shared(sn.host_name(), sn.port()); return this->cp_->GetConnection(remote_id); }) - .then([tn, row, this](std::shared_ptr rpc_connection) { + .thenValue([tn, row, this](std::shared_ptr rpc_connection) { return rpc_connection->SendRequest(std::move(meta_util_.MetaRequest(tn, row))); }) - .onError([&](const folly::exception_wrapper &ew) { + .thenError(folly::tag_t{},[&](const folly::exception_wrapper &ew) { auto promise = InvalidateMeta(); throw ew; return static_cast>(nullptr); }) - .then([tn, this](std::unique_ptr resp) { + .thenValue([tn, this](std::unique_ptr resp) { // take the protobuf response and make it into // a region location. return meta_util_.CreateLocation(std::move(*resp), tn); }) - .then([tn, this](std::shared_ptr rl) { + .thenValue([tn, this](std::shared_ptr rl) { // Make sure that the correct location was found. if (rl->region_info().table_name().namespace_() != tn.namespace_() || rl->region_info().table_name().qualifier() != tn.qualifier()) { @@ -175,12 +175,12 @@ folly::Future> LocationCache::LocateFromMeta( } return rl; }) - .then([this](std::shared_ptr rl) { + .thenValue([this](std::shared_ptr rl) { auto remote_id = std::make_shared(rl->server_name().host_name(), rl->server_name().port()); return rl; }) - .then([tn, this](std::shared_ptr rl) { + .thenValue([tn, this](std::shared_ptr rl) { // now add fetched location to the cache. this->CacheLocation(tn, rl); return rl; @@ -194,7 +194,7 @@ folly::Future> LocationCache::LocateRegion( const int64_t locate_ns) { // We maybe asked to locate meta itself if (MetaUtil::IsMeta(tn)) { - return LocateMeta().then([this](const ServerName &server_name) { + return LocateMeta().thenValue([this](const ServerName &server_name) { auto rl = std::make_shared(MetaUtil::kMetaRegionName, meta_util_.meta_region_info(), server_name); return rl; diff --git a/src/hbase/client/meta-utils.cc b/src/hbase/client/meta-utils.cc index 4a3727d..a74b4fa 100644 --- a/src/hbase/client/meta-utils.cc +++ b/src/hbase/client/meta-utils.cc @@ -66,7 +66,7 @@ std::unique_ptr MetaUtil::MetaRequest(const TableName tn, const std::st // Set the region this scan goes to auto region = msg->mutable_region(); - region->set_value(MetaUtil::kMetaRegionName); + region->set_value(MetaUtil::kMetaRegion); region->set_type( RegionSpecifier_RegionSpecifierType::RegionSpecifier_RegionSpecifierType_ENCODED_REGION_NAME); diff --git a/src/hbase/client/raw-async-table.cc b/src/hbase/client/raw-async-table.cc index f017e86..d19dee2 100644 --- a/src/hbase/client/raw-async-table.cc +++ b/src/hbase/client/raw-async-table.cc @@ -53,7 +53,7 @@ folly::Future RawAsyncTable::Call( return rpc_client ->AsyncCall(loc->server_name().host_name(), loc->server_name().port(), std::move(preq), User::defaultUser(), "ClientService") - .then( + .thenValue( [resp_converter](const std::unique_ptr& presp) { return resp_converter(*presp); }); } @@ -76,7 +76,7 @@ folly::Future> RawAsyncTable::Get(const hbase::Get& get) // context and get deallocated since the caller injects a lot of closures which capture [this, &] // which is use-after-free. We are just passing an identity closure capturing caller by value to // ensure that the lifecycle of the Caller object is longer than the retry lambdas. - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future> RawAsyncTable::Increment(const hbase::Increment& incr) { auto caller = @@ -93,7 +93,7 @@ folly::Future> RawAsyncTable::Increment(const hbase::Inc }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future RawAsyncTable::Put(const hbase::Put& put) { @@ -109,7 +109,7 @@ folly::Future RawAsyncTable::Put(const hbase::Put& put) { }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future RawAsyncTable::CheckAndPut(const std::string& row, const std::string& family, @@ -135,7 +135,7 @@ folly::Future RawAsyncTable::CheckAndPut(const std::string& row, const std }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future RawAsyncTable::CheckAndDelete(const std::string& row, const std::string& family, @@ -162,7 +162,7 @@ folly::Future RawAsyncTable::CheckAndDelete(const std::string& row, const }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future RawAsyncTable::Delete(const hbase::Delete& del) { @@ -178,7 +178,7 @@ folly::Future RawAsyncTable::Delete(const hbase::Delete& del) { }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future> RawAsyncTable::Append(const hbase::Append& append) { @@ -196,7 +196,7 @@ folly::Future> RawAsyncTable::Append(const hbase::Append }) ->Build(); - return caller->Call().then([caller](const auto r) { return r; }); + return caller->Call().thenValue([caller](const auto r) { return r; }); } folly::Future>>> RawAsyncTable::Get( @@ -224,7 +224,7 @@ folly::Future>> RawAsyncTable::Batch( ->start_log_errors_count(connection_conf_->start_log_errors_count()) ->Build(); - return caller->Call().then([caller](auto r) { return r; }); + return caller->Call().thenValue([caller](auto r) { return r; }); } void RawAsyncTable::Scan(const hbase::Scan& scan, std::shared_ptr consumer) { diff --git a/src/hbase/client/table.cc b/src/hbase/client/table.cc index 0daf4a3..0066d5e 100644 --- a/src/hbase/client/table.cc +++ b/src/hbase/client/table.cc @@ -49,8 +49,7 @@ Table::Table(const TableName &table_name, std::shared_ptr async Table::~Table() {} std::shared_ptr Table::Get(const hbase::Get &get) { - auto context = async_table_->Get(get); - return context.get(operation_timeout()); + return async_table_->Get(get).get(operation_timeout()); } std::shared_ptr Table::Scan(const hbase::Scan &scan) { @@ -69,37 +68,31 @@ int64_t Table::ResultSize2CacheSize(int64_t max_results_size) const { } void Table::Put(const hbase::Put &put) { - auto future = async_table_->Put(put); - future.get(operation_timeout()); + async_table_->Put(put).get(operation_timeout()); } bool Table::CheckAndPut(const std::string &row, const std::string &family, const std::string &qualifier, const std::string &value, const hbase::Put &put, const pb::CompareType &compare_op) { - auto context = async_table_->CheckAndPut(row, family, qualifier, value, put, compare_op); - return context.get(operation_timeout()); + return async_table_->CheckAndPut(row, family, qualifier, value, put, compare_op).get(operation_timeout()); } bool Table::CheckAndDelete(const std::string &row, const std::string &family, const std::string &qualifier, const std::string &value, const hbase::Delete &del, const pb::CompareType &compare_op) { - auto context = async_table_->CheckAndDelete(row, family, qualifier, value, del, compare_op); - return context.get(operation_timeout()); + return async_table_->CheckAndDelete(row, family, qualifier, value, del, compare_op).get(operation_timeout()); } void Table::Delete(const hbase::Delete &del) { - auto future = async_table_->Delete(del); - future.get(operation_timeout()); + async_table_->Delete(del).get(operation_timeout()); } std::shared_ptr Table::Increment(const hbase::Increment &increment) { - auto context = async_table_->Increment(increment); - return context.get(operation_timeout()); + return async_table_->Increment(increment).get(operation_timeout()); } std::shared_ptr Table::Append(const hbase::Append &append) { - auto context = async_table_->Append(append); - return context.get(operation_timeout()); + return async_table_->Append(append).get(operation_timeout()); } milliseconds Table::operation_timeout() const { diff --git a/src/hbase/connection/connection-factory.cc b/src/hbase/connection/connection-factory.cc index 14ac22b..1eba197 100644 --- a/src/hbase/connection/connection-factory.cc +++ b/src/hbase/connection/connection-factory.cc @@ -39,8 +39,8 @@ using std::chrono::nanoseconds; namespace hbase { -ConnectionFactory::ConnectionFactory(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, +ConnectionFactory::ConnectionFactory(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, nanoseconds connect_timeout) @@ -67,14 +67,14 @@ std::shared_ptr ConnectionFactory::Connect( const std::string &hostname, uint16_t port) { // connection should happen from an IO thread try { - auto future = via(io_executor_.get()).then([=]() { + auto future = via(io_executor_.get()).thenValue([&](folly::Unit) { VLOG(1) << "Connecting to server: " << hostname << ":" << port; return client_bootstrap->connect(folly::SocketAddress(hostname, port, true), std::chrono::duration_cast(connect_timeout_)); }); // See about using shared promise for this. - auto pipeline = future.get(); + auto pipeline = std::move(future).get(); VLOG(1) << "Connected to server: " << hostname << ":" << port; auto dispatcher = diff --git a/src/hbase/connection/connection-pool.cc b/src/hbase/connection/connection-pool.cc index 92e87f8..69b1b4e 100644 --- a/src/hbase/connection/connection-pool.cc +++ b/src/hbase/connection/connection-pool.cc @@ -20,7 +20,7 @@ #include "hbase/connection/connection-pool.h" #include -#include +#include #include #include @@ -31,8 +31,8 @@ using std::chrono::nanoseconds; namespace hbase { -ConnectionPool::ConnectionPool(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, +ConnectionPool::ConnectionPool(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, nanoseconds connect_timeout) : cf_(std::make_shared(io_executor, cpu_executor, codec, conf, diff --git a/src/hbase/connection/pipeline.cc b/src/hbase/connection/pipeline.cc index 45ac0c0..329f4e3 100644 --- a/src/hbase/connection/pipeline.cc +++ b/src/hbase/connection/pipeline.cc @@ -18,7 +18,7 @@ */ #include "hbase/connection/pipeline.h" -#include +#include #include #include #include diff --git a/src/hbase/connection/rpc-client.cc b/src/hbase/connection/rpc-client.cc index d73829e..77ea895 100644 --- a/src/hbase/connection/rpc-client.cc +++ b/src/hbase/connection/rpc-client.cc @@ -20,10 +20,10 @@ #include "hbase/connection/rpc-client.h" #include -#include +#include #include #include -#include +#include #include "hbase/exceptions/exception.h" using hbase::security::User; @@ -31,8 +31,8 @@ using std::chrono::nanoseconds; namespace hbase { -RpcClient::RpcClient(std::shared_ptr io_executor, - std::shared_ptr cpu_executor, +RpcClient::RpcClient(std::shared_ptr io_executor, + std::shared_ptr cpu_executor, std::shared_ptr codec, std::shared_ptr conf, nanoseconds connect_timeout) : io_executor_(io_executor), conf_(conf) { @@ -83,7 +83,7 @@ folly::Future> RpcClient::SendRequest( try { return GetConnection(remote_id) ->SendRequest(std::move(req)) - .onError([&, this](const folly::exception_wrapper& ew) { + .thenError([&, this](const folly::exception_wrapper& ew) { VLOG(3) << folly::sformat("RpcClient Exception: {}", ew.what()); ew.with_exception([&, this](const hbase::ConnectionException& re) { /* bad connection, remove it from pool. */ diff --git a/src/hbase/connection/rpc-test-server.cc b/src/hbase/connection/rpc-test-server.cc index 0be06ed..61e1364 100644 --- a/src/hbase/connection/rpc-test-server.cc +++ b/src/hbase/connection/rpc-test-server.cc @@ -65,6 +65,8 @@ Future> RpcTestService::operator()(std::unique_ptrset_call_id(request->call_id()); std::string method_name = request->method(); + std::cout << "received " << method_name << std::endl; + if (method_name == "ping") { auto pb_resp_msg = std::make_shared(); response->set_resp_msg(pb_resp_msg); diff --git a/src/hbase/examples/load-client.cc b/src/hbase/examples/load-client.cc index a321845..4accc5a 100644 --- a/src/hbase/examples/load-client.cc +++ b/src/hbase/examples/load-client.cc @@ -17,7 +17,7 @@ * */ -#include +#include #include #include diff --git a/src/hbase/examples/simple-client.cc b/src/hbase/examples/simple-client.cc index 25f203a..f031820 100644 --- a/src/hbase/examples/simple-client.cc +++ b/src/hbase/examples/simple-client.cc @@ -17,7 +17,7 @@ * */ -#include +#include #include #include diff --git a/src/hbase/serde/rpc-serde.cc b/src/hbase/serde/rpc-serde.cc index b7d75f4..22b1fcf 100644 --- a/src/hbase/serde/rpc-serde.cc +++ b/src/hbase/serde/rpc-serde.cc @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include diff --git a/src/hbase/test-util/mini-cluster-util.cc b/src/hbase/test-util/mini-cluster-util.cc index 648c0c8..8444ff4 100644 --- a/src/hbase/test-util/mini-cluster-util.cc +++ b/src/hbase/test-util/mini-cluster-util.cc @@ -18,6 +18,7 @@ */ #include "hbase/test-util/mini-cluster-util.h" +#include #include #include diff --git a/src/hbase/test-util/mini-cluster.cc b/src/hbase/test-util/mini-cluster.cc index 6cdfafb..be0139c 100644 --- a/src/hbase/test-util/mini-cluster.cc +++ b/src/hbase/test-util/mini-cluster.cc @@ -238,7 +238,6 @@ jobject MiniCluster::CreateTable(const string &table, const vector &fami for (const auto& key : keys) { env_->SetObjectArrayElement(key_array, i++, StrToByteChar(key)); } - jobject tbl = env_->CallObjectMethod(htu_, create_table_with_split_mid_, table_name, family_array, key_array); return tbl; diff --git a/src/hbase/utils/user-util.cc b/src/hbase/utils/user-util.cc index ec8bb27..bf70be5 100644 --- a/src/hbase/utils/user-util.cc +++ b/src/hbase/utils/user-util.cc @@ -19,7 +19,7 @@ #include "hbase/utils/user-util.h" -#include +#include #include #include #include diff --git a/src/test/async-batch-rpc-retrying-test.cc b/src/test/async-batch-rpc-retrying-test.cc index 4608d74..fa4886a 100644 --- a/src/test/async-batch-rpc-retrying-test.cc +++ b/src/test/async-batch-rpc-retrying-test.cc @@ -17,12 +17,13 @@ * */ -#include +#include #include #include #include #include -#include +#include +#include #include #include @@ -204,9 +205,9 @@ class MockAsyncConnection : public AsyncConnection, public: MockAsyncConnection(std::shared_ptr conn_conf, std::shared_ptr retry_timer, - std::shared_ptr cpu_executor, - std::shared_ptr io_executor, - std::shared_ptr retry_executor, + std::shared_ptr cpu_executor, + std::shared_ptr io_executor, + std::shared_ptr retry_executor, std::shared_ptr rpc_client, std::shared_ptr region_locator) : conn_conf_(conn_conf), @@ -229,9 +230,9 @@ class MockAsyncConnection : public AsyncConnection, } std::shared_ptr rpc_client() override { return rpc_client_; } std::shared_ptr region_locator() override { return region_locator_; } - std::shared_ptr cpu_executor() override { return cpu_executor_; } - std::shared_ptr io_executor() override { return io_executor_; } - std::shared_ptr retry_executor() override { + std::shared_ptr cpu_executor() override { return cpu_executor_; } + std::shared_ptr io_executor() override { return io_executor_; } + std::shared_ptr retry_executor() override { return retry_executor_; } @@ -251,9 +252,9 @@ class MockAsyncConnection : public AsyncConnection, std::shared_ptr caller_factory_; std::shared_ptr rpc_client_; std::shared_ptr region_locator_; - std::shared_ptr cpu_executor_; - std::shared_ptr io_executor_; - std::shared_ptr retry_executor_; + std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr retry_executor_; }; class MockRawAsyncTableImpl { @@ -292,9 +293,9 @@ std::shared_ptr getAsyncConnection( Client &client, uint32_t operation_timeout_millis, uint32_t tries, std::shared_ptr region_locator) { /* init region location and rpc channel */ - auto cpu_executor_ = std::make_shared(4); + auto cpu_executor_ = std::make_shared(4); auto io_executor_ = client.async_connection()->io_executor(); - auto retry_executor_ = std::make_shared(1); + auto retry_executor_ = std::make_shared(1); auto codec = std::make_shared(); auto rpc_client = std::make_shared(io_executor_, cpu_executor_, codec, AsyncBatchRpcRetryTest::test_util->conf()); diff --git a/src/test/async-rpc-retrying-test.cc b/src/test/async-rpc-retrying-test.cc index 59fcd20..c7c6217 100644 --- a/src/test/async-rpc-retrying-test.cc +++ b/src/test/async-rpc-retrying-test.cc @@ -17,13 +17,13 @@ * */ -#include +#include #include #include #include #include #include -#include +#include #include #include @@ -183,9 +183,9 @@ class MockAsyncConnection : public AsyncConnection, public: MockAsyncConnection(std::shared_ptr conn_conf, std::shared_ptr retry_timer, - std::shared_ptr cpu_executor, - std::shared_ptr io_executor, - std::shared_ptr retry_executor, + std::shared_ptr cpu_executor, + std::shared_ptr io_executor, + std::shared_ptr retry_executor, std::shared_ptr rpc_client, std::shared_ptr region_locator) : conn_conf_(conn_conf), @@ -208,9 +208,9 @@ class MockAsyncConnection : public AsyncConnection, } std::shared_ptr rpc_client() override { return rpc_client_; } std::shared_ptr region_locator() override { return region_locator_; } - std::shared_ptr cpu_executor() override { return cpu_executor_; } - std::shared_ptr io_executor() override { return io_executor_; } - std::shared_ptr retry_executor() override { + std::shared_ptr cpu_executor() override { return cpu_executor_; } + std::shared_ptr io_executor() override { return io_executor_; } + std::shared_ptr retry_executor() override { return retry_executor_; } @@ -225,9 +225,9 @@ class MockAsyncConnection : public AsyncConnection, std::shared_ptr caller_factory_; std::shared_ptr rpc_client_; std::shared_ptr region_locator_; - std::shared_ptr cpu_executor_; - std::shared_ptr io_executor_; - std::shared_ptr retry_executor_; + std::shared_ptr cpu_executor_; + std::shared_ptr io_executor_; + std::shared_ptr retry_executor_; }; template @@ -269,12 +269,12 @@ class MockRawAsyncTableImpl { auto f = promise_->getFuture(); VLOG(1) << "calling rpc_call"; rpc_call(rpc_client, loc, controller, std::move(req_converter(req, loc->region_name()))) - .then([&, this, resp_converter](std::unique_ptr presp) { + .thenValue([&, this, resp_converter](std::unique_ptr presp) { VLOG(1) << "MockRawAsyncTableImpl#call succeded: "; RESP result = resp_converter(*presp); promise_->setValue(result); }) - .onError([this](const exception_wrapper &e) { + .thenError([this](const exception_wrapper &e) { VLOG(1) << "entering MockRawAsyncTableImpl#call, exception: " << e.what(); VLOG(1) << "entering MockRawAsyncTableImpl#call, error typeinfo: " << typeid(e).name(); promise_->setException(e); @@ -310,10 +310,10 @@ void runTest(std::shared_ptr region_locator, std::string /* init region location and rpc channel */ auto region_location = table->GetRegionLocation(row); - // auto io_executor_ = std::make_shared(4); - auto cpu_executor_ = std::make_shared(4); + // auto io_executor_ = std::make_shared(4); + auto cpu_executor_ = std::make_shared(4); auto io_executor_ = client.async_connection()->io_executor(); - auto retry_executor_ = std::make_shared(1); + auto retry_executor_ = std::make_shared(1); auto codec = std::make_shared(); auto rpc_client = std::make_shared(io_executor_, cpu_executor_, codec, AsyncRpcRetryTest::test_util->conf()); diff --git a/src/test/bytes-util-test.cc b/src/test/bytes-util-test.cc index 8997501..2ef07a6 100644 --- a/src/test/bytes-util-test.cc +++ b/src/test/bytes-util-test.cc @@ -17,7 +17,8 @@ * */ -#include +#include +#include #include #include "hbase/utils/bytes-util.h" diff --git a/src/test/client-test.cc b/src/test/client-test.cc index 282039c..ebdf585 100644 --- a/src/test/client-test.cc +++ b/src/test/client-test.cc @@ -207,7 +207,7 @@ TEST_F(ClientTest, PutGetDelete) { result = table->Get(get); ASSERT_TRUE(!result->IsEmpty()) << "Result shouldn't be empty."; ASSERT_FALSE(result->Value("d", "1")) << "Column 1 should be gone"; - ASSERT_TRUE(result->Value("d", "extra") != none) << "Column extra should have value"; + ASSERT_TRUE(result->Value("d", "extra")) << "Column extra should have value"; EXPECT_EQ(valExt, *(result->Value("d", "ext"))) << "Column ext should have value"; // delete all cells from "extra" column diff --git a/src/test/concurrent-map-test.cc b/src/test/concurrent-map-test.cc index b1733ad..2b44ef0 100644 --- a/src/test/concurrent-map-test.cc +++ b/src/test/concurrent-map-test.cc @@ -17,7 +17,8 @@ * */ -#include +#include +#include #include #include "hbase/test-util/test-util.h" diff --git a/src/test/connection-pool-test.cc b/src/test/connection-pool-test.cc index 5886a42..b97e7cf 100644 --- a/src/test/connection-pool-test.cc +++ b/src/test/connection-pool-test.cc @@ -17,7 +17,7 @@ * */ -#include +#include #include #include "hbase/connection/connection-factory.h" diff --git a/src/test/hbase-configuration-test.cc b/src/test/hbase-configuration-test.cc index a5760e8..e724bfb 100644 --- a/src/test/hbase-configuration-test.cc +++ b/src/test/hbase-configuration-test.cc @@ -150,7 +150,7 @@ TEST(Configuration, LoadConfFromDefaultLocation) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("custom-prop", "Set this value").c_str(), "custom-value"); EXPECT_STREQ((*conf).Get("default-prop", "Set this value").c_str(), "default-value"); } @@ -167,7 +167,7 @@ TEST(Configuration, LoadConfFromCustomLocation) { HBaseConfigurationLoader loader; std::vector resources{kHBaseSiteXml}; hbase::optional conf = loader.LoadResources(kHBaseConfPath, resources); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value"); EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value"); } @@ -188,7 +188,7 @@ TEST(Configuration, LoadConfFromMultipleLocatons) { std::string conf_paths = kDefHBaseConfPath + ":" + kHBaseConfPath; std::vector resources{kHBaseDefaultXml, kHBaseSiteXml}; hbase::optional conf = loader.LoadResources(conf_paths, resources); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("default-prop", "From hbase-default.xml").c_str(), "default-value"); EXPECT_STREQ((*conf).Get("custom-prop", "").c_str(), "custom-value"); EXPECT_STRNE((*conf).Get("custom-prop", "").c_str(), "some-value"); @@ -207,7 +207,7 @@ TEST(Configuration, DefaultValues) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("default-prop", "Set this value.").c_str(), "default-value"); EXPECT_STREQ((*conf).Get("custom-prop", "Set this value.").c_str(), "custom-value"); } @@ -219,7 +219,7 @@ TEST(Configuration, FinalValues) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("hbase.rootdir", "").c_str(), "/root/hbase-docker/apps/hbase/data"); EXPECT_STREQ((*conf).Get("hbase.zookeeper.property.datadir", "").c_str(), "/root/hbase-docker/zookeeper"); @@ -241,7 +241,7 @@ TEST(Configuration, EnvVars) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("hbase-client.user.name", "").c_str(), "${user.name}"); EXPECT_STRNE((*conf).Get("hbase-client.user.name", "root").c_str(), "test-user"); } @@ -253,7 +253,7 @@ TEST(Configuration, SelfRef) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("selfRef", "${selfRef}").c_str(), "${selfRef}"); } @@ -264,7 +264,7 @@ TEST(Configuration, VarExpansion) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_STREQ((*conf).Get("foo.substs", "foo-value").c_str(), "bar-value,bar-value,bar-value,bar-value,bar-value,bar-value," "bar-value,bar-value,bar-value,bar-value,"); @@ -278,7 +278,7 @@ TEST(Configuration, VarExpansionException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; ASSERT_THROW((*conf).Get("foo.substs.exception", "foo-value").c_str(), std::runtime_error); } @@ -289,7 +289,7 @@ TEST(Configuration, GetInt) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_EQ(16000, (*conf).GetInt("int", 0)); EXPECT_EQ(2147483646, (*conf).GetInt("int.largevalue", 0)); } @@ -301,7 +301,7 @@ TEST(Configuration, GetLong) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_EQ(2147483850, (*conf).GetLong("long", 0)); EXPECT_EQ(9223372036854775807, (*conf).GetLong("long.largevalue", 0)); } @@ -313,7 +313,7 @@ TEST(Configuration, GetDouble) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_DOUBLE_EQ(17.9769e+100, (*conf).GetDouble("double", 0.0)); EXPECT_DOUBLE_EQ(170.769e+200, (*conf).GetDouble("double.largevalue", 0.0)); } @@ -325,7 +325,7 @@ TEST(Configuration, GetBool) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; EXPECT_EQ(true, (*conf).GetBool("bool.true", true)); EXPECT_EQ(false, (*conf).GetBool("bool.false", false)); } @@ -337,7 +337,7 @@ TEST(Configuration, GetIntException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; ASSERT_THROW((*conf).GetInt("int.exception", 0), std::runtime_error); } @@ -348,7 +348,7 @@ TEST(Configuration, GetLongException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; ASSERT_THROW((*conf).GetLong("long.exception", 0), std::runtime_error); } @@ -359,7 +359,7 @@ TEST(Configuration, GetDoubleException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; ASSERT_THROW((*conf).GetDouble("double.exception", 0), std::runtime_error); } @@ -370,7 +370,7 @@ TEST(Configuration, GetBoolException) { HBaseConfigurationLoader loader; hbase::optional conf = loader.LoadDefaultResources(); - ASSERT_TRUE(conf != none) << "No configuration object present."; + ASSERT_TRUE(conf) << "No configuration object present."; ASSERT_THROW((*conf).GetBool("bool.exception", false), std::runtime_error); } diff --git a/src/test/location-cache-test.cc b/src/test/location-cache-test.cc index 0d030c8..6ad9cc9 100644 --- a/src/test/location-cache-test.cc +++ b/src/test/location-cache-test.cc @@ -56,23 +56,23 @@ class LocationCacheTest : public ::testing::Test { std::unique_ptr LocationCacheTest::test_util_ = nullptr; TEST_F(LocationCacheTest, TestGetMetaNodeContents) { - auto cpu = std::make_shared(4); - auto io = std::make_shared(4); + auto cpu = std::make_shared(4); + auto io = std::make_shared(4); auto codec = std::make_shared(); auto cp = std::make_shared(io, cpu, codec, LocationCacheTest::test_util_->conf()); LocationCache cache{LocationCacheTest::test_util_->conf(), io, cpu, cp}; auto f = cache.LocateMeta(); - auto result = f.get(); ASSERT_FALSE(f.hasException()); - ASSERT_TRUE(result.has_port()); - ASSERT_TRUE(result.has_host_name()); + auto res = std::move(f).get(); + ASSERT_TRUE(res.has_port()); + ASSERT_TRUE(res.has_host_name()); cpu->stop(); io->stop(); } TEST_F(LocationCacheTest, TestGetRegionLocation) { - auto cpu = std::make_shared(4); - auto io = std::make_shared(4); + auto cpu = std::make_shared(4); + auto io = std::make_shared(4); auto codec = std::make_shared(); auto cp = std::make_shared(io, cpu, codec, LocationCacheTest::test_util_->conf()); LocationCache cache{LocationCacheTest::test_util_->conf(), io, cpu, cp}; @@ -89,8 +89,8 @@ TEST_F(LocationCacheTest, TestGetRegionLocation) { } TEST_F(LocationCacheTest, TestCaching) { - auto cpu = std::make_shared(4); - auto io = std::make_shared(4); + auto cpu = std::make_shared(4); + auto io = std::make_shared(4); auto codec = std::make_shared(); auto cp = std::make_shared(io, cpu, codec, LocationCacheTest::test_util_->conf()); LocationCache cache{LocationCacheTest::test_util_->conf(), io, cpu, cp}; diff --git a/src/test/result-test.cc b/src/test/result-test.cc index 581db32..3bd80e9 100644 --- a/src/test/result-test.cc +++ b/src/test/result-test.cc @@ -113,7 +113,7 @@ TEST(Result, FilledResult) { // Value will be nullptr as no such family and qualifier is present ASSERT_FALSE(result.Value("family-4", "qualifier")); // Value will be present as family and qualifier is present - ASSERT_TRUE(result.Value("family-4", "column-4") != none); + ASSERT_TRUE(result.Value("family-4", "column-4")); // Value should be present and match. EXPECT_EQ(latest_cell->Value(), (*result.ColumnLatestCell("family-4", "column-4")).Value()); EXPECT_EQ("value-5", (*result.ColumnLatestCell("family-5", "column-5")).Value()); diff --git a/src/test/rpc-test.cc b/src/test/rpc-test.cc index 277d573..c2771c4 100644 --- a/src/test/rpc-test.cc +++ b/src/test/rpc-test.cc @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include @@ -79,16 +79,16 @@ std::shared_ptr GetRpcServerAddress(ServerPtr server) { } std::shared_ptr CreateRpcClient(std::shared_ptr conf) { - auto io_executor = std::make_shared(1); - auto cpu_executor = std::make_shared(1); + auto io_executor = std::make_shared(1); + auto cpu_executor = std::make_shared(1); auto client = std::make_shared(io_executor, cpu_executor, nullptr, conf); return client; } std::shared_ptr CreateRpcClient(std::shared_ptr conf, std::chrono::nanoseconds connect_timeout) { - auto io_executor = std::make_shared(1); - auto cpu_executor = std::make_shared(1); + auto io_executor = std::make_shared(1); + auto cpu_executor = std::make_shared(1); auto client = std::make_shared(io_executor, cpu_executor, nullptr, conf, connect_timeout); return client; @@ -108,15 +108,16 @@ TEST_F(RpcTest, Ping) { std::make_shared(), method); /* sending out request */ + auto server_host_name = server_addr->getIPAddress().isNonroutable() ? "127.0.0.1" : server_addr->getAddressStr(); client - ->AsyncCall(server_addr->getAddressStr(), server_addr->getPort(), std::move(request), + ->AsyncCall(server_host_name, server_addr->getPort(), std::move(request), hbase::security::User::defaultUser()) - .then([&](std::unique_ptr response) { + .thenValue([&](std::unique_ptr response) { auto pb_resp = std::static_pointer_cast(response->resp_msg()); EXPECT_TRUE(pb_resp != nullptr); VLOG(1) << folly::sformat(FLAGS_result_format, method, ""); }) - .onError([&](const folly::exception_wrapper& ew) { + .thenError([&](const folly::exception_wrapper& ew) { FAIL() << folly::sformat(FLAGS_fail_no_ex_format, method); }) .get(); @@ -142,16 +143,17 @@ TEST_F(RpcTest, Echo) { pb_msg->set_message(greetings); /* sending out request */ + auto server_host_name = server_addr->getIPAddress().isNonroutable() ? "127.0.0.1" : server_addr->getAddressStr(); client - ->AsyncCall(server_addr->getAddressStr(), server_addr->getPort(), std::move(request), + ->AsyncCall(server_host_name, server_addr->getPort(), std::move(request), hbase::security::User::defaultUser()) - .then([&](std::unique_ptr response) { + .thenValue([&](std::unique_ptr response) { auto pb_resp = std::static_pointer_cast(response->resp_msg()); EXPECT_TRUE(pb_resp != nullptr); VLOG(1) << folly::sformat(FLAGS_result_format, method, pb_resp->message()); EXPECT_EQ(greetings, pb_resp->message()); }) - .onError([&](const folly::exception_wrapper& ew) { + .thenError([&](const folly::exception_wrapper& ew) { FAIL() << folly::sformat(FLAGS_fail_no_ex_format, method); }) .get(); @@ -173,13 +175,14 @@ TEST_F(RpcTest, Error) { auto request = std::make_unique(std::make_shared(), std::make_shared(), method); /* sending out request */ +auto server_host_name = server_addr->getIPAddress().isNonroutable() ? "127.0.0.1" : server_addr->getAddressStr(); client - ->AsyncCall(server_addr->getAddressStr(), server_addr->getPort(), std::move(request), + ->AsyncCall(server_host_name, server_addr->getPort(), std::move(request), hbase::security::User::defaultUser()) - .then([&](std::unique_ptr response) { + .thenValue([&](std::unique_ptr response) { FAIL() << folly::sformat(FLAGS_fail_ex_format, method); }) - .onError([&](const folly::exception_wrapper& ew) { + .thenError([&](const folly::exception_wrapper& ew) { VLOG(1) << folly::sformat(FLAGS_result_format, method, ew.what()); std::string kRemoteException = demangle(typeid(hbase::RemoteException)).toStdString(); std::string kRpcTestException = demangle(typeid(hbase::RpcTestException)).toStdString(); @@ -214,13 +217,14 @@ TEST_F(RpcTest, SocketNotOpen) { server->join(); /* sending out request */ + auto server_host_name = server_addr->getIPAddress().isNonroutable() ? "127.0.0.1" : server_addr->getAddressStr(); client - ->AsyncCall(server_addr->getAddressStr(), server_addr->getPort(), std::move(request), + ->AsyncCall(server_host_name, server_addr->getPort(), std::move(request), hbase::security::User::defaultUser()) - .then([&](std::unique_ptr response) { + .thenValue([&](std::unique_ptr response) { FAIL() << folly::sformat(FLAGS_fail_ex_format, method); }) - .onError([&](const folly::exception_wrapper& ew) { + .thenError([&](const folly::exception_wrapper& ew) { VLOG(1) << folly::sformat(FLAGS_result_format, method, ew.what()); std::string kConnectionException = demangle(typeid(hbase::ConnectionException)).toStdString(); @@ -265,15 +269,16 @@ TEST_F(RpcTest, Pause) { pb_msg->set_ms(ms); /* sending out request */ + auto server_host_name = server_addr->getIPAddress().isNonroutable() ? "127.0.0.1" : server_addr->getAddressStr(); client - ->AsyncCall(server_addr->getAddressStr(), server_addr->getPort(), std::move(request), + ->AsyncCall(server_host_name, server_addr->getPort(), std::move(request), hbase::security::User::defaultUser()) - .then([&](std::unique_ptr response) { + .thenValue([&](std::unique_ptr response) { auto pb_resp = std::static_pointer_cast(response->resp_msg()); EXPECT_TRUE(pb_resp != nullptr); VLOG(1) << folly::sformat(FLAGS_result_format, method, ""); }) - .onError([&](const folly::exception_wrapper& ew) { + .thenError([&](const folly::exception_wrapper& ew) { VLOG(1) << folly::sformat(FLAGS_result_format, method, ew.what()); FAIL() << folly::sformat(FLAGS_fail_no_ex_format, method); }) diff --git a/src/test/time-range-test.cc b/src/test/time-range-test.cc index 9267c8c..209476e 100644 --- a/src/test/time-range-test.cc +++ b/src/test/time-range-test.cc @@ -20,7 +20,8 @@ #include "hbase/client/time-range.h" #include "hbase/test-util/test-util.h" -#include +#include +#include using namespace hbase; diff --git a/src/test/user-util-test.cc b/src/test/user-util-test.cc index c132419..29a1544 100644 --- a/src/test/user-util-test.cc +++ b/src/test/user-util-test.cc @@ -17,7 +17,8 @@ * */ -#include +#include +#include #include #include "hbase/utils/user-util.h" diff --git a/src/test/zk-deserializer-test.cc b/src/test/zk-deserializer-test.cc index 81bc42d..4ad26fe 100644 --- a/src/test/zk-deserializer-test.cc +++ b/src/test/zk-deserializer-test.cc @@ -19,7 +19,7 @@ #include "hbase/serde/zk.h" -#include +#include #include #include