From 35a2cfeb83477c956b80451cb8c8d47463bf8a45 Mon Sep 17 00:00:00 2001 From: Yingchun Lai <405403881@qq.com> Date: Mon, 17 Jan 2022 20:27:34 +0800 Subject: [PATCH] feat(build): support to build on MacOS --- rdsn | 2 +- src/base/pegasus_key_schema.h | 13 +++++++------ src/base/pegasus_value_schema.h | 2 +- src/base/test/CMakeLists.txt | 2 +- src/client_lib/CMakeLists.txt | 21 +++++++++++---------- src/geo/bench/CMakeLists.txt | 2 +- src/geo/test/CMakeLists.txt | 2 +- src/redis_protocol/proxy/CMakeLists.txt | 2 +- src/redis_protocol/proxy_ut/CMakeLists.txt | 2 +- src/server/available_detector.cpp | 6 +++--- src/server/hashkey_transform.h | 3 ++- src/server/pegasus_server_impl.cpp | 2 +- src/shell/commands/data_operations.cpp | 15 ++++++++------- src/shell/commands/debugger.cpp | 3 ++- src/test/bench_test/CMakeLists.txt | 2 +- src/test/bench_test/rand.cpp | 3 ++- src/test/kill_test/CMakeLists.txt | 2 +- src/test/pressure_test/CMakeLists.txt | 2 +- src/test/upgrade_test/CMakeLists.txt | 2 +- 19 files changed, 47 insertions(+), 41 deletions(-) diff --git a/rdsn b/rdsn index 058f9474d3..9552d2cbcc 160000 --- a/rdsn +++ b/rdsn @@ -1 +1 @@ -Subproject commit 058f9474d3b16b4d9123d03df6332a8218377d29 +Subproject commit 9552d2cbccf271c2b6c317777eb54b3dd6d3ec33 diff --git a/src/base/pegasus_key_schema.h b/src/base/pegasus_key_schema.h index b894c6d3da..042da1cf4e 100644 --- a/src/base/pegasus_key_schema.h +++ b/src/base/pegasus_key_schema.h @@ -20,10 +20,11 @@ #pragma once #include -#include +#include #include #include #include +#include #include #include #include @@ -46,7 +47,7 @@ void pegasus_generate_key(::dsn::blob &key, const T &hash_key, const T &sort_key // hash_key_len is in big endian uint16_t hash_key_len = hash_key.length(); - *((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len); + *((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len); ::memcpy(buf.get() + 2, hash_key.data(), hash_key_len); @@ -68,7 +69,7 @@ void pegasus_generate_next_blob(::dsn::blob &next, const T &hash_key) int hash_key_len = hash_key.length(); std::shared_ptr buf(::dsn::utils::make_shared_array(hash_key_len + 2)); - *((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len); + *((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len); ::memcpy(buf.get() + 2, hash_key.data(), hash_key_len); unsigned char *p = (unsigned char *)(buf.get() + hash_key_len + 1); @@ -104,7 +105,7 @@ pegasus_restore_key(const ::dsn::blob &key, ::dsn::blob &hash_key, ::dsn::blob & dassert(key.length() >= 2, "key length must be no less than 2"); // hash_key_len is in big endian - uint16_t hash_key_len = be16toh(*(int16_t *)(key.data())); + uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data())); if (hash_key_len > 0) { dassert(key.length() >= 2 + hash_key_len, @@ -129,7 +130,7 @@ pegasus_restore_key(const ::dsn::blob &key, std::string &hash_key, std::string & dassert(key.length() >= 2, "key length must be no less than 2"); // hash_key_len is in big endian - uint16_t hash_key_len = be16toh(*(int16_t *)(key.data())); + uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data())); if (hash_key_len > 0) { dassert(key.length() >= 2 + hash_key_len, @@ -153,7 +154,7 @@ inline uint64_t pegasus_key_hash(const T &key) dassert(key.size() >= 2, "key length must be no less than 2"); // hash_key_len is in big endian - uint16_t hash_key_len = be16toh(*(int16_t *)(key.data())); + uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data())); if (hash_key_len > 0) { // hash_key_len > 0, compute hash from hash_key diff --git a/src/base/pegasus_value_schema.h b/src/base/pegasus_value_schema.h index 0202e6ac60..cc1d8f6961 100644 --- a/src/base/pegasus_value_schema.h +++ b/src/base/pegasus_value_schema.h @@ -20,7 +20,7 @@ #pragma once #include -#include +#include #include #include diff --git a/src/base/test/CMakeLists.txt b/src/base/test/CMakeLists.txt index 651e0c0551..8af554bc5f 100644 --- a/src/base/test/CMakeLists.txt +++ b/src/base/test/CMakeLists.txt @@ -33,7 +33,7 @@ set(MY_PROJ_LIBS pegasus_base gtest) -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) set(MY_BINPLACES config.ini run.sh) diff --git a/src/client_lib/CMakeLists.txt b/src/client_lib/CMakeLists.txt index f2a99864a2..1ced4f812a 100644 --- a/src/client_lib/CMakeLists.txt +++ b/src/client_lib/CMakeLists.txt @@ -29,6 +29,7 @@ target_include_directories(pegasus_client_impl_objects PUBLIC $) -target_link_libraries(pegasus_client_shared PRIVATE - pegasus_base - dsn_runtime - dsn_utils - dsn_client - dsn_replication_common - thrift) -install(TARGETS pegasus_client_shared DESTINATION "lib") +## link the shared lib of pegasus client +#add_library(pegasus_client_shared SHARED $) +#target_link_libraries(pegasus_client_shared PRIVATE +# pegasus_base +# dsn_runtime +# dsn_utils +# dsn_client +# dsn_replication_common +# thrift) +#install(TARGETS pegasus_client_shared DESTINATION "lib") diff --git a/src/geo/bench/CMakeLists.txt b/src/geo/bench/CMakeLists.txt index 3b848460fe..1c4ea97a51 100644 --- a/src/geo/bench/CMakeLists.txt +++ b/src/geo/bench/CMakeLists.txt @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS dsn_utils ) -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) set(MY_BINPLACES "config.ini") diff --git a/src/geo/test/CMakeLists.txt b/src/geo/test/CMakeLists.txt index 807d7306b0..fbb17cd4bc 100644 --- a/src/geo/test/CMakeLists.txt +++ b/src/geo/test/CMakeLists.txt @@ -35,7 +35,7 @@ set(MY_PROJ_LIBS dsn_utils gtest) -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) add_definitions(-Wno-attributes) diff --git a/src/redis_protocol/proxy/CMakeLists.txt b/src/redis_protocol/proxy/CMakeLists.txt index 88aaae1158..229e140afc 100644 --- a/src/redis_protocol/proxy/CMakeLists.txt +++ b/src/redis_protocol/proxy/CMakeLists.txt @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS pegasus.rproxylib set(MY_BINPLACES "config.ini") -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) # Avoid megabytes of warnings like: # rdsn/thirdparty/output/include/s2/s1angle.h:288:28: error: diff --git a/src/redis_protocol/proxy_ut/CMakeLists.txt b/src/redis_protocol/proxy_ut/CMakeLists.txt index 18f9d825dc..73cf0a74d0 100644 --- a/src/redis_protocol/proxy_ut/CMakeLists.txt +++ b/src/redis_protocol/proxy_ut/CMakeLists.txt @@ -27,7 +27,7 @@ set(MY_PROJ_SRC "") # "GLOB" for non-recursive search set(MY_SRC_SEARCH_MODE "GLOB") -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) set(MY_PROJ_LIBS pegasus.rproxylib pegasus_base diff --git a/src/server/available_detector.cpp b/src/server/available_detector.cpp index c39fadd210..75df12743f 100644 --- a/src/server/available_detector.cpp +++ b/src/server/available_detector.cpp @@ -386,7 +386,7 @@ void available_detector::on_day_report() ddebug("start to report on new day, last_day = %s", _old_day.c_str()); int64_t detect_times = _recent_day_detect_times.fetch_and(0); int64_t fail_times = _recent_day_fail_times.fetch_and(0); - int64_t succ_times = std::max(0L, detect_times - fail_times); + int64_t succ_times = std::max(0L, detect_times - fail_times); int64_t available = 0; std::string hash_key("detect_available_day"); std::string sort_key(_old_day); @@ -437,7 +437,7 @@ void available_detector::on_hour_report() ddebug("start to report on new hour, last_hour = %s", _old_hour.c_str()); int64_t detect_times = _recent_hour_detect_times.fetch_and(0); int64_t fail_times = _recent_hour_fail_times.fetch_and(0); - int64_t succ_times = std::max(0L, detect_times - fail_times); + int64_t succ_times = std::max(0L, detect_times - fail_times); int64_t available = 0; std::string hash_key("detect_available_hour"); std::string sort_key(_old_hour); @@ -461,7 +461,7 @@ void available_detector::on_minute_report() ddebug("start to report on new minute, last_minute = %s", _old_minute.c_str()); int64_t detect_times = _recent_minute_detect_times.fetch_and(0); int64_t fail_times = _recent_minute_fail_times.fetch_and(0); - int64_t succ_times = std::max(0L, detect_times - fail_times); + int64_t succ_times = std::max(0L, detect_times - fail_times); int64_t available = 0; std::string hash_key("detect_available_minute"); std::string sort_key(_old_minute); diff --git a/src/server/hashkey_transform.h b/src/server/hashkey_transform.h index 6b9b74bb4f..d640577309 100644 --- a/src/server/hashkey_transform.h +++ b/src/server/hashkey_transform.h @@ -24,6 +24,7 @@ #include #include +#include namespace pegasus { namespace server { @@ -46,7 +47,7 @@ class HashkeyTransform : public rocksdb::SliceTransform } // hash_key_len is in big endian - uint16_t hash_key_len = be16toh(*(int16_t *)(src.data())); + uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(src.data())); dassert(src.size() >= 2 + hash_key_len, "key length must be no less than (2 + hash_key_len)"); return rocksdb::Slice(src.data(), 2 + hash_key_len); diff --git a/src/server/pegasus_server_impl.cpp b/src/server/pegasus_server_impl.cpp index 72a24481f5..d3d6b58cfd 100644 --- a/src/server/pegasus_server_impl.cpp +++ b/src/server/pegasus_server_impl.cpp @@ -2830,7 +2830,7 @@ bool pegasus_server_impl::set_usage_scenario(const std::string &usage_scenario) new_options["write_buffer_size"] = std::to_string(buffer_size); uint64_t max_size = get_random_nearby(_data_cf_opts.max_bytes_for_level_base); new_options["level0_file_num_compaction_trigger"] = - std::to_string(std::max(4UL, max_size / buffer_size)); + std::to_string(std::max(4UL, max_size / buffer_size)); } } else if (usage_scenario == ROCKSDB_ENV_USAGE_SCENARIO_BULK_LOAD) { // refer to Options::PrepareForBulkLoad() diff --git a/src/shell/commands/data_operations.cpp b/src/shell/commands/data_operations.cpp index 44eabbb874..90d9703a86 100644 --- a/src/shell/commands/data_operations.cpp +++ b/src/shell/commands/data_operations.cpp @@ -18,6 +18,7 @@ */ #include "shell/commands.h" +#include #include "idl_utils.h" static void @@ -115,7 +116,7 @@ bool set_value(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -149,7 +150,7 @@ bool multi_set_value(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -403,7 +404,7 @@ bool delete_value(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -433,7 +434,7 @@ bool multi_del_value(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -664,7 +665,7 @@ bool incr(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -819,7 +820,7 @@ bool check_and_set(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; } @@ -983,7 +984,7 @@ bool check_and_mutate(command_executor *e, shell_context *sc, arguments args) fprintf(stderr, "\n"); fprintf(stderr, "app_id : %d\n", info.app_id); fprintf(stderr, "partition_index : %d\n", info.partition_index); - fprintf(stderr, "decree : %ld\n", info.decree); + fmt::fprintf(stderr, "decree : %lld\n", info.decree); fprintf(stderr, "server : %s\n", info.server.c_str()); return true; diff --git a/src/shell/commands/debugger.cpp b/src/shell/commands/debugger.cpp index e3d8407379..080b9570bf 100644 --- a/src/shell/commands/debugger.cpp +++ b/src/shell/commands/debugger.cpp @@ -271,7 +271,8 @@ bool rdb_value_hex2str(command_executor *e, shell_context *sc, arguments args) std::string pegasus_value = rocksdb::LDBCommand::HexToString(hex_rdb_value); auto expire_ts = static_cast(pegasus::pegasus_extract_expire_ts(0, pegasus_value)) + pegasus::utils::epoch_begin; // TODO(wutao): pass user specified version - fmt::print(stderr, "\nWhen to expire:\n {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&expire_ts)); + std::time_t tm(expire_ts); + fmt::print(stderr, "\nWhen to expire:\n {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&tm)); dsn::blob user_data; pegasus::pegasus_extract_user_data(0, std::move(pegasus_value), user_data); diff --git a/src/test/bench_test/CMakeLists.txt b/src/test/bench_test/CMakeLists.txt index 307d543d09..eaf02da84b 100644 --- a/src/test/bench_test/CMakeLists.txt +++ b/src/test/bench_test/CMakeLists.txt @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS krb5 ) -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) set(MY_BINPLACES "config.ini") diff --git a/src/test/bench_test/rand.cpp b/src/test/bench_test/rand.cpp index 9829705dae..09f82b5fd8 100644 --- a/src/test/bench_test/rand.cpp +++ b/src/test/bench_test/rand.cpp @@ -17,6 +17,7 @@ * under the License. */ +#include #include namespace pegasus { @@ -37,7 +38,7 @@ std::string generate_string(uint64_t len) // fill with random int uint64_t random_int = next_u64(); - key.append(reinterpret_cast(&random_int), std::min(len, 8UL)); + key.append(reinterpret_cast(&random_int), std::min(len, 8UL)); // append with '0' key.resize(len, '0'); diff --git a/src/test/kill_test/CMakeLists.txt b/src/test/kill_test/CMakeLists.txt index df97448737..6e2ab5d6c2 100644 --- a/src/test/kill_test/CMakeLists.txt +++ b/src/test/kill_test/CMakeLists.txt @@ -41,7 +41,7 @@ set(MY_PROJ_LIBS ) set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini") -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) if (UNIX) SET(CMAKE_INSTALL_RPATH ".") diff --git a/src/test/pressure_test/CMakeLists.txt b/src/test/pressure_test/CMakeLists.txt index 42e29b7366..b26cc10b58 100644 --- a/src/test/pressure_test/CMakeLists.txt +++ b/src/test/pressure_test/CMakeLists.txt @@ -37,7 +37,7 @@ set(MY_PROJ_LIBS set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-pressure.ini") -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) if (UNIX) SET(CMAKE_INSTALL_RPATH ".") diff --git a/src/test/upgrade_test/CMakeLists.txt b/src/test/upgrade_test/CMakeLists.txt index c4aed170d4..ee3a6eff81 100644 --- a/src/test/upgrade_test/CMakeLists.txt +++ b/src/test/upgrade_test/CMakeLists.txt @@ -40,7 +40,7 @@ set(MY_PROJ_LIBS ) set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini") -set(MY_BOOST_LIBS Boost::system Boost::filesystem) +set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex) if (UNIX) SET(CMAKE_INSTALL_RPATH ".")