This is an automated email from the ASF dual-hosted git repository.
laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new d7087b60f feat: Support to build server binaries separately (#2009)
d7087b60f is described below
commit d7087b60fbab0455e06809ee14f459db85a320d1
Author: Yingchun Lai <[email protected]>
AuthorDate: Wed May 22 11:08:49 2024 +0800
feat: Support to build server binaries separately (#2009)
This patch adds a new flag `--separate_servers` to indicate whether to build
`pegasus_collector`,`pegasus_meta_server` and `pegasus_replica_server`
binaries
separately, otherwise a combined `pegasus_server` binary will be built. The
corresponding option in CMake is `SEPARATE_SERVERS`.
---
CMakeLists.txt | 3 +
run.sh | 8 +-
src/base/test/CMakeLists.txt | 12 ++-
src/geo/test/CMakeLists.txt | 4 +
src/redis_protocol/proxy/CMakeLists.txt | 20 +++--
src/redis_protocol/proxy_ut/CMakeLists.txt | 22 +++---
src/sample/CMakeLists.txt | 7 +-
src/server/CMakeLists.txt | 88 ++++++++++++++++------
src/{sample => server/collector}/CMakeLists.txt | 16 ++--
.../misc.cpp => server/collector/main.cpp} | 43 ++++++-----
src/server/main.cpp | 87 ++++-----------------
src/{sample => server/meta_server}/CMakeLists.txt | 16 ++--
.../misc.cpp => server/meta_server/main.cpp} | 44 ++++++-----
.../replica_server}/CMakeLists.txt | 16 ++--
src/server/replica_server/main.cpp | 56 ++++++++++++++
src/server/server_utils.cpp | 81 ++++++++++++++++++++
.../commands/misc.cpp => server/server_utils.h} | 41 +++++-----
src/shell/command_helper.h | 8 --
src/shell/commands/misc.cpp | 2 +-
.../function_test/backup_restore/CMakeLists.txt | 8 +-
src/test/function_test/base_api/CMakeLists.txt | 27 ++++---
.../function_test/detect_hotspot/CMakeLists.txt | 8 +-
.../function_test/partition_split/CMakeLists.txt | 27 ++++---
src/test/function_test/recovery/CMakeLists.txt | 8 +-
src/test/function_test/restore/CMakeLists.txt | 8 +-
src/test/function_test/throttle/CMakeLists.txt | 27 ++++---
src/test/kill_test/CMakeLists.txt | 27 ++++---
src/test/pressure_test/CMakeLists.txt | 18 +++--
28 files changed, 458 insertions(+), 274 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 48a9da245..5cc4c7004 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,4 +64,7 @@ if(USE_JEMALLOC)
set(JEMALLOC_LIB_TYPE "SHARED")
endif()
+option(SEPARATE_SERVERS "Whether to build
pegasus_collector,pegasus_meta_server and pegasus_replica_server binaries
separately, otherwise a combined pegasus_server binary will be built" OFF)
+message(STATUS "SEPARATE_SERVERS = ${SEPARATE_SERVERS}")
+
add_subdirectory(src)
diff --git a/run.sh b/run.sh
index a8ec64edd..903e059ba 100755
--- a/run.sh
+++ b/run.sh
@@ -97,6 +97,7 @@ function usage_build()
echo " --disable_gperf build without gperftools, this flag is
mainly used"
echo " to enable valgrind memcheck, default no"
echo " --use_jemalloc build with jemalloc"
+ echo " --separate_servers whether to build
pegasus_collector,pegasus_meta_server and pegasus_replica_server binaries
separately, otherwise a combined pegasus_server binary will be built"
echo " --sanitizer <type> build with sanitizer to check potential
problems,
type: address|leak|thread|undefined"
echo " --skip_thirdparty whether to skip building thirdparties,
default no"
@@ -130,6 +131,7 @@ function run_build()
SANITIZER=""
ROCKSDB_PORTABLE=0
USE_JEMALLOC=OFF
+ SEPARATE_SERVERS=OFF
BUILD_TEST=OFF
IWYU=""
BUILD_MODULES=""
@@ -198,6 +200,9 @@ function run_build()
ENABLE_GPERF=OFF
USE_JEMALLOC=ON
;;
+ --separate_servers)
+ SEPARATE_SERVERS=ON
+ ;;
--test)
BUILD_TEST=ON
;;
@@ -230,7 +235,8 @@ function run_build()
CMAKE_OPTIONS="-DCMAKE_C_COMPILER=${C_COMPILER}
-DCMAKE_CXX_COMPILER=${CXX_COMPILER}
- -DUSE_JEMALLOC=${USE_JEMALLOC}"
+ -DUSE_JEMALLOC=${USE_JEMALLOC}
+ -DSEPARATE_SERVERS=${SEPARATE_SERVERS}"
echo "BUILD_TYPE=$BUILD_TYPE"
if [ "$BUILD_TYPE" == "debug" ]
diff --git a/src/base/test/CMakeLists.txt b/src/base/test/CMakeLists.txt
index b7e1c29d0..4d33878fe 100644
--- a/src/base/test/CMakeLists.txt
+++ b/src/base/test/CMakeLists.txt
@@ -28,10 +28,14 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- dsn_runtime
- dsn_utils
- pegasus_base
- gtest)
+ dsn_runtime
+ dsn_utils
+ pegasus_base
+ rocksdb
+ lz4
+ zstd
+ snappy
+ gtest)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/geo/test/CMakeLists.txt b/src/geo/test/CMakeLists.txt
index e29d506ae..73fd8ba10 100644
--- a/src/geo/test/CMakeLists.txt
+++ b/src/geo/test/CMakeLists.txt
@@ -35,6 +35,10 @@ set(MY_PROJ_LIBS
s2
pegasus_client_static
dsn_utils
+ rocksdb
+ lz4
+ zstd
+ snappy
gtest)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/redis_protocol/proxy/CMakeLists.txt
b/src/redis_protocol/proxy/CMakeLists.txt
index b74136056..a381914c7 100644
--- a/src/redis_protocol/proxy/CMakeLists.txt
+++ b/src/redis_protocol/proxy/CMakeLists.txt
@@ -26,14 +26,18 @@ set(MY_PROJ_SRC "")
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")
-set(MY_PROJ_LIBS pegasus.rproxylib
- absl::flat_hash_set
- absl::strings
- pegasus_geo_lib
- event
- s2
- pegasus_client_static
- )
+set(MY_PROJ_LIBS
+ pegasus.rproxylib
+ absl::flat_hash_set
+ absl::strings
+ pegasus_geo_lib
+ event
+ s2
+ pegasus_client_static
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BINPLACES "config.ini")
diff --git a/src/redis_protocol/proxy_ut/CMakeLists.txt
b/src/redis_protocol/proxy_ut/CMakeLists.txt
index cf7bb1df3..bddf2c085 100644
--- a/src/redis_protocol/proxy_ut/CMakeLists.txt
+++ b/src/redis_protocol/proxy_ut/CMakeLists.txt
@@ -29,15 +29,19 @@ set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-set(MY_PROJ_LIBS pegasus.rproxylib
- pegasus_base
- absl::flat_hash_set
- absl::strings
- pegasus_geo_lib
- s2
- pegasus_client_static
- gtest
- )
+set(MY_PROJ_LIBS
+ pegasus.rproxylib
+ pegasus_base
+ absl::flat_hash_set
+ absl::strings
+ pegasus_geo_lib
+ s2
+ pegasus_client_static
+ rocksdb
+ lz4
+ zstd
+ snappy
+ gtest)
set(MY_BINPLACES "config.ini" "run.sh")
diff --git a/src/sample/CMakeLists.txt b/src/sample/CMakeLists.txt
index b0618dfca..294a67111 100644
--- a/src/sample/CMakeLists.txt
+++ b/src/sample/CMakeLists.txt
@@ -20,8 +20,11 @@ set(MY_PROJ_NAME "sample")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- pegasus_client_static
- )
+ pegasus_client_static
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::filesystem Boost::system)
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index 11673f693..fbb990e4a 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -15,33 +15,77 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME pegasus_server)
-set(MY_PROJ_SRC "")
-set(MY_SRC_SEARCH_MODE "GLOB")
-set(MY_PROJ_LIBS
- dsn_replica_server
+set(SERVER_COMMON_SRC
+ ${CMAKE_CURRENT_SOURCE_DIR}/server_utils.cpp)
+set(COLLECTOR_SRC
+ ${SERVER_COMMON_SRC}
+ ${CMAKE_CURRENT_SOURCE_DIR}/available_detector.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/info_collector.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/info_collector_app.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/hotspot_partition_calculator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/result_writer.cpp)
+set(META_SERVER_SRC
+ ${SERVER_COMMON_SRC})
+set(REPLICA_SERVER_SRC
+ ${SERVER_COMMON_SRC}
+ ${CMAKE_CURRENT_SOURCE_DIR}/capacity_unit_calculator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/compaction_filter_rule.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/compaction_operation.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/hotkey_collector.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_event_listener.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_manual_compact_service.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_mutation_duplicator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_server_impl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_server_impl_init.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_server_write.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/pegasus_write_service.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/rocksdb_wrapper.cpp)
+
+set(SERVER_COMMON_LIBS
+ dsn_utils)
+set(COLLECTOR_LIBS
+ ${SERVER_COMMON_LIBS}
+ dsn_meta_server
+ pegasus_client_static
+ event)
+set(META_SERVER_LIBS
+ ${SERVER_COMMON_LIBS}
dsn_meta_server
- dsn_ranger
+ dsn.failure_detector
+ dsn.replication.zookeeper_provider
+ dsn.block_service
+ event
+ zookeeper
+ hashtable)
+set(REPLICA_SERVER_LIBS
+ ${SERVER_COMMON_LIBS}
+ dsn_replica_server
dsn_replication_common
- dsn_client
dsn.block_service.local
dsn.block_service
dsn.failure_detector
- dsn.replication.zookeeper_provider
- dsn_utils
rocksdb
- lz4
- zstd
- snappy
pegasus_base
pegasus_client_static
- event
- hashtable)
-set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-set(MY_BINPLACES
- config.ini)
-add_definitions(-Wno-attributes)
-SET(CMAKE_INSTALL_RPATH ".")
-SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-dsn_add_executable()
-dsn_install_executable()
+ event)
+
+if (SEPARATE_SERVERS)
+ add_subdirectory(collector)
+ add_subdirectory(meta_server)
+ add_subdirectory(replica_server)
+else ()
+ set(MY_PROJ_NAME pegasus_server)
+ set(MY_PROJ_SRC "")
+ set(MY_SRC_SEARCH_MODE "GLOB")
+ set(MY_PROJ_LIBS
+ ${SERVER_COMMON_LIBS}
+ ${COLLECTOR_LIBS}
+ ${META_SERVER_LIBS}
+ ${REPLICA_SERVER_LIBS})
+ set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+ set(MY_BINPLACES config.ini)
+ SET(CMAKE_INSTALL_RPATH ".")
+ SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+ dsn_add_executable()
+ dsn_install_executable()
+endif ()
diff --git a/src/sample/CMakeLists.txt b/src/server/collector/CMakeLists.txt
similarity index 75%
copy from src/sample/CMakeLists.txt
copy to src/server/collector/CMakeLists.txt
index b0618dfca..bbbf2294d 100644
--- a/src/sample/CMakeLists.txt
+++ b/src/server/collector/CMakeLists.txt
@@ -15,17 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "sample")
+set(MY_PROJ_NAME "pegasus_collector")
+set(MY_PROJ_SRC ${COLLECTOR_SRC})
set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS
- pegasus_client_static
- )
-
-set(MY_BOOST_LIBS Boost::filesystem Boost::system)
-
-set(MY_BINPLACES config.ini run.sh)
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../")
+set(MY_PROJ_LIBS ${COLLECTOR_LIBS})
+set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+SET(CMAKE_INSTALL_RPATH ".")
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
dsn_add_executable()
dsn_install_executable()
diff --git a/src/shell/commands/misc.cpp b/src/server/collector/main.cpp
similarity index 53%
copy from src/shell/commands/misc.cpp
copy to src/server/collector/main.cpp
index 4d5cec745..718937ba2 100644
--- a/src/shell/commands/misc.cpp
+++ b/src/server/collector/main.cpp
@@ -17,27 +17,34 @@
* under the License.
*/
-#include <iostream>
-#include <string>
+#include <unistd.h>
+#include <memory>
-#include "pegasus/git_commit.h"
-#include "pegasus/version.h"
+#include "info_collector_app.h"
+#include "pegasus_service_app.h"
#include "runtime/app_model.h"
-#include "shell/command_executor.h"
-#include "shell/command_helper.h"
-#include "shell/commands.h"
+#include "runtime/service_app.h"
+#include "server/server_utils.h"
+#include "utils/fmt_logging.h"
-bool version(command_executor *e, shell_context *sc, arguments args)
-{
- std::ostringstream oss;
- oss << "Pegasus Shell " << PEGASUS_VERSION << " (" << PEGASUS_GIT_COMMIT
<< ") "
- << PEGASUS_BUILD_TYPE;
- std::cout << oss.str() << std::endl;
- return true;
-}
+namespace dsn {
+class command_deregister;
+} // namespace dsn
-bool exit_shell(command_executor *e, shell_context *sc, arguments args)
+int main(int argc, char **argv)
{
- dsn_exit(0);
- return true;
+ static const char server_name[] = "Collector";
+ if (help(argc, argv, server_name)) {
+ dsn_exit(0);
+ }
+ LOG_INFO("{} starting, pid({}), version({})", server_name, getpid(),
pegasus_server_rcsid());
+
+ // Register collector service.
+
dsn::service_app::register_factory<pegasus::server::info_collector_app>("collector");
+
+ auto server_info_cmd = register_server_info_cmd();
+
+ dsn_run(argc, argv, true);
+
+ return 0;
}
diff --git a/src/server/main.cpp b/src/server/main.cpp
index 3aefd1329..aa9d1128e 100644
--- a/src/server/main.cpp
+++ b/src/server/main.cpp
@@ -17,18 +17,9 @@
* under the License.
*/
-#include <nlohmann/json.hpp>
-#include <nlohmann/json_fwd.hpp>
-#include <pegasus/git_commit.h>
-#include <pegasus/version.h>
#include <unistd.h>
-#include <cstdio>
-#include <map>
-#include <memory>
#include <string>
-#include <vector>
-#include "backup_types.h"
#include "common/replication_common.h"
#include "compaction_operation.h"
#include "info_collector_app.h"
@@ -37,77 +28,31 @@
#include "pegasus_service_app.h"
#include "runtime/app_model.h"
#include "runtime/service_app.h"
-#include "utils/command_manager.h"
+#include "server/server_utils.h"
#include "utils/fmt_logging.h"
-#include "utils/process_utils.h"
-#include "utils/strings.h"
-#include "utils/time_utils.h"
-#include "utils/utils.h"
-#define STR_I(var) #var
-#define STR(var) STR_I(var)
-#ifndef DSN_BUILD_TYPE
-#define PEGASUS_BUILD_TYPE ""
-#else
-#define PEGASUS_BUILD_TYPE STR(DSN_BUILD_TYPE)
-#endif
-
-static char const rcsid[] =
- "$Version: Pegasus Server " PEGASUS_VERSION " (" PEGASUS_GIT_COMMIT ")"
-#if defined(DSN_BUILD_TYPE)
- " " STR(DSN_BUILD_TYPE)
-#endif
- ", built by gcc " STR(__GNUC__) "." STR(__GNUC_MINOR__) "."
STR(__GNUC_PATCHLEVEL__)
-#if defined(DSN_BUILD_HOSTNAME)
- ", built on " STR(DSN_BUILD_HOSTNAME)
-#endif
- ", built at " __DATE__ " " __TIME__ " $";
-
-const char *pegasus_server_rcsid() { return rcsid; }
-
-using namespace dsn;
-using namespace dsn::replication;
-
-void dsn_app_registration_pegasus()
+int main(int argc, char **argv)
{
+ static const char server_name[] = "Pegasus server";
+ if (help(argc, argv, server_name)) {
+ dsn_exit(0);
+ }
+ LOG_INFO("{} starting, pid({}), version({})", server_name, getpid(),
pegasus_server_rcsid());
+
+ // Register meta service.
dsn::service::meta_service_app::register_components();
-
service_app::register_factory<pegasus::server::pegasus_meta_service_app>("meta");
-
service_app::register_factory<pegasus::server::pegasus_replication_service_app>(
+
dsn::service_app::register_factory<pegasus::server::pegasus_meta_service_app>("meta");
+
+ // Register replica service.
+
dsn::service_app::register_factory<pegasus::server::pegasus_replication_service_app>(
dsn::replication::replication_options::kReplicaAppType.c_str());
-
service_app::register_factory<pegasus::server::info_collector_app>("collector");
pegasus::server::pegasus_server_impl::register_service();
pegasus::server::register_compaction_operations();
-}
-int main(int argc, char **argv)
-{
- for (int i = 1; i < argc; ++i) {
- if (utils::equals(argv[i], "-v") || utils::equals(argv[i], "-version")
||
- utils::equals(argv[i], "--version")) {
- printf("Pegasus Server %s (%s) %s\n",
- PEGASUS_VERSION,
- PEGASUS_GIT_COMMIT,
- PEGASUS_BUILD_TYPE);
- dsn_exit(0);
- }
- }
- LOG_INFO("pegasus server starting, pid({}), version({})", getpid(),
pegasus_server_rcsid());
- dsn_app_registration_pegasus();
+ // Register collector service.
+
dsn::service_app::register_factory<pegasus::server::info_collector_app>("collector");
- std::unique_ptr<command_deregister> server_info_cmd =
- dsn::command_manager::instance().register_single_command(
- "server-info",
- "Query server information",
- "",
- [](const std::vector<std::string> &args) {
- nlohmann::json info;
- info["version"] = PEGASUS_VERSION;
- info["build_type"] = PEGASUS_BUILD_TYPE;
- info["git_SHA"] = PEGASUS_GIT_COMMIT;
- info["start_time"] =
-
::dsn::utils::time_s_to_date_time(dsn::utils::process_start_millis() / 1000);
- return info.dump();
- });
+ auto server_info_cmd = register_server_info_cmd();
dsn_run(argc, argv, true);
diff --git a/src/sample/CMakeLists.txt b/src/server/meta_server/CMakeLists.txt
similarity index 74%
copy from src/sample/CMakeLists.txt
copy to src/server/meta_server/CMakeLists.txt
index b0618dfca..51ec44ca6 100644
--- a/src/sample/CMakeLists.txt
+++ b/src/server/meta_server/CMakeLists.txt
@@ -15,17 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "sample")
+set(MY_PROJ_NAME "pegasus_meta_server")
+set(MY_PROJ_SRC ${META_SERVER_SRC})
set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS
- pegasus_client_static
- )
-
-set(MY_BOOST_LIBS Boost::filesystem Boost::system)
-
-set(MY_BINPLACES config.ini run.sh)
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../")
+set(MY_PROJ_LIBS ${META_SERVER_LIBS})
+set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+SET(CMAKE_INSTALL_RPATH ".")
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
dsn_add_executable()
dsn_install_executable()
diff --git a/src/shell/commands/misc.cpp b/src/server/meta_server/main.cpp
similarity index 51%
copy from src/shell/commands/misc.cpp
copy to src/server/meta_server/main.cpp
index 4d5cec745..92cfb5f5d 100644
--- a/src/shell/commands/misc.cpp
+++ b/src/server/meta_server/main.cpp
@@ -17,27 +17,35 @@
* under the License.
*/
-#include <iostream>
-#include <string>
+#include <unistd.h>
+#include <memory>
-#include "pegasus/git_commit.h"
-#include "pegasus/version.h"
+#include "meta/meta_service_app.h"
+#include "pegasus_service_app.h"
#include "runtime/app_model.h"
-#include "shell/command_executor.h"
-#include "shell/command_helper.h"
-#include "shell/commands.h"
+#include "runtime/service_app.h"
+#include "server/server_utils.h"
+#include "utils/fmt_logging.h"
-bool version(command_executor *e, shell_context *sc, arguments args)
-{
- std::ostringstream oss;
- oss << "Pegasus Shell " << PEGASUS_VERSION << " (" << PEGASUS_GIT_COMMIT
<< ") "
- << PEGASUS_BUILD_TYPE;
- std::cout << oss.str() << std::endl;
- return true;
-}
+namespace dsn {
+class command_deregister;
+} // namespace dsn
-bool exit_shell(command_executor *e, shell_context *sc, arguments args)
+int main(int argc, char **argv)
{
- dsn_exit(0);
- return true;
+ static const char server_name[] = "Meta server";
+ if (help(argc, argv, server_name)) {
+ dsn_exit(0);
+ }
+ LOG_INFO("{} starting, pid({}), version({})", server_name, getpid(),
pegasus_server_rcsid());
+
+ // Register meta service.
+ dsn::service::meta_service_app::register_components();
+
dsn::service_app::register_factory<pegasus::server::pegasus_meta_service_app>("meta");
+
+ auto server_info_cmd = register_server_info_cmd();
+
+ dsn_run(argc, argv, true);
+
+ return 0;
}
diff --git a/src/sample/CMakeLists.txt
b/src/server/replica_server/CMakeLists.txt
similarity index 74%
copy from src/sample/CMakeLists.txt
copy to src/server/replica_server/CMakeLists.txt
index b0618dfca..52e1b13f4 100644
--- a/src/sample/CMakeLists.txt
+++ b/src/server/replica_server/CMakeLists.txt
@@ -15,17 +15,15 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "sample")
+set(MY_PROJ_NAME "pegasus_replica_server")
+set(MY_PROJ_SRC ${REPLICA_SERVER_SRC})
set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS
- pegasus_client_static
- )
-
-set(MY_BOOST_LIBS Boost::filesystem Boost::system)
-
-set(MY_BINPLACES config.ini run.sh)
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../")
+set(MY_PROJ_LIBS ${REPLICA_SERVER_LIBS})
+set(MY_BOOST_LIBS Boost::system Boost::filesystem)
+SET(CMAKE_INSTALL_RPATH ".")
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
dsn_add_executable()
dsn_install_executable()
diff --git a/src/server/replica_server/main.cpp
b/src/server/replica_server/main.cpp
new file mode 100644
index 000000000..ad355692e
--- /dev/null
+++ b/src/server/replica_server/main.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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 <unistd.h>
+#include <memory>
+#include <string>
+
+#include "common/replication_common.h"
+#include "compaction_operation.h"
+#include "pegasus_server_impl.h"
+#include "pegasus_service_app.h"
+#include "runtime/app_model.h"
+#include "runtime/service_app.h"
+#include "server/server_utils.h"
+#include "utils/fmt_logging.h"
+
+namespace dsn {
+class command_deregister;
+} // namespace dsn
+
+int main(int argc, char **argv)
+{
+ static const char server_name[] = "Replica server";
+ if (help(argc, argv, server_name)) {
+ dsn_exit(0);
+ }
+ LOG_INFO("{} starting, pid({}), version({})", server_name, getpid(),
pegasus_server_rcsid());
+
+ // Register replica service.
+
dsn::service_app::register_factory<pegasus::server::pegasus_replication_service_app>(
+ dsn::replication::replication_options::kReplicaAppType.c_str());
+ pegasus::server::pegasus_server_impl::register_service();
+ pegasus::server::register_compaction_operations();
+
+ auto server_info_cmd = register_server_info_cmd();
+
+ dsn_run(argc, argv, true);
+
+ return 0;
+}
diff --git a/src/server/server_utils.cpp b/src/server/server_utils.cpp
new file mode 100644
index 000000000..002e467fa
--- /dev/null
+++ b/src/server/server_utils.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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 <fmt/core.h>
+#include <nlohmann/json.hpp>
+#include <nlohmann/json_fwd.hpp>
+#include <stdio.h>
+#include <map>
+#include <string>
+#include <vector>
+
+#include "pegasus/git_commit.h"
+#include "pegasus/version.h"
+#include "server/server_utils.h"
+#include "utils/command_manager.h"
+#include "utils/process_utils.h"
+#include "utils/strings.h"
+#include "utils/time_utils.h"
+
+using namespace dsn;
+
+bool help(int argc, char **argv, const char *app_name)
+{
+ for (int i = 1; i < argc; ++i) {
+ if (utils::equals(argv[i], "-v") || utils::equals(argv[i], "-version")
||
+ utils::equals(argv[i], "--version")) {
+ fmt::print(stdout,
+ "{} {} ({}) {}\n",
+ app_name,
+ PEGASUS_VERSION,
+ PEGASUS_GIT_COMMIT,
+ PEGASUS_BUILD_TYPE);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+std::unique_ptr<command_deregister> register_server_info_cmd()
+{
+ return dsn::command_manager::instance().register_single_command(
+ "server-info", "Query server information", "", [](const
std::vector<std::string> &args) {
+ nlohmann::json info;
+ info["version"] = PEGASUS_VERSION;
+ info["build_type"] = PEGASUS_BUILD_TYPE;
+ info["git_SHA"] = PEGASUS_GIT_COMMIT;
+ info["start_time"] =
+
::dsn::utils::time_s_to_date_time(dsn::utils::process_start_millis() / 1000);
+ return info.dump();
+ });
+}
+
+static char const rcsid[] = "$Version: Pegasus Server " PEGASUS_VERSION " ("
PEGASUS_GIT_COMMIT ")"
+#if defined(DSN_BUILD_TYPE)
+ " " STRINGIFY(DSN_BUILD_TYPE)
+#endif
+ ", built by gcc " STRINGIFY(__GNUC__) "."
STRINGIFY(
+ __GNUC_MINOR__) "."
STRINGIFY(__GNUC_PATCHLEVEL__)
+#if defined(DSN_BUILD_HOSTNAME)
+ ", built on " STRINGIFY(DSN_BUILD_HOSTNAME)
+#endif
+ ", built at " __DATE__ " " __TIME__ "
$";
+
+const char *pegasus_server_rcsid() { return rcsid; }
diff --git a/src/shell/commands/misc.cpp b/src/server/server_utils.h
similarity index 57%
copy from src/shell/commands/misc.cpp
copy to src/server/server_utils.h
index 4d5cec745..f8b75183f 100644
--- a/src/shell/commands/misc.cpp
+++ b/src/server/server_utils.h
@@ -17,27 +17,24 @@
* under the License.
*/
-#include <iostream>
-#include <string>
-
-#include "pegasus/git_commit.h"
-#include "pegasus/version.h"
-#include "runtime/app_model.h"
-#include "shell/command_executor.h"
-#include "shell/command_helper.h"
-#include "shell/commands.h"
-
-bool version(command_executor *e, shell_context *sc, arguments args)
-{
- std::ostringstream oss;
- oss << "Pegasus Shell " << PEGASUS_VERSION << " (" << PEGASUS_GIT_COMMIT
<< ") "
- << PEGASUS_BUILD_TYPE;
- std::cout << oss.str() << std::endl;
- return true;
-}
+#pragma once
+
+#include <memory>
+
+#include "utils/macros.h"
+
+#ifndef DSN_BUILD_TYPE
+#define PEGASUS_BUILD_TYPE ""
+#else
+#define PEGASUS_BUILD_TYPE STRINGIFY(DSN_BUILD_TYPE)
+#endif
-bool exit_shell(command_executor *e, shell_context *sc, arguments args)
-{
- dsn_exit(0);
- return true;
+namespace dsn {
+class command_deregister;
}
+
+bool help(int argc, char **argv, const char *app_name);
+
+std::unique_ptr<dsn::command_deregister> register_server_info_cmd();
+
+const char *pegasus_server_rcsid();
diff --git a/src/shell/command_helper.h b/src/shell/command_helper.h
index 70fc62119..e4e16f621 100644
--- a/src/shell/command_helper.h
+++ b/src/shell/command_helper.h
@@ -66,14 +66,6 @@
using namespace dsn::replication;
-#define STR_I(var) #var
-#define STR(var) STR_I(var)
-#ifndef DSN_BUILD_TYPE
-#define PEGASUS_BUILD_TYPE ""
-#else
-#define PEGASUS_BUILD_TYPE STR(DSN_BUILD_TYPE)
-#endif
-
DEFINE_TASK_CODE(LPC_SCAN_DATA, TASK_PRIORITY_COMMON,
::dsn::THREAD_POOL_DEFAULT)
DEFINE_TASK_CODE(LPC_GET_METRICS, TASK_PRIORITY_COMMON,
::dsn::THREAD_POOL_DEFAULT)
diff --git a/src/shell/commands/misc.cpp b/src/shell/commands/misc.cpp
index 4d5cec745..e45b1442e 100644
--- a/src/shell/commands/misc.cpp
+++ b/src/shell/commands/misc.cpp
@@ -23,8 +23,8 @@
#include "pegasus/git_commit.h"
#include "pegasus/version.h"
#include "runtime/app_model.h"
+#include "server/server_utils.h"
#include "shell/command_executor.h"
-#include "shell/command_helper.h"
#include "shell/commands.h"
bool version(command_executor *e, shell_context *sc, arguments args)
diff --git a/src/test/function_test/backup_restore/CMakeLists.txt
b/src/test/function_test/backup_restore/CMakeLists.txt
index 41a6c6ed2..c35974f27 100644
--- a/src/test/function_test/backup_restore/CMakeLists.txt
+++ b/src/test/function_test/backup_restore/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "backup_restore_test")
+set(MY_PROJ_NAME backup_restore_test)
project(${MY_PROJ_NAME} C CXX)
set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
@@ -30,7 +30,11 @@ set(MY_PROJ_LIBS
krb5
function_test_utils
pegasus_client_static
- test_utils)
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/base_api/CMakeLists.txt
b/src/test/function_test/base_api/CMakeLists.txt
index 3e688f3a1..149abaa59 100644
--- a/src/test/function_test/base_api/CMakeLists.txt
+++ b/src/test/function_test/base_api/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "base_api_test")
+set(MY_PROJ_NAME base_api_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -28,17 +28,20 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- dsn_client
- dsn_replication_common
- dsn_utils
- pegasus_client_static
- gtest
- sasl2
- gssapi_krb5
- krb5
- function_test_utils
- test_utils
- )
+ dsn_client
+ dsn_replication_common
+ dsn_utils
+ pegasus_client_static
+ gtest
+ sasl2
+ gssapi_krb5
+ krb5
+ function_test_utils
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/detect_hotspot/CMakeLists.txt
b/src/test/function_test/detect_hotspot/CMakeLists.txt
index 8a8070d85..e78150224 100644
--- a/src/test/function_test/detect_hotspot/CMakeLists.txt
+++ b/src/test/function_test/detect_hotspot/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "detect_hotspot_test")
+set(MY_PROJ_NAME detect_hotspot_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -37,7 +37,11 @@ set(MY_PROJ_LIBS
gssapi_krb5
krb5
function_test_utils
- test_utils)
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/partition_split/CMakeLists.txt
b/src/test/function_test/partition_split/CMakeLists.txt
index b2cff9f60..ba4f0ca40 100644
--- a/src/test/function_test/partition_split/CMakeLists.txt
+++ b/src/test/function_test/partition_split/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "partition_split_test")
+set(MY_PROJ_NAME partition_split_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -28,17 +28,20 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- dsn_client
- dsn_replication_common
- dsn_utils
- pegasus_client_static
- gtest
- sasl2
- gssapi_krb5
- krb5
- function_test_utils
- test_utils
- )
+ dsn_client
+ dsn_replication_common
+ dsn_utils
+ pegasus_client_static
+ gtest
+ sasl2
+ gssapi_krb5
+ krb5
+ function_test_utils
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/recovery/CMakeLists.txt
b/src/test/function_test/recovery/CMakeLists.txt
index a13d12734..491bd68b5 100644
--- a/src/test/function_test/recovery/CMakeLists.txt
+++ b/src/test/function_test/recovery/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "recovery_test")
+set(MY_PROJ_NAME recovery_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -37,7 +37,11 @@ set(MY_PROJ_LIBS
gssapi_krb5
krb5
function_test_utils
- test_utils)
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/restore/CMakeLists.txt
b/src/test/function_test/restore/CMakeLists.txt
index 18b0ad444..3a96d13ac 100644
--- a/src/test/function_test/restore/CMakeLists.txt
+++ b/src/test/function_test/restore/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "restore_test")
+set(MY_PROJ_NAME restore_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -37,7 +37,11 @@ set(MY_PROJ_LIBS
krb5
function_test_utils
pegasus_client_static
- test_utils)
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/function_test/throttle/CMakeLists.txt
b/src/test/function_test/throttle/CMakeLists.txt
index 70460d0c5..5b7884f78 100644
--- a/src/test/function_test/throttle/CMakeLists.txt
+++ b/src/test/function_test/throttle/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "throttle_test")
+set(MY_PROJ_NAME throttle_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -28,17 +28,20 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- dsn_client
- dsn_replication_common
- dsn_utils
- pegasus_client_static
- gtest
- sasl2
- gssapi_krb5
- krb5
- function_test_utils
- test_utils
- )
+ dsn_client
+ dsn_replication_common
+ dsn_utils
+ pegasus_client_static
+ gtest
+ sasl2
+ gssapi_krb5
+ krb5
+ function_test_utils
+ test_utils
+ rocksdb
+ lz4
+ zstd
+ snappy)
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/kill_test/CMakeLists.txt
b/src/test/kill_test/CMakeLists.txt
index df9744873..23b859079 100644
--- a/src/test/kill_test/CMakeLists.txt
+++ b/src/test/kill_test/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "pegasus_kill_test")
+set(MY_PROJ_NAME pegasus_kill_test)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -28,17 +28,20 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- pegasus_base
- pegasus_client_static
- dsn_client
- dsn_replication_common
- dsn_dist_cmd
- dsn_runtime
- dsn_utils
- sasl2
- gssapi_krb5
- krb5
- )
+ pegasus_base
+ pegasus_client_static
+ dsn_client
+ dsn_replication_common
+ dsn_dist_cmd
+ dsn_runtime
+ dsn_utils
+ rocksdb
+ lz4
+ zstd
+ snappy
+ sasl2
+ gssapi_krb5
+ krb5)
set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")
set(MY_BOOST_LIBS Boost::system Boost::filesystem)
diff --git a/src/test/pressure_test/CMakeLists.txt
b/src/test/pressure_test/CMakeLists.txt
index 42e29b736..8b63bc2c4 100644
--- a/src/test/pressure_test/CMakeLists.txt
+++ b/src/test/pressure_test/CMakeLists.txt
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-set(MY_PROJ_NAME "pegasus_pressureclient")
+set(MY_PROJ_NAME pegasus_pressureclient)
project(${MY_PROJ_NAME} C CXX)
# Source files under CURRENT project directory will be automatically included.
@@ -28,12 +28,16 @@ set(MY_PROJ_SRC "")
set(MY_SRC_SEARCH_MODE "GLOB")
set(MY_PROJ_LIBS
- pegasus_client_static
- dsn_utils
- sasl2
- gssapi_krb5
- krb5
- )
+ pegasus_client_static
+ dsn_utils
+ sasl2
+ gssapi_krb5
+ krb5
+ rocksdb
+ lz4
+ zstd
+ snappy
+ dsn_utils)
set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-pressure.ini")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]