You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by el...@apache.org on 2017/10/13 22:43:51 UTC
[8/8] hbase git commit: HBASE-18901 [C++] Provide CMAKE infrastructure
HBASE-18901 [C++] Provide CMAKE infrastructure
* Provided cmake files for packages in which a default module
did not exist.
* Moved tests to a location where we could automatically build
the test suite.
* Resolved minor issues with tests
* Tested across OSX, RHEL7, and Ubuntu16
* Fix PROTOBUF_LIBRARY by removing static override in FindZookeeper
* Get the Dockerfile working again
Signed-off-by: Josh Elser <el...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/24f7f093
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/24f7f093
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/24f7f093
Branch: refs/heads/HBASE-14850
Commit: 24f7f093e1a9b7c40f737eadffd97c8be3382c02
Parents: e2bb10a
Author: Marc Parisi <ph...@apache.org>
Authored: Thu Sep 21 14:40:40 2017 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Fri Oct 13 18:43:19 2017 -0400
----------------------------------------------------------------------
hbase-native-client/.gitignore | 16 +
hbase-native-client/BUILDING.md | 28 +-
hbase-native-client/CMakeLists.txt | 194 +++++
hbase-native-client/Makefile | 176 -----
hbase-native-client/Makefile.protos | 80 ---
hbase-native-client/bin/cpplint.sh | 9 +-
hbase-native-client/cmake/BuildTests.cmake | 80 +++
hbase-native-client/cmake/FindFolly.cmake | 48 ++
hbase-native-client/cmake/FindGMock.cmake | 23 +
hbase-native-client/cmake/FindGflags.cmake | 23 +
hbase-native-client/cmake/FindGlog.cmake | 23 +
hbase-native-client/cmake/FindKrb5.cmake | 43 ++
hbase-native-client/cmake/FindSasl2.cmake | 29 +
hbase-native-client/cmake/FindWangle.cmake | 43 ++
hbase-native-client/cmake/FindZookeeper.cmake | 51 ++
hbase-native-client/cmake/ProtobufGen.cmake | 62 ++
hbase-native-client/docker-files/Dockerfile | 49 +-
hbase-native-client/include/hbase/client/BUCK | 93 ---
.../include/hbase/connection/BUCK | 57 --
.../include/hbase/exceptions/BUCK | 28 -
hbase-native-client/include/hbase/security/BUCK | 30 -
hbase-native-client/include/hbase/serde/BUCK | 37 -
.../include/hbase/test-util/mini-cluster.h | 82 +++
.../include/hbase/test-util/test-util.h | 78 +++
hbase-native-client/include/hbase/utils/BUCK | 40 --
hbase-native-client/src/hbase/client/BUCK | 301 --------
.../src/hbase/client/append-test.cc | 105 ---
.../client/async-batch-rpc-retrying-test.cc | 577 ---------------
.../src/hbase/client/async-rpc-retrying-test.cc | 420 -----------
.../src/hbase/client/cell-test.cc | 195 ------
.../src/hbase/client/client-test.cc | 698 ------------------
.../src/hbase/client/configuration-test.cc | 119 ----
.../src/hbase/client/delete-test.cc | 124 ----
.../src/hbase/client/filter-test.cc | 141 ----
.../src/hbase/client/get-test.cc | 221 ------
.../hbase/client/hbase-configuration-test.cc | 375 ----------
.../src/hbase/client/increment-test.cc | 129 ----
.../src/hbase/client/load-client.cc | 390 -----------
.../hbase/client/location-cache-retry-test.cc | 112 ---
.../src/hbase/client/location-cache-test.cc | 164 -----
.../src/hbase/client/put-test.cc | 135 ----
.../src/hbase/client/request-converter-test.cc | 126 ----
.../src/hbase/client/result-test.cc | 323 ---------
.../src/hbase/client/scan-result-cache-test.cc | 177 -----
.../src/hbase/client/scan-test.cc | 228 ------
.../src/hbase/client/scanner-test.cc | 368 ----------
.../src/hbase/client/simple-client.cc | 207 ------
.../src/hbase/client/time-range-test.cc | 48 --
.../src/hbase/client/zk-util-test.cc | 50 --
hbase-native-client/src/hbase/connection/BUCK | 68 --
.../hbase/connection/connection-pool-test.cc | 140 ----
.../src/hbase/connection/rpc-test.cc | 284 --------
.../src/hbase/examples/load-client.cc | 390 +++++++++++
.../src/hbase/examples/simple-client.cc | 207 ++++++
hbase-native-client/src/hbase/exceptions/BUCK | 37 -
.../src/hbase/exceptions/exception-test.cc | 64 --
hbase-native-client/src/hbase/if/BUCK | 49 --
hbase-native-client/src/hbase/security/BUCK | 27 -
hbase-native-client/src/hbase/serde/BUCK | 86 ---
.../src/hbase/serde/client-deserializer-test.cc | 64 --
.../src/hbase/serde/client-serializer-test.cc | 75 --
.../serde/region-info-deserializer-test.cc | 53 --
.../src/hbase/serde/server-name-test.cc | 47 --
.../src/hbase/serde/table-name-test.cc | 54 --
.../src/hbase/serde/zk-deserializer-test.cc | 123 ----
hbase-native-client/src/hbase/test-util/BUCK | 53 --
.../src/hbase/test-util/mini-cluster.cc | 3 +-
.../src/hbase/test-util/mini-cluster.h | 81 ---
.../src/hbase/test-util/test-util.h | 78 ---
hbase-native-client/src/hbase/utils/BUCK | 57 --
.../src/hbase/utils/bytes-util-test.cc | 69 --
.../src/hbase/utils/bytes-util.cc | 1 -
.../src/hbase/utils/concurrent-map-test.cc | 36 -
.../src/hbase/utils/user-util-test.cc | 35 -
hbase-native-client/src/test/append-test.cc | 105 +++
.../src/test/async-batch-rpc-retrying-test.cc | 577 +++++++++++++++
.../src/test/async-rpc-retrying-test.cc | 419 +++++++++++
hbase-native-client/src/test/bytes-util-test.cc | 69 ++
hbase-native-client/src/test/cell-test.cc | 195 ++++++
.../src/test/client-deserializer-test.cc | 64 ++
.../src/test/client-serializer-test.cc | 75 ++
hbase-native-client/src/test/client-test.cc | 699 +++++++++++++++++++
.../src/test/concurrent-map-test.cc | 36 +
.../src/test/configuration-test.cc | 119 ++++
.../src/test/connection-pool-test.cc | 140 ++++
hbase-native-client/src/test/delete-test.cc | 124 ++++
hbase-native-client/src/test/exception-test.cc | 64 ++
hbase-native-client/src/test/filter-test.cc | 141 ++++
hbase-native-client/src/test/get-test.cc | 221 ++++++
.../src/test/hbase-configuration-test.cc | 375 ++++++++++
hbase-native-client/src/test/increment-test.cc | 129 ++++
.../src/test/location-cache-retry-test.cc | 112 +++
.../src/test/location-cache-test.cc | 164 +++++
hbase-native-client/src/test/put-test.cc | 135 ++++
.../src/test/region-info-deserializer-test.cc | 53 ++
.../src/test/request-converter-test.cc | 126 ++++
hbase-native-client/src/test/result-test.cc | 323 +++++++++
hbase-native-client/src/test/rpc-test.cc | 284 ++++++++
.../src/test/scan-result-cache-test.cc | 177 +++++
hbase-native-client/src/test/scan-test.cc | 228 ++++++
hbase-native-client/src/test/scanner-test.cc | 368 ++++++++++
.../src/test/server-name-test.cc | 47 ++
hbase-native-client/src/test/table-name-test.cc | 54 ++
hbase-native-client/src/test/time-range-test.cc | 48 ++
hbase-native-client/src/test/user-util-test.cc | 35 +
.../src/test/zk-deserializer-test.cc | 123 ++++
hbase-native-client/src/test/zk-util-test.cc | 50 ++
hbase-native-client/third-party/BUCK | 118 ----
108 files changed, 7309 insertions(+), 8024 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/.gitignore
----------------------------------------------------------------------
diff --git a/hbase-native-client/.gitignore b/hbase-native-client/.gitignore
index e8dd42d..5f3e387 100644
--- a/hbase-native-client/.gitignore
+++ b/hbase-native-client/.gitignore
@@ -27,3 +27,19 @@ third-party/*
# Generated files
src/hbase/utils/version.h
+
+# Tests
+*-test
+
+# Executables
+load-client
+simple-client
+
+# CMake temporary files
+CMakeCache.txt
+CMakeFiles
+*.cmake
+Makefile
+
+# Copied from hbase-common at build-time
+include/hbase/utils/version.h
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/BUILDING.md
----------------------------------------------------------------------
diff --git a/hbase-native-client/BUILDING.md b/hbase-native-client/BUILDING.md
index 4c06776..53eb6d9 100644
--- a/hbase-native-client/BUILDING.md
+++ b/hbase-native-client/BUILDING.md
@@ -47,31 +47,11 @@ Then go into the hbase-native-client directory and run `./bin/start-docker.sh`
that will build the docker development environment and when complete will
drop you into a shell on a linux vm with all the tools needed installed.
-# Buck
-From then on we can use [buck](https://buckbuild.com/) to build everything.
-For example:
-```
-buck build //core:core
-buck test --all
-buck build //core:simple-client
-```
-
-That will build the library, then build and test everything, then build
-the simple-client binary. Buck will find all modules used, and compile
-them in parallel, caching the results. Output from buck is in the buck-out
-foulder. Generated binaries are in buck-out/gen logs are in buck-out/logs
-
-
-# Make
-
-If learning buck isn't your thing there is a Makefile wrapper for your
-convenience.
+# CMake
```
-make help
-make check
-make clean
-make all
-make build
+cmake .
+make
+make install
```
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/hbase-native-client/CMakeLists.txt b/hbase-native-client/CMakeLists.txt
new file mode 100644
index 0000000..3afe4d7
--- /dev/null
+++ b/hbase-native-client/CMakeLists.txt
@@ -0,0 +1,194 @@
+# 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.
+#
+cmake_minimum_required(VERSION 3.0)
+PROJECT(hbaseclient CXX)
+set(PROJECT_NAME "hbaseclient")
+set(PROJECT_VERSION_MAJOR 0)
+set(PROJECT_VERSION_MINOR 1 )
+set(PROJECT_VERSION_PATCH 0)
+set(BUILD_SHARED_LIBS ON)
+## set our cmake module path
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+## include the Protobuf generation code
+include(ProtobufGen)
+if(COMPILER_SUPPORTS_CXX14)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+else()
+ message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
+endif()
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+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")
+# Set the right openssl root path
+if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl/")
+else()
+ set(OPENSSL_ROOT_DIR "/usr/lib/x86_64-linux-gnu")
+endif()
+# Include OpenSSL
+find_package (OpenSSL REQUIRED)
+if (OPENSSL_FOUND)
+ include_directories(${OPENSSL_INCLUDE_DIR})
+else ()
+ message( FATAL_ERROR "OpenSSL was not found. Please install OpenSSL" )
+endif (OPENSSL_FOUND)
+# ensure we have required dependencies
+find_package(Threads)
+find_package(Boost REQUIRED COMPONENTS thread system filesystem)
+find_package(Gflags REQUIRED)
+find_package(Folly REQUIRED)
+find_package(Krb5 REQUIRED)
+find_package(Sasl2 REQUIRED)
+find_package(Wangle REQUIRED)
+find_package(GTest)
+find_package(Glog)
+find_package(Java REQUIRED)
+find_package(JNI REQUIRED)
+find_package(Zookeeper REQUIRED)
+find_package(Protobuf REQUIRED)
+if (NOT FOLLY_FOUND)
+ message(FATAL_ERROR "-- Folly not found")
+endif()
+if (NOT WANGLE_FOUND)
+ message(FATAL_ERROR "-- Wangle not found")
+endif()
+if (NOT PROTOBUF_FOUND)
+ message(FATAL_ERROR "-- Protocol buffer include directory not found ${PROTOBUF_INCLUDE_DIRS}")
+endif()
+if (NOT JNI_FOUND)
+ message(FATAL_ERROR "-- JAVA include directory not found")
+endif()
+### provide the include directories, starting at the base
+### and including those from our
+include_directories(include)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+include_directories(${Zookeeper_INCLUDE_DIRS})
+include_directories(${Boost_INCLUDE_DIR})
+include_directories(${KRB5_INCLUDE_DIRS})
+include_directories(${JAVA_INCLUDE_DIRS})
+include_directories(${FOLLY_INCLUDE_DIRS})
+### 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.
+set(CMAKE_BINARY_DIR_GEN "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/hbase/if/")
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR_GEN})
+## build a recursive list of sources
+file(GLOB_RECURSE CONNECTION_SRC "${HBASE_SRC_DIR}/connection/*.cc" )
+file(GLOB_RECURSE EXCEPTION_SRC "${HBASE_SRC_DIR}/exceptions/*.cc" )
+file(GLOB_RECURSE PROTO_SRC "${HBASE_SRC_DIR}/if/*.cc" )
+file(GLOB_RECURSE UTILS_SRC "${HBASE_SRC_DIR}/utils/*.cc" )
+file(GLOB_RECURSE CLIENT_SRC "${HBASE_SRC_DIR}/client/*.cc" )
+file(GLOB_RECURSE SECURITY_SRC "${HBASE_SRC_DIR}/security/*.cc" )
+file(GLOB_RECURSE SRDE_SRC "${HBASE_SRC_DIR}/serde/*.cc" )
+file(GLOB_RECURSE TEST_UTIL "${HBASE_SRC_DIR}/test-util/*.cc" )
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY})
+include_directories(${SASL_INCLUDE_DIRS})
+include_directories(${GFLAGS_INCLUDE_DIR})
+file(GLOB_RECURSE PROTO_FILES "${HBASE_SRC_DIR}/if/*.proto" )
+### generate the protocol buffers.
+generate_protobuf_src(PROTO_SOURCES PROTO_HEADERS ${PROTO_FILES})
+
+add_library(hbaseclient-static STATIC ${PROTO_SOURCES} ${CLIENT_SRC} ${CONNECTION_SRC} ${EXCEPTION_SRC} ${PROTO_SRC} ${SECURITY_SRC} ${SRDE_SRC} ${UTILS_SRC})
+set_target_properties(hbaseclient-static PROPERTIES LINKER_LANGUAGE CXX)
+SET_TARGET_PROPERTIES(hbaseclient-static PROPERTIES OUTPUT_NAME hbaseclient CLEAN_DIRECT_OUTPUT 1)
+target_link_libraries(hbaseclient-static ${PROTOBUF_LIBRARY})
+target_link_libraries(hbaseclient-static ${FOLLY_LIBRARIES})
+target_link_libraries(hbaseclient-static ${Boost_LIBRARIES})
+target_link_libraries(hbaseclient-static ${SASL_LIBS})
+target_link_libraries(hbaseclient-static ${GLOG_SHARED_LIB})
+target_link_libraries(hbaseclient-static ${GFLAGS_SHARED_LIB})
+target_link_libraries(hbaseclient-static ${KRB5_LIBRARIES})
+target_link_libraries(hbaseclient-static ${WANGLE_LIBRARIES})
+target_link_libraries(hbaseclient-static ${Zookeeper_LIBRARIES})
+target_link_libraries(hbaseclient-static ${OPENSSL_LIBRARIES})
+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)
+target_link_libraries(hbaseclient-shared ${PROTOBUF_LIBRARY})
+target_link_libraries(hbaseclient-shared ${FOLLY_LIBRARIES})
+target_link_libraries(hbaseclient-shared ${Boost_LIBRARIES})
+target_link_libraries(hbaseclient-shared ${SASL_LIBS})
+target_link_libraries(hbaseclient-shared ${GLOG_SHARED_LIB})
+target_link_libraries(hbaseclient-shared ${GFLAGS_SHARED_LIB})
+target_link_libraries(hbaseclient-shared ${KRB5_LIBRARIES})
+target_link_libraries(hbaseclient-shared ${WANGLE_LIBRARIES})
+target_link_libraries(hbaseclient-shared ${Zookeeper_LIBRARIES})
+add_executable(simple-client "${HBASE_SRC_DIR}/examples/simple-client.cc")
+SET_TARGET_PROPERTIES(simple-client PROPERTIES COMPILE_FLAGS " ")
+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})
+add_executable(load-client "${HBASE_SRC_DIR}/examples/load-client.cc")
+SET_TARGET_PROPERTIES(load-client PROPERTIES COMPILE_FLAGS " ")
+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})
+if (JNI_FOUND)
+ message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
+ message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
+endif()
+if (NOT SKIP_TESTS)
+ include(BuildTests)
+endif()
+## Create a custom target for our linter
+add_custom_target(
+ linter
+ COMMAND ${CMAKE_SOURCE_DIR}/bin/cpplint.sh)
+# Copy the version.h file in before doing anything
+add_custom_target (
+ copy_version_h
+ COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/bin/copy-version.sh"
+)
+add_dependencies(hbaseclient-static copy_version_h)
+add_dependencies(hbaseclient-shared copy_version_h)
+
+# Install library headers
+include(GNUInstallDirs)
+file(GLOB RECURSE HEADERS include/*.h)
+set_target_properties(hbaseclient-static PROPERTIES PUBLIC_HEADER "${HEADERS}")
+install(TARGETS hbaseclient-static
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION include/
+ COMPONENT LIBRARY )
+install(TARGETS hbaseclient-shared
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION include/
+ COMPONENT LIBRARY )
+INSTALL (
+ DIRECTORY ${CMAKE_SOURCE_DIR}/include/
+ DESTINATION include/
+ FILES_MATCHING PATTERN "*.h*")
+# Install pb-generated headers too
+INSTALL (
+ DIRECTORY "${CMAKE_BINARY_DIR_GEN}"
+ DESTINATION include/hbase/if
+ FILES_MATCHING PATTERN "hbase/if/*.h")
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/Makefile
----------------------------------------------------------------------
diff --git a/hbase-native-client/Makefile b/hbase-native-client/Makefile
deleted file mode 100644
index cd818ca..0000000
--- a/hbase-native-client/Makefile
+++ /dev/null
@@ -1,176 +0,0 @@
-# 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.
-
-#use "g++" to compile source files
-CC := g++
-LD := g++
-
-SRC_HBASE := src/hbase
-INCLUDE_HBASE := include/
-BUILD_PATH := build
-DEBUG_PATH := $(BUILD_PATH)/debug
-RELEASE_PATH := $(BUILD_PATH)/release
-PROTO_SRC_DIR := $(SRC_HBASE)/if
-PROTO_CXX_DIR := $(BUILD_PATH)/$(PROTO_SRC_DIR)
-MODULES := connection client exceptions security serde utils
-TEST_MODULES := test-util # These modules contain test code, not included in the build for the lib
-SRC_DIR := $(addprefix $(SRC_HBASE)/,$(MODULES))
-DEBUG_BUILD_DIR := $(addprefix $(DEBUG_PATH)/hbase/,$(MODULES))
-RELEASE_BUILD_DIR := $(addprefix $(RELEASE_PATH)/hbase/,$(MODULES))
-
-INCLUDE_DIR := . src $(BUILD_PATH)/src $(INCLUDE_HBASE)
-TEST_BUILD_INCLUDE_DIR := $(INLCUDE_DIR) $(JAVA_HOME)/include/ $(JAVA_HOME)/include/linux
-
-#flags to pass to the CPP compiler & linker
-CPPFLAGS_DEBUG := -D_GLIBCXX_USE_CXX11_ABI=0 -g -Wall -std=c++14 -pedantic -fPIC -MMD -MP
-CPPFLAGS_RELEASE := -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -O2 -Wall -std=c++14 -pedantic -fPIC -MMD -MP
-LDFLAGS := -lprotobuf -lzookeeper_mt -lsasl2 -lfolly -lwangle
-TEST_BUILD_LDFLAGS := $(LDFLAGS) -L $(JAVA_HOME)/jre/lib/amd64/server -ljvm
-LINKFLAG := -shared
-
-#define list of source files and object files
-ALLSRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cc))
-EXCLUDE_SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*-test.cc)) \
- $(SRC_HBASE)/client/simple-client.cc $(SRC_HBASE)/client/load-client.cc
-SRC := $(filter-out $(EXCLUDE_SRC), $(ALLSRC))
-PROTOSRC := $(patsubst $(PROTO_SRC_DIR)/%.proto, $(addprefix $(PROTO_CXX_DIR)/,%.pb.cc),$(wildcard $(PROTO_SRC_DIR)/*.proto))
-PROTOHDR := $(patsubst $(PROTO_SRC_DIR)/%.proto, $(addprefix $(PROTO_CXX_DIR)/,%.pb.h),$(wildcard $(PROTO_SRC_DIR)/*.proto))
-DEBUG_OBJ := $(patsubst $(SRC_HBASE)/%.cc,$(DEBUG_PATH)/hbase/%.o,$(SRC))
-DEBUG_OBJ += $(patsubst $(PROTO_CXX_DIR)/%.cc,$(DEBUG_PATH)/hbase/if/%.o,$(PROTOSRC))
-RELEASE_OBJ := $(patsubst $(SRC_HBASE)/%.cc,$(RELEASE_PATH)/hbase/%.o,$(SRC))
-RELEASE_OBJ += $(patsubst $(PROTO_CXX_DIR)/%.cc,$(RELEASE_PATH)/hbase/if/%.o,$(PROTOSRC))
-INCLUDES := $(addprefix -I,$(INCLUDE_DIR))
-
-LIB_DIR := /usr/local
-LIB_LIBDIR := $(LIB_DIR)/lib
-LIB_INCDIR := $(LIB_DIR)/include
-LIB_RELEASE := $(RELEASE_PATH)/libHBaseClient.so
-ARC_RELEASE := $(RELEASE_PATH)/libHBaseClient.a
-LIB_DEBUG := $(DEBUG_PATH)/libHBaseClient_d.so
-ARC_DEBUG := $(DEBUG_PATH)/libHBaseClient_d.a
-LOCAL_INCLUDE_DIR := /usr/local/include/
-
-build: checkdirs protos copyfiles $(LIB_DEBUG) $(LIB_RELEASE) $(ARC_DEBUG) $(ARC_RELEASE)
-
-vpath %.cc $(SRC_DIR)
-
-$(LIB_DEBUG):
-define make-goal-dbg
-DEPS := $(DEBUG_OBJ:.o=.d)
--include $(DEPS)
-$1/%.o: %.cc
- $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_DEBUG) $(INCLUDES)
-endef
-
-$(LIB_RELEASE):
-define make-goal-rel
-DEPS := $(RELEASE_OBJ:.o=.d)
--include $(DEPS)
-$1/%.o: %.cc
- $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_RELEASE) $(INCLUDES)
-endef
-
-.PHONY: all clean install copyfiles
-
-checkdirs: $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) $(PROTO_CXX_DIR)
-
-copyfiles:
- @bin/copy-protobuf.sh
- @bin/copy-version.sh
-
-# .proto files are in src/hbase/if. These are compiled into C++ code by the
-# protoc compiler, and turned into .cc and .h files under build/src/hbase/if
-$(PROTO_CXX_DIR)/%.pb.cc $(PROTO_CXX_DIR)/%.pb.h: $(PROTO_SRC_DIR)/%.proto
- @protoc --proto_path=$(PROTO_SRC_DIR) --cpp_out=$(PROTO_CXX_DIR) $<
-
-# protos target compiles the .cc and .h files into .o files for the protobuf
-# generated source files
-protos: $(PROTO_CXX_DIR) $(PROTOSRC) $(PROTOHDR)
- @make -j8 all -f Makefile.protos
-
-install_headers:
- cp -r $(INCLUDE_HBASE)/hbase $(LOCAL_INCLUDE_DIR)
- mkdir -p $(LOCAL_INCLUDE_DIR)/hbase/if
- cp -r $(PROTO_CXX_DIR)/*.h $(LOCAL_INCLUDE_DIR)/hbase/if
-
-uninstall_headers:
- rm -rf $(LOCAL_INCLUDE_DIR)/hbase
-
-install: install_headers
- cp $(LIB_RELEASE) $(LIB_LIBDIR)/libHBaseClient.so
- cp $(ARC_RELEASE) $(LIB_LIBDIR)/libHBaseClient.a
- cp $(LIB_DEBUG) $(LIB_LIBDIR)/libHBaseClient_d.so
- cp $(ARC_DEBUG) $(LIB_LIBDIR)/libHBaseClient_d.a
- ldconfig
-
-uninstall: uninstall_headers
- rm -f $(LIB_LIBDIR)/libHBaseClient.so $(LIB_LIBDIR)/libHBaseClient.a $(LIB_LIBDIR)/libHBaseClient_d.so $(LIB_LIBDIR)/libHBaseClient_d.a
- ldconfig
-
-$(PROTO_CXX_DIR):
- @mkdir -p $@
-
-$(DEBUG_BUILD_DIR):
- @mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- @mkdir -p $@
-
-$(ARC_DEBUG): $(DEBUG_OBJ)
- ar rcs $@ $^
-
-$(ARC_RELEASE): $(RELEASE_OBJ)
- ar rcs $@ $^
-
-$(LIB_RELEASE): $(RELEASE_OBJ)
- $(LD) $(LINKFLAG) -o $@ $(LDFLAGS) $(RELEASE_OBJ)
-
-$(LIB_DEBUG): $(DEBUG_OBJ)
- $(LD) $(LINKFLAG) -o $@ $(LDFLAGS) $(DEBUG_OBJ)
-
-clean:
- @rm -rf docs buck-out $(BUILD_PATH)
-
-$(foreach bdir,$(DEBUG_BUILD_DIR), $(eval $(call make-goal-dbg,$(bdir))))
-
-$(foreach bdir,$(RELEASE_BUILD_DIR),$(eval $(call make-goal-rel,$(bdir))))
-
-check:
- $(shell buck test --all --no-results-cache)
-
-lint:
- bin/cpplint.sh
-
-doc:
- $(shell doxygen hbase.doxygen > /dev/null)
-
-help:
- @echo "Available targets:"
- @echo ""
- @echo " all : builds everything, creates doc and runs tests."
- @echo " build : will build/rebuild everything."
- @echo " check : will test everything."
- @echo " clean : removes docs folder, object files and local libraries from build/ directory."
- @echo " copyfiles : copies native version.h from mvn build and proto locally to hbase-native-client."
- @echo " doc : generates documentation."
- @echo " install : will copy the libs to $(LIB_LIBDIR). super user priviliege would be required."
- @echo " protos : will create PB CPP sec and headers from if/*.proto and build them."
- @echo " uninstall : removes the libs from $(LIB_LIBDIR)."
- @echo " lint : will ensure that code conforms to Google coding style."
- @echo "If no target is specified 'build' will be executed"
-
-all: copyfiles build doc check
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/Makefile.protos
----------------------------------------------------------------------
diff --git a/hbase-native-client/Makefile.protos b/hbase-native-client/Makefile.protos
deleted file mode 100644
index 8712029..0000000
--- a/hbase-native-client/Makefile.protos
+++ /dev/null
@@ -1,80 +0,0 @@
-# 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.
-
-#use "g++" to compile source files
-CC := g++
-
-BUILD_PATH := build
-DEBUG_PATH := $(BUILD_PATH)/debug
-RELEASE_PATH := $(BUILD_PATH)/release
-MODULES := if
-SRC_DIR := $(BUILD_PATH)/src/hbase/$(MODULES)
-DEBUG_BUILD_DIR := $(addprefix $(DEBUG_PATH)/hbase/,$(MODULES))
-RELEASE_BUILD_DIR := $(addprefix $(RELEASE_PATH)/hbase/,$(MODULES))
-INCLUDE_DIR := . $(BUILD_PATH)/src/hbase/if
-
-#flags to pass to the CPP compiler & linker
-CPPFLAGS_DEBUG := -D_GLIBCXX_USE_CXX11_ABI=0 -g -Wall -std=c++14 -pedantic -fPIC -MMD -MP
-CPPFLAGS_RELEASE := -D_GLIBCXX_USE_CXX11_ABI=0 -DNDEBUG -O2 -Wall -std=c++14 -pedantic -fPIC -MMD -MP
-
-#define list of source files and object files
-SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cc))
-DEBUG_OBJ := $(patsubst $(SRC_DIR)/%.cc,$(DEBUG_PATH)/hbase/if/%.o,$(SRC))
-RELEASE_OBJ := $(patsubst $(SRC_DIR)/%.cc,$(RELEASE_PATH)/hbase/if/%.o,$(SRC))
-INCLUDES := $(addprefix -I,$(INCLUDE_DIR))
-
-all: $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR) $(DEBUG_OBJ) $(RELEASE_OBJ)
-
-vpath %.cc $(SRC_DIR)
-
-$(DEBUG_OBJ):
-define make-goal-dbg
-DEPS := $(DEBUG_OBJ:.o=.d)
--include $(DEPS)
-$1/%.o: %.cc
- $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_DEBUG) $(INCLUDES)
-endef
-
-$(RELEASE_OBJ):
-define make-goal-rel
-DEPS := $(RELEASE_OBJ:.o=.d)
--include $(DEPS)
-$1/%.o: %.cc
- $(CC) -c $$< -o $$@ -MF$$(@:%.o=%.d) -MT$$@ $(CPPFLAGS_RELEASE) $(INCLUDES)
-endef
-
-.PHONY: all clean
-
-$(DEBUG_BUILD_DIR):
- @mkdir -p $@
-
-$(RELEASE_BUILD_DIR):
- @mkdir -p $@
-
-clean:
- @rm -rf $(DEBUG_BUILD_DIR) $(RELEASE_BUILD_DIR)
-
-$(foreach bdir,$(DEBUG_BUILD_DIR),$(eval $(call make-goal-dbg,$(bdir))))
-
-$(foreach bdir,$(RELEASE_BUILD_DIR),$(eval $(call make-goal-rel,$(bdir))))
-
-help:
- @echo "This Makefile invocation will only work when protobuf sources and headers have been generated by running 'make protos'"
- @echo "Available targets:"
- @echo ""
- @echo " all : creates objects for the generated PB src."
- @echo " clean : removes PB objects."
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/bin/cpplint.sh
----------------------------------------------------------------------
diff --git a/hbase-native-client/bin/cpplint.sh b/hbase-native-client/bin/cpplint.sh
index 7a27945..497ab24 100755
--- a/hbase-native-client/bin/cpplint.sh
+++ b/hbase-native-client/bin/cpplint.sh
@@ -16,9 +16,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
IFS=$'\n\t'
-
+OUTPUT_DIR=$1
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CPPLINT_LOC=https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py
-OUTPUT=build/cpplint.py
+OUTPUT=$OUTPUT_DIR/cpplint.py
declare -a MODULES=( client connection exceptions security serde utils test-util )
@@ -31,9 +32,9 @@ wget -nc $CPPLINT_LOC -O $OUTPUT
# build/c++11 (We are building with c++14)
for m in ${MODULES[@]}; do
if [ $m != "security" ]; then #These are empty
- exec find src/hbase/$m -name "*.h" -or -name "*.cc" | xargs -P8 python $OUTPUT --filter=-build/header_guard,-readability/todo,-build/c++11 --linelength=100
+ exec find ${SCRIPT_DIR}/../src/hbase/$m -name "*.h" -or -name "*.cc" | xargs -P8 python $OUTPUT --filter=-build/header_guard,-readability/todo,-build/c++11 --linelength=100
fi
if [ $m != "test-util" ]; then
- exec find include/hbase/$m -name "*.h" -or -name "*.cc" | xargs -P8 python $OUTPUT --filter=-build/header_guard,-readability/todo,-build/c++11 --linelength=100
+ exec find ${SCRIPT_DIR}/../include/hbase/$m -name "*.h" -or -name "*.cc" | xargs -P8 python $OUTPUT --filter=-build/header_guard,-readability/todo,-build/c++11 --linelength=100
fi
done
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/BuildTests.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/BuildTests.cmake b/hbase-native-client/cmake/BuildTests.cmake
new file mode 100644
index 0000000..7ab2102
--- /dev/null
+++ b/hbase-native-client/cmake/BuildTests.cmake
@@ -0,0 +1,80 @@
+# 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.
+### test functions
+MACRO(GETSOURCEFILES result curdir)
+ FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
+ SET(dirlist "")
+ FOREACH(child ${children})
+ IF( "${child}" MATCHES ^[^.].*\\.cc)
+
+ LIST(APPEND dirlist ${child})
+ ENDIF()
+ ENDFOREACH()
+ SET(${result} ${dirlist})
+ENDMACRO()
+find_package(GMock REQUIRED)
+add_library(testutil STATIC ${TEST_UTIL})
+target_include_directories(testutil PRIVATE BEFORE "include")
+target_include_directories(testutil PRIVATE BEFORE "${Java_INCLUDE_DIRS}")
+target_include_directories(testutil PRIVATE BEFORE "${JNI_INCLUDE_DIRS}")
+target_include_directories(testutil PRIVATE BEFORE "${Boost_INCLUDE_DIR}")
+target_include_directories(testutil PRIVATE BEFORE "${GTEST_INCLUDE_DIRS}")
+target_include_directories(testutil PRIVATE BEFORE${PROTOBUF_INCLUDE_DIRS})
+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})
+function(createTests testName)
+ message ("-- 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(hbaseclient-static ${PROTOBUF_LIBRARY})
+ target_link_libraries(hbaseclient-static ${FOLLY_LIBRARIES})
+
+ target_link_libraries(${testName} hbaseclient-static testutil ${CMAKE_THREAD_LIBS_INIT}
+ ${Java_LIBRARIES}
+ ${JNI_LIBRARIES}
+ ${PROTOBUF_LIBRARY}
+ ${Boost_LIBRARIES}
+ ${GFLAGS_SHARED_LIB}
+ ${GTEST_BOTH_LIBRARIES}
+ ${SASL_LIBS}
+ ${GFLAGS_SHARED_LIB}
+ ${KRB5_LIBRARIES}
+ ${Zookeeper_LIBRARIES} ${OPENSSL_LIBRARIES}
+ ${WANGLE_LIBRARIES}
+ ${FOLLY_LIBRARIES}
+ ${GLOG_SHARED_LIB})
+endfunction()
+enable_testing(test)
+SET(TEST_DIR ${CMAKE_SOURCE_DIR}/src/test)
+GETSOURCEFILES(UNIT_TESTS "${TEST_DIR}")
+SET(UNIT_TEST_COUNT 0)
+FOREACH(testfile ${UNIT_TESTS})
+ get_filename_component(testfilename "${testfile}" NAME_WE)
+ add_executable("${testfilename}" "${TEST_DIR}/${testfile}")
+ createTests("${testfilename}")
+ MATH(EXPR UNIT_TEST_COUNT "${UNIT_TEST_COUNT}+1")
+ add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR})
+ENDFOREACH()
+message("-- Finished building ${UNIT_TEST_COUNT} unit test file(s)...")
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindFolly.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindFolly.cmake b/hbase-native-client/cmake/FindFolly.cmake
new file mode 100644
index 0000000..e7854a0
--- /dev/null
+++ b/hbase-native-client/cmake/FindFolly.cmake
@@ -0,0 +1,48 @@
+# 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.
+#
+find_path(FOLLY_ROOT_DIR
+ NAMES include/folly/AtomicHashMap.h
+)
+find_library(FOLLY_LIBRARIES
+ NAMES folly
+ HINTS ${FOLLY_ROOT_DIR}/lib /usr/lib/ /usr/local/lib/ /usr/lib/x86_64-linux-gnu/
+)
+find_library(FOLLY_BENCHMARK_LIBRARIES
+ NAMES follybenchmark
+ HINTS ${FOLLY_ROOT_DIR}/lib
+)
+find_path(FOLLY_INCLUDE_DIR
+ NAMES folly/AtomicHashMap.h
+ HINTS ${FOLLY_ROOT_DIR}/include
+)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Folly DEFAULT_MSG
+ FOLLY_LIBRARIES
+ FOLLY_INCLUDE_DIR
+)
+mark_as_advanced(
+ FOLLY_ROOT_DIR
+ FOLLY_LIBRARIES
+ FOLLY_BENCHMARK_LIBRARIES
+ FOLLY_INCLUDE_DIR
+)
+if (FOLLY_LIBRARIES)
+ set(FOLLY_FOUND "true")
+ message("-- Folly found, ${FOLLY_LIBRARIES}")
+endif(FOLLY_LIBRARIES)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindGMock.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindGMock.cmake b/hbase-native-client/cmake/FindGMock.cmake
new file mode 100644
index 0000000..998fa6d
--- /dev/null
+++ b/hbase-native-client/cmake/FindGMock.cmake
@@ -0,0 +1,23 @@
+# 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.
+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h)
+ # make sure we don't accidentally pick up a different version
+find_library(GMOCK_SHARED_LIB gmock)
+find_library(GMOCK_STATIC_LIB libgmock.a)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GMOCK REQUIRED_VARS
+ GMOCK_SHARED_LIB GMOCK_STATIC_LIB GMOCK_INCLUDE_DIR)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindGflags.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindGflags.cmake b/hbase-native-client/cmake/FindGflags.cmake
new file mode 100644
index 0000000..59c65df
--- /dev/null
+++ b/hbase-native-client/cmake/FindGflags.cmake
@@ -0,0 +1,23 @@
+# 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.
+find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h)
+ # make sure we don't accidentally pick up a different version
+find_library(GFLAGS_SHARED_LIB gflags)
+find_library(GFLAGS_STATIC_LIB libgflags.a)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GFLAGS REQUIRED_VARS
+ GFLAGS_SHARED_LIB GFLAGS_STATIC_LIB GFLAGS_INCLUDE_DIR)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindGlog.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindGlog.cmake b/hbase-native-client/cmake/FindGlog.cmake
new file mode 100644
index 0000000..a2c541d
--- /dev/null
+++ b/hbase-native-client/cmake/FindGlog.cmake
@@ -0,0 +1,23 @@
+# 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.
+find_path(GLOG_INCLUDE_DIR glog/logging.h)
+ # make sure we don't accidentally pick up a different version
+find_library(GLOG_SHARED_LIB glog)
+find_library(GLOG_STATIC_LIB libglog.a)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLOG REQUIRED_VARS
+ GLOG_SHARED_LIB GLOG_STATIC_LIB GLOG_INCLUDE_DIR)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindKrb5.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindKrb5.cmake b/hbase-native-client/cmake/FindKrb5.cmake
new file mode 100644
index 0000000..e4c6fb8
--- /dev/null
+++ b/hbase-native-client/cmake/FindKrb5.cmake
@@ -0,0 +1,43 @@
+# 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.
+#
+find_path(KRB5_ROOT_DIR
+ NAMES include/krb5/krb5.h
+)
+find_library(KRB5_LIBRARIES
+ NAMES krb5
+ HINTS ${KRB5_ROOT_DIR}/lib
+)
+find_path(KRB5_INCLUDE_DIR
+ NAMES krb5/krb5.h
+ HINTS ${KRB5_ROOT_DIR}/include
+)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(krb5 DEFAULT_MSG
+ KRB5_LIBRARIES
+ KRB5_INCLUDE_DIR
+)
+if (KRB5_LIBRARIES)
+ set(KRB5_FOUND "true")
+ message("-- KRB5 Libs Found, ${KRB5_LIBRARIES}")
+endif()
+mark_as_advanced(
+ KRB5_ROOT_DIR
+ KRB5_LIBRARIES
+ KRB5_INCLUDE_DIR
+)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindSasl2.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindSasl2.cmake b/hbase-native-client/cmake/FindSasl2.cmake
new file mode 100644
index 0000000..871385b
--- /dev/null
+++ b/hbase-native-client/cmake/FindSasl2.cmake
@@ -0,0 +1,29 @@
+# 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.
+#
+include(CheckSymbolExists)
+find_path (
+ SASL_INCLUDE_DIRS NAMES sasl/sasl.h
+ PATHS /include /usr/include /usr/local/include /usr/share/include)
+find_library(
+ SASL_LIBS NAMES sasl2
+ PATHS /usr/lib /lib /usr/local/lib /usr/lib/x86_64-linux-gnu/)
+if (SASL_INCLUDE_DIRS AND SASL_LIBS)
+ set (SASL_FOUND 1)
+ message("-- LibSASL found, ${SASL_LIBS}")
+endif ()
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindWangle.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindWangle.cmake b/hbase-native-client/cmake/FindWangle.cmake
new file mode 100644
index 0000000..6e69faa
--- /dev/null
+++ b/hbase-native-client/cmake/FindWangle.cmake
@@ -0,0 +1,43 @@
+# 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.
+#
+find_path(WANGLE_ROOT_DIR
+ NAMES include/wangle/acceptor/Acceptor.h
+)
+find_library(WANGLE_LIBRARIES
+ NAMES wangle
+ HINTS ${WANGLE_ROOT_DIR}/lib /usr/lib/ /usr/local/lib/
+)
+find_path(WANGLE_INCLUDE_DIR
+ NAMES wangle/acceptor/Acceptor.h
+ HINTS ${WANGLE_ROOT_DIR}/include /usr/local/include/
+)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WANGLE DEFAULT_MSG
+ WANGLE_LIBRARIES
+ WANGLE_INCLUDE_DIR
+)
+mark_as_advanced(
+ WANGLE_ROOT_DIR
+ WANGLE_LIBRARIES
+ WANGLE_INCLUDE_DIR
+)
+if (WANGLE_LIBRARIES)
+ set(WANGLE_FOUND "true")
+ message("-- Wangle found, ${WANGLE_LIBRARIES}")
+endif(WANGLE_LIBRARIES)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/FindZookeeper.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/FindZookeeper.cmake b/hbase-native-client/cmake/FindZookeeper.cmake
new file mode 100644
index 0000000..a9e9d3d
--- /dev/null
+++ b/hbase-native-client/cmake/FindZookeeper.cmake
@@ -0,0 +1,51 @@
+# 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.
+#
+if (MSVC)
+ if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
+ set(ZK_BuildOutputDir "Debug")
+ else()
+ set(ZK_BuildOutputDir "Release")
+ endif()
+ if("${ZOOKEEPER_HOME}_" MATCHES "^_$")
+ message(" ")
+ message("- Please set the cache variable ZOOKEEPER_HOME to point to the directory with the zookeeper source.")
+ message("- CMAKE will look for zookeeper include files in $ZOOKEEPER_HOME/src/c/include.")
+ message("- CMAKE will look for zookeeper library files in $ZOOKEEPER_HOME/src/c/Debug or $ZOOKEEPER_HOME/src/c/Release.")
+ else()
+ FILE(TO_CMAKE_PATH ${ZOOKEEPER_HOME} Zookeeper_HomePath)
+ set(Zookeeper_LIB_PATHS ${Zookeeper_HomePath}/src/c/${ZK_BuildOutputDir})
+ find_path(ZK_INCLUDE_DIR zookeeper.h ${Zookeeper_HomePath}/src/c/include)
+ find_path(ZK_INCLUDE_DIR_GEN zookeeper.jute.h ${Zookeeper_HomePath}/src/c/generated)
+ set(Zookeeper_INCLUDE_DIR zookeeper.h ${ZK_INCLUDE_DIR} ${ZK_INCLUDE_DIR_GEN} )
+ find_library(Zookeeper_LIBRARY NAMES zookeeper PATHS ${Zookeeper_LIB_PATHS})
+ endif()
+else()
+ set(Zookeeper_LIB_PATHS /usr/local/lib /usr/lib/ /usr/lib/x86_64-linux-gnu/)
+ find_path(Zookeeper_INCLUDE_DIR zookeeper/zookeeper.h /usr/local/include)
+ find_library(Zookeeper_LIBRARY NAMES libzookeeper_mt.a PATHS ${Zookeeper_LIB_PATHS})
+endif()
+set(Zookeeper_LIBRARIES ${Zookeeper_LIBRARY} )
+set(Zookeeper_INCLUDE_DIRS ${Zookeeper_INCLUDE_DIR} )
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set Zookeeper_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(Zookeeper DEFAULT_MSG
+ Zookeeper_LIBRARY Zookeeper_INCLUDE_DIR)
+if (Zookeeper_LIBRARY)
+ message("-- Zookeeper found, ${Zookeeper_LIBRARY}")
+endif()
+mark_as_advanced(Zookeeper_INCLUDE_DIR Zookeeper_LIBRARY )
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/cmake/ProtobufGen.cmake
----------------------------------------------------------------------
diff --git a/hbase-native-client/cmake/ProtobufGen.cmake b/hbase-native-client/cmake/ProtobufGen.cmake
new file mode 100644
index 0000000..0cc2c2f
--- /dev/null
+++ b/hbase-native-client/cmake/ProtobufGen.cmake
@@ -0,0 +1,62 @@
+# 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.
+# copied in most part from protobuf cmake
+# there are similar protobuf gen changes online, all of which do
+# a similar job of customizing their generation.
+function(generate_protobuf_src SRCS HDRS)
+ if(NOT ARGN)
+ message(SEND_ERROR "Error: generate_protobuf_src() called without any proto files")
+ return()
+ endif()
+
+ set(_protobuf_include_path -I .)
+ if(DEFINED PROTOBUF_INCLUDE_DIRS)
+ foreach(DIR ${PROTOBUF_INCLUDE_DIRS})
+ file(RELATIVE_PATH REL_PATH ${CMAKE_SOURCE_DIR} ${DIR})
+ list(FIND _protobuf_include_path ${REL_PATH} _contains_already)
+ if(${_contains_already} EQUAL -1)
+ list(APPEND _protobuf_include_path -I ${REL_PATH})
+ endif()
+ endforeach()
+ endif()
+ set(${SRCS})
+ set(${HDRS})
+ foreach(FIL ${ARGN})
+ get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
+ get_filename_component(FIL_WE ${FIL} NAME_WE)
+ ## get the directory where our protobufs are stored
+ file(RELATIVE_PATH REL_FIL ${CMAKE_SOURCE_DIR} ${ABS_FIL})
+ get_filename_component(REL_DIR ${REL_FIL} DIRECTORY)
+ list(APPEND ${SRCS} "${CMAKE_BINARY_DIR_GEN}/${FIL_WE}.pb.cc")
+ list(APPEND ${HDRS} "${CMAKE_BINARY_DIR_GEN}/${FIL_WE}.pb.h")
+ add_custom_command(
+ OUTPUT "${CMAKE_BINARY_DIR_GEN}/${FIL_WE}.pb.cc"
+ "${CMAKE_BINARY_DIR_GEN}/${FIL_WE}.pb.h"
+ COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
+ ARGS --cpp_out=${CMAKE_BINARY_DIR_GEN}
+ --proto_path=${REL_DIR}
+ ${_protobuf_include_path}
+ ${REL_FIL}
+ DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ COMMENT "Generating ${FIL}"
+ VERBATIM)
+ endforeach()
+ set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
+ set(${SRCS} ${${SRCS}} PARENT_SCOPE)
+ set(${HDRS} ${${HDRS}} PARENT_SCOPE)
+endfunction()
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/docker-files/Dockerfile
----------------------------------------------------------------------
diff --git a/hbase-native-client/docker-files/Dockerfile b/hbase-native-client/docker-files/Dockerfile
index c8844ac..045f4f5 100644
--- a/hbase-native-client/docker-files/Dockerfile
+++ b/hbase-native-client/docker-files/Dockerfile
@@ -15,31 +15,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-FROM pjameson/buck-folly-watchman:20160511
+FROM ubuntu:16.04
ARG CC=/usr/bin/gcc-5
ARG CXX=/usr/bin/g++-5
-ARG CFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -g -fno-omit-frame-pointer -O2 -pthread"
-ARG CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -g -fno-omit-frame-pointer -O2 -pthread"
+ARG CFLAGS="-fPIC -g -fno-omit-frame-pointer -O2 -pthread"
+ARG CXXFLAGS="-fPIC -g -fno-omit-frame-pointer -O2 -pthread"
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 \
+ libboost-all-dev libevent-dev libdouble-conversion-dev cmake libkrb5-dev git openjdk-8-jdk && \
+ 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 ftp://ftp.cyrusimap.org/cyrus-sasl/cyrus-sasl-2.1.26.tar.gz ; \
tar zxf cyrus-sasl-2.1.26.tar.gz ; \
cd cyrus-sasl-2.1.26 ; \
./configure ; \
- make ; \
+ make -j4; \
make install ;\
cp /usr/local/lib/sasl2/* /usr/lib/sasl2/
-RUN apt-get install -y vim maven inetutils-ping python-pip doxygen graphviz clang-format \
- valgrind && \
- pip install yapf && \
- apt-get -qq clean && \
- apt-get -y -qq autoremove && \
- rm -rf /var/lib/{apt,dpkg,cache,log}/ && \
- rm -rf /tmp/*
-
RUN apt-get update && \
apt-get install -y debconf-utils debconf-set-selections && \
echo "krb5-config krb5-config/kerberos_servers string localhost" | debconf-set-selections ; \
@@ -67,7 +69,7 @@ RUN git clone https://github.com/google/protobuf.git /usr/src/protobuf && \
ldconfig && \
./autogen.sh && \
./configure && \
- make && \
+ make -j4 && \
make install && \
make clean && \
rm -rf .git && \
@@ -79,12 +81,12 @@ RUN git clone https://github.com/google/protobuf.git /usr/src/protobuf && \
cd src/c && \
ldconfig && \
./configure && \
- make && \
+ make -j4 && \
make install && \
make clean && \
ldconfig
-# Update folly
+# Update folly. `make check` removed due to a failing test, explicitly installing gtest ourselves
RUN cd /usr/src/ && \
ver=2017.09.04.00 && \
wget https://github.com/facebook/folly/archive/v$ver.tar.gz && \
@@ -96,13 +98,17 @@ RUN cd /usr/src/ && \
tar zxf release-1.8.0.tar.gz && \
rm -f release-1.8.0.tar.gz && \
mv googletest-release-1.8.0 gtest && \
- cd ../ && \
+ cd gtest && \
+ cmake . && \
+ make -j4 && \
+ make install && \
+ cd ../.. && \
ldconfig && \
autoreconf -ivf && \
./configure && \
- make && \
- make check && \
- make install
+ make -j4 && \
+ make install && \
+ make clean
# Update wangle
RUN cd /usr/src/ && \
@@ -113,9 +119,10 @@ RUN cd /usr/src/ && \
cd wangle-$ver/wangle && \
ldconfig && \
cmake . -DBUILD_TESTS=OFF && \
- make && \
+ make -j4 && \
ctest && \
- make install
+ make install && \
+ make clean
RUN echo "enabled=1" >> /etc/default/apport
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/client/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/client/BUCK b/hbase-native-client/include/hbase/client/BUCK
deleted file mode 100644
index 66d6896..0000000
--- a/hbase-native-client/include/hbase/client/BUCK
+++ /dev/null
@@ -1,93 +0,0 @@
-##
-# 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.
-
-# This is the main library.
-cxx_library(
- name="client",
- header_namespace="hbase/client",
- exported_headers=[
- "async-client-scanner.h",
- "async-connection.h",
- "async-region-locator.h",
- "async-rpc-retrying-caller-factory.h",
- "async-rpc-retrying-caller.h",
- "async-table-result-scanner.h",
- "client.h",
- "cell.h",
- "filter.h",
- "query.h",
- "keyvalue-codec.h",
- "region-location.h",
- "location-cache.h",
- "connection-configuration.h",
- # TODO: move this out of exported
- # Once meta lookup works
- "meta-utils.h",
- "get.h",
- "increment.h",
- "mutation.h",
- "put.h",
- "delete.h",
- "scan.h",
- "append.h",
- "result.h",
- "result-scanner.h",
- "request-converter.h",
- "response-converter.h",
- "table.h",
- "async-scan-rpc-retrying-caller.h",
- "raw-async-table.h",
- "raw-scan-result-consumer.h",
- "scan-result-cache.h",
- "hbase-rpc-controller.h",
- "time-range.h",
- "zk-util.h",
- "action.h",
- "multi-response.h",
- "region-request.h",
- "region-result.h",
- "row.h",
- "server-request.h",
- "async-batch-rpc-retrying-caller.h",
- ],
- deps=[
- "//include/hbase/exceptions:exceptions",
- "//include/hbase/utils:utils",
- "//include/hbase/connection:connection",
- "//include/hbase/client:conf",
- "//src/hbase/if:if",
- "//include/hbase/serde:serde",
- "//third-party:folly",
- "//third-party:wangle",
- "//third-party:zookeeper_mt",
- ],
- compiler_flags=['-Weffc++', '-ggdb'],
- visibility=[
- 'PUBLIC',
- ],)
-cxx_library(
- name="conf",
- header_namespace="hbase/client",
- exported_headers=[
- "configuration.h",
- "hbase-configuration-loader.h",
- ],
- deps=["//src/hbase/utils:utils", "//third-party:folly"],
- compiler_flags=['-Weffc++', '-ggdb'],
- visibility=[
- 'PUBLIC',
- ],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/connection/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/connection/BUCK b/hbase-native-client/include/hbase/connection/BUCK
deleted file mode 100644
index 9a0b0cf..0000000
--- a/hbase-native-client/include/hbase/connection/BUCK
+++ /dev/null
@@ -1,57 +0,0 @@
-##
-# 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.
-
-# This is the library dealing with a single connection
-# to a single server.
-cxx_library(
- name="connection",
- header_namespace="hbase/connection",
- exported_headers=[
- "client-dispatcher.h",
- "client-handler.h",
- "sasl-handler.h",
- "connection-factory.h",
- "connection-pool.h",
- "connection-id.h",
- "pipeline.h",
- "request.h",
- "rpc-connection.h",
- "response.h",
- "service.h",
- "rpc-client.h",
- "sasl-util.h",
- "rpc-test-server.h",
- "rpc-test-server-handler.h",
- "rpc-fault-injector.h",
- "rpc-fault-injector-inl.h",
- ],
- deps=[
- "//src/hbase/if:if",
- "//include/hbase/utils:utils",
- "//include/hbase/serde:serde",
- "//include/hbase/security:security",
- "//third-party:folly",
- "//third-party:wangle",
- "//include/hbase/exceptions:exceptions",
- ],
- compiler_flags=['-Weffc++'],
- linker_flags=['-L/usr/local/lib', '-lsasl2', '-lkrb5'],
- exported_linker_flags=['-L/usr/local/lib', '-lsasl2', '-lkrb5'],
- visibility=[
- '//include/hbase/client/...',
- '//src/hbase/connection/...',
- ],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/exceptions/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/exceptions/BUCK b/hbase-native-client/include/hbase/exceptions/BUCK
deleted file mode 100644
index ee296ff..0000000
--- a/hbase-native-client/include/hbase/exceptions/BUCK
+++ /dev/null
@@ -1,28 +0,0 @@
-##
-# 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.
-
-cxx_library(
- name="exceptions",
- header_namespace="hbase/exceptions",
- exported_headers=[
- "exception.h",
- ],
- deps=[
- "//third-party:folly",
- ],
- compiler_flags=['-Weffc++'],
- visibility=['//src/hbase/exceptions/...', '//include/hbase/client/...', '//include/hbase/connection/...'],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/security/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/security/BUCK b/hbase-native-client/include/hbase/security/BUCK
deleted file mode 100644
index 2e7530b..0000000
--- a/hbase-native-client/include/hbase/security/BUCK
+++ /dev/null
@@ -1,30 +0,0 @@
-##
-# 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.
-
-# This is the library dealing with a single connection
-# to a single server.
-cxx_library(
- name="security",
- header_namespace="hbase/security",
- exported_headers=[
- "user.h",
- ],
- deps=["//src/hbase/client:conf"],
- compiler_flags=['-Weffc++'],
- visibility=[
- 'PUBLIC',
- ],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/serde/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/serde/BUCK b/hbase-native-client/include/hbase/serde/BUCK
deleted file mode 100644
index ee8ef82..0000000
--- a/hbase-native-client/include/hbase/serde/BUCK
+++ /dev/null
@@ -1,37 +0,0 @@
-##
-# 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.
-
-cxx_library(
- name="serde",
- header_namespace="hbase/serde",
- exported_headers=[
- "cell-scanner.h",
- "cell-outputstream.h",
- "codec.h",
- "region-info.h",
- "rpc-serde.h",
- "server-name.h",
- "table-name.h",
- "zk.h",
- ],
- deps=[
- "//src/hbase/if:if", "//third-party:folly", "//src/hbase/utils:utils", "//src/hbase/security:security"
- ],
- compiler_flags=['-Weffc++'],
- visibility=[
- 'PUBLIC',
- ],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/test-util/mini-cluster.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/test-util/mini-cluster.h b/hbase-native-client/include/hbase/test-util/mini-cluster.h
new file mode 100644
index 0000000..978ded8
--- /dev/null
+++ b/hbase-native-client/include/hbase/test-util/mini-cluster.h
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ *
+ */
+#pragma once
+
+#include <jni.h>
+#include <string>
+#include <vector>
+#include <mutex>
+
+namespace hbase {
+
+class MiniCluster {
+ public:
+ virtual ~MiniCluster();
+ jobject StartCluster(int32_t num_region_servers);
+ void StopCluster();
+ jobject CreateTable(const std::string &table, const std::string &family);
+ jobject CreateTable(const std::string &table, const std::vector<std::string> &families);
+ jobject CreateTable(const std::string &table, const std::string &family,
+ const std::vector<std::string> &keys);
+ jobject CreateTable(const std::string &table, const std::vector<std::string> &families,
+ const std::vector<std::string> &keys);
+ jobject StopRegionServer(int idx);
+
+ // moves region to server
+ void MoveRegion(const std::string ®ion, const std::string &server);
+ // returns the Configuration instance for the cluster
+ jobject GetConf();
+ // returns the value for config key retrieved from cluster
+ const std::string GetConfValue(const std::string &key);
+
+ private:
+ JNIEnv *env_;
+ jclass testing_util_class_;
+ jclass table_name_class_;
+ jclass put_class_;
+ jclass conf_class_;
+ jmethodID stop_rs_mid_;
+ jmethodID get_conf_mid_;
+ jmethodID set_conf_mid_;
+ jmethodID tbl_name_value_of_mid_;
+ jmethodID create_table_mid_;
+ jmethodID create_table_families_mid_;
+ jmethodID create_table_with_split_mid_;
+ jmethodID put_mid_;
+ jmethodID put_ctor_;
+ jmethodID add_col_mid_;
+ jmethodID create_conn_mid_;
+ jmethodID get_conn_mid_;
+ jmethodID get_table_mid_;
+ jmethodID conf_get_mid_;
+ jmethodID get_admin_mid_;
+ jmethodID move_mid_;
+ jmethodID str_ctor_mid_;
+ jobject htu_;
+ jobject cluster_;
+ std::mutex count_mutex_;
+ JavaVM *jvm_;
+ JNIEnv *CreateVM(JavaVM **jvm);
+ void Setup();
+ jobject htu();
+ JNIEnv *env();
+ jbyteArray StrToByteChar(const std::string &str);
+ jobject admin();
+};
+} /*namespace hbase*/
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/test-util/test-util.h
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/test-util/test-util.h b/hbase-native-client/include/hbase/test-util/test-util.h
new file mode 100644
index 0000000..7c57c28
--- /dev/null
+++ b/hbase-native-client/include/hbase/test-util/test-util.h
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ *
+ */
+#pragma once
+
+#include <folly/Random.h>
+#include <folly/experimental/TestUtil.h>
+
+#include <cstdlib>
+#include <memory>
+#include <string>
+#include <vector>
+#include "hbase/client/configuration.h"
+#include "hbase/test-util/mini-cluster.h"
+
+namespace hbase {
+/**
+ * @brief Class to deal with a local instance cluster for testing.
+ */
+class TestUtil {
+ public:
+ TestUtil();
+
+ /**
+ * Destroying a TestUtil will spin down a cluster and remove the test dir.
+ */
+ ~TestUtil();
+
+ /**
+ * Create a random string. This random string is all letters, as such it is
+ * very good for use as a directory name.
+ */
+ static std::string RandString(int len = 32);
+
+ /**
+ * Returns the configuration to talk to the local cluster
+ */
+ std::shared_ptr<Configuration> conf() const { return conf_; }
+
+ /**
+ * Starts mini hbase cluster with specified number of region servers
+ */
+ void StartMiniCluster(int32_t num_region_servers);
+
+ void StopMiniCluster();
+ void CreateTable(const std::string &table, const std::string &family);
+ void CreateTable(const std::string &table, const std::vector<std::string> &families);
+ void CreateTable(const std::string &table, const std::string &family,
+ const std::vector<std::string> &keys);
+ void CreateTable(const std::string &table, const std::vector<std::string> &families,
+ const std::vector<std::string> &keys);
+
+ void StartStandAloneInstance();
+ void StopStandAloneInstance();
+ void RunShellCmd(const std::string &);
+ void MoveRegion(const std::string ®ion, const std::string &server);
+
+ private:
+ std::unique_ptr<MiniCluster> mini_;
+ folly::test::TemporaryDirectory temp_dir_;
+ std::shared_ptr<Configuration> conf_ = std::make_shared<Configuration>();
+};
+} // namespace hbase
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/include/hbase/utils/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/include/hbase/utils/BUCK b/hbase-native-client/include/hbase/utils/BUCK
deleted file mode 100644
index d44e908..0000000
--- a/hbase-native-client/include/hbase/utils/BUCK
+++ /dev/null
@@ -1,40 +0,0 @@
-##
-# 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.
-
-cxx_library(
- name="utils",
- header_namespace="hbase/utils",
- exported_headers=[
- "bytes-util.h",
- "connection-util.h",
- "concurrent-map.h",
- "optional.h",
- "sys-util.h",
- "time-util.h",
- "user-util.h",
- "version.h",
- ],
- deps=[
- '//third-party:folly',
- ],
- tests=[":user-util-test"],
- linker_flags=['-L/usr/local/lib', '-lkrb5'],
- exported_linker_flags=['-L/usr/local/lib', '-lkrb5'],
- visibility=[
- 'PUBLIC',
- ],
- compiler_flags=['-Weffc++'],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/src/hbase/client/BUCK
----------------------------------------------------------------------
diff --git a/hbase-native-client/src/hbase/client/BUCK b/hbase-native-client/src/hbase/client/BUCK
deleted file mode 100644
index 1a8f434..0000000
--- a/hbase-native-client/src/hbase/client/BUCK
+++ /dev/null
@@ -1,301 +0,0 @@
-##
-# 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.
-
-# This is the main library.
-cxx_library(
- name="client",
- srcs=[
- "async-client-scanner.cc",
- "async-connection.cc",
- "async-rpc-retrying-caller-factory.cc",
- "async-rpc-retrying-caller.cc",
- "async-scan-rpc-retrying-caller.cc",
- "async-table-result-scanner.cc",
- "cell.cc",
- "client.cc",
- "hbase-rpc-controller.cc",
- "keyvalue-codec.cc",
- "location-cache.cc",
- "meta-utils.cc",
- "increment.cc",
- "get.cc",
- "mutation.cc",
- "put.cc",
- "delete.cc",
- "scan.cc",
- "append.cc",
- "scan-result-cache.cc",
- "raw-async-table.cc",
- "result.cc",
- "request-converter.cc",
- "response-converter.cc",
- "table.cc",
- "time-range.cc",
- "zk-util.cc",
- "multi-response.cc",
- "region-result.cc",
- "async-batch-rpc-retrying-caller.cc",
- ],
- deps=[
- "//include/hbase/client:client",
- "//src/hbase/exceptions:exceptions",
- "//src/hbase/utils:utils",
- "//src/hbase/connection:connection",
- "//src/hbase/client:conf",
- "//src/hbase/if:if",
- "//src/hbase/serde:serde",
- "//third-party:folly",
- "//third-party:wangle",
- "//third-party:zookeeper_mt",
- ],
- compiler_flags=['-Weffc++', '-ggdb'],
- visibility=[
- 'PUBLIC',
- ],)
-cxx_library(
- name="conf",
- exported_headers=[
- ],
- srcs=[
- "configuration.cc",
- "hbase-configuration-loader.cc",
- ],
- deps=["//include/hbase/client:conf", "//src/hbase/utils:utils", "//third-party:folly"],
- compiler_flags=['-Weffc++', '-ggdb'],
- visibility=[
- 'PUBLIC',
- ],)
-cxx_test(
- name="location-cache-test",
- srcs=[
- "location-cache-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/test-util:test-util",
- ],
- run_test_separately=True,)
-cxx_test(
- name="location-cache-retry-test",
- srcs=[
- "location-cache-retry-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/if:if",
- "//src/hbase/serde:serde",
- "//src/hbase/test-util:test-util",
- ],
- run_test_separately=True,)
-cxx_test(
- name="cell-test",
- srcs=[
- "cell-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="filter-test",
- srcs=[
- "filter-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/if:if",
- "//src/hbase/serde:serde",
- "//src/hbase/test-util:test-util",
- ],
- run_test_separately=True,)
-cxx_test(
- name="get-test",
- srcs=[
- "get-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="delete-test",
- srcs=[
- "delete-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="increment-test",
- srcs=[
- "increment-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="put-test",
- srcs=[
- "put-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="append-test",
- srcs=[
- "append-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="retry-test",
- srcs=[
- "async-rpc-retrying-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/test-util:test-util",
- "//src/hbase/exceptions:exceptions",
- ],
- run_test_separately=True,)
-cxx_test(
- name="time-range-test",
- srcs=[
- "time-range-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="configuration-test",
- srcs=[
- "configuration-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="hbase-configuration-test",
- srcs=[
- "hbase-configuration-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="scan-test",
- srcs=[
- "scan-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="result-test",
- srcs=[
- "result-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="request-converter-test",
- srcs=[
- "request-converter-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/connection:connection",
- "//src/hbase/if:if",
- ],
- run_test_separately=True,)
-cxx_test(
- name="client-test",
- srcs=[
- "client-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/if:if",
- "//src/hbase/serde:serde",
- "//src/hbase/test-util:test-util",
- ],
- run_test_separately=True,)
-cxx_test(
- name="scan-result-cache-test",
- srcs=[
- "scan-result-cache-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="scanner-test",
- srcs=[
- "scanner-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/if:if",
- "//src/hbase/serde:serde",
- "//src/hbase/test-util:test-util",
- ],
- run_test_separately=True,)
-cxx_test(
- name="zk-util-test",
- srcs=[
- "zk-util-test.cc",
- ],
- deps=[
- ":client",
- ],
- run_test_separately=True,)
-cxx_test(
- name="multi-retry-test",
- srcs=[
- "async-batch-rpc-retrying-test.cc",
- ],
- deps=[
- ":client",
- "//src/hbase/test-util:test-util",
- "//src/hbase/exceptions:exceptions",
- ],
- run_test_separately=True,)
-cxx_binary(
- name="simple-client",
- srcs=[
- "simple-client.cc",
- ],
- deps=[":client", "//src/hbase/connection:connection"],)
-cxx_binary(
- name="load-client",
- srcs=[
- "load-client.cc",
- ],
- deps=[":client", "//src/hbase/connection:connection"],)
http://git-wip-us.apache.org/repos/asf/hbase/blob/24f7f093/hbase-native-client/src/hbase/client/append-test.cc
----------------------------------------------------------------------
diff --git a/hbase-native-client/src/hbase/client/append-test.cc b/hbase-native-client/src/hbase/client/append-test.cc
deleted file mode 100644
index 1af138d..0000000
--- a/hbase-native-client/src/hbase/client/append-test.cc
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * 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.
- *
- */
-#include <glog/logging.h>
-#include <gtest/gtest.h>
-
-#include "hbase/client/append.h"
-#include "hbase/client/mutation.h"
-#include "hbase/utils/time-util.h"
-
-using hbase::Append;
-using hbase::Cell;
-using hbase::CellType;
-using hbase::Mutation;
-using hbase::TimeUtil;
-
-const constexpr int64_t Mutation::kLatestTimestamp;
-
-TEST(Append, Row) {
- Append append{"foo"};
- EXPECT_EQ("foo", append.row());
-}
-
-TEST(Append, Durability) {
- Append append{"row"};
- EXPECT_EQ(hbase::pb::MutationProto_Durability_USE_DEFAULT, append.Durability());
-
- auto skipWal = hbase::pb::MutationProto_Durability_SKIP_WAL;
- append.SetDurability(skipWal);
- EXPECT_EQ(skipWal, append.Durability());
-}
-
-TEST(Append, Timestamp) {
- Append append{"row"};
-
- // test default timestamp
- EXPECT_EQ(Mutation::kLatestTimestamp, append.TimeStamp());
-
- // set custom timestamp
- auto ts = TimeUtil::ToMillis(TimeUtil::GetNowNanos());
- append.SetTimeStamp(ts);
- EXPECT_EQ(ts, append.TimeStamp());
-
- // Add a column with custom timestamp
- append.Add("f", "q", "v");
- auto &cell = append.FamilyMap().at("f")[0];
- EXPECT_EQ(ts, cell->Timestamp());
-}
-
-TEST(Append, HasFamilies) {
- Append append{"row"};
-
- EXPECT_EQ(false, append.HasFamilies());
-
- append.Add("f", "q", "v");
- EXPECT_EQ(true, append.HasFamilies());
-}
-
-TEST(Append, Add) {
- CellType cell_type = CellType::PUT;
- std::string row = "row";
- std::string family = "family";
- std::string column = "column";
- std::string value = "value";
- int64_t timestamp = std::numeric_limits<int64_t>::max();
- auto cell = std::make_unique<Cell>(row, family, column, timestamp, value, cell_type);
-
- // add first cell
- Append append{"row"};
- append.Add(std::move(cell));
- EXPECT_EQ(1, append.FamilyMap().size());
- EXPECT_EQ(1, append.FamilyMap().at(family).size());
-
- // add a non-matching row
- auto cell2 = std::make_unique<Cell>(row, family, column, timestamp, value, cell_type);
- Append append2{"foo"};
- ASSERT_THROW(append2.Add(std::move(cell2)), std::runtime_error); // rows don't match
-
- // add a second cell with same family
- auto cell3 = std::make_unique<Cell>(row, family, "column-2", timestamp, value, cell_type);
- append.Add(std::move(cell3));
- EXPECT_EQ(1, append.FamilyMap().size());
- EXPECT_EQ(2, append.FamilyMap().at(family).size());
-
- // add a cell to a different family
- auto cell4 = std::make_unique<Cell>(row, "family-2", "column-2", timestamp, value, cell_type);
- append.Add(std::move(cell4));
- EXPECT_EQ(2, append.FamilyMap().size());
- EXPECT_EQ(1, append.FamilyMap().at("family-2").size());
-}