This is an automated email from the ASF dual-hosted git repository.

wangdan 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 43aa01646 refactor(ranger): move ranger out of runtime (#1808)
43aa01646 is described below

commit 43aa016462540afa5b7ba6c309769d87519f4ad8
Author: Yingchun Lai <[email protected]>
AuthorDate: Fri Dec 29 19:44:02 2023 +0800

    refactor(ranger): move ranger out of runtime (#1808)
    
    This is a pure refactor patch without any function changes.
    The patch is aim to reduce the size and dependencies of runtime library,
    mainly move the "ranger" out of "runtime", including:
    - Add a test named "dsn_ranger_tests"
    - Move src/runtime/test/test_utils.h to src/runtime/test_utils.h so the
      other tests out of "runtime" is able to inlcude it easily
    - Remove duplicate comments from **/CMakeLists.txt
    - Move concat_path_unix_style() from meta_options to filesystem where is
      more reasonable, and  also reduce some unnecessary couple
    - Make supported_mechanisms as a static member variable of negotiation
      class instead of a global variable which is more modernized
---
 .github/workflows/lint_and_test_cpp.yaml           |  3 ++
 .licenserc.yaml                                    |  2 +-
 src/CMakeLists.txt                                 |  1 +
 src/aio/test/CMakeLists.txt                        | 26 ++++---------
 src/common/json_helper.h                           |  2 +-
 src/failure_detector/test/CMakeLists.txt           | 26 ++++---------
 src/meta/CMakeLists.txt                            | 14 +------
 src/meta/meta_options.cpp                          | 13 -------
 src/meta/meta_options.h                            |  4 --
 src/meta/meta_service.cpp                          | 11 +++---
 src/meta/test/CMakeLists.txt                       | 23 ++++-------
 src/meta/test/balancer_simulator/CMakeLists.txt    | 22 +++--------
 src/meta/test/meta_bulk_load_service_test.cpp      |  4 +-
 src/meta/test/meta_partition_guardian_test.cpp     |  5 ++-
 src/meta/test/meta_state/CMakeLists.txt            | 37 ++++++------------
 src/meta/test/meta_test_base.cpp                   |  4 +-
 src/meta/test/update_configuration_test.cpp        |  8 ++--
 src/perf_counter/test/CMakeLists.txt               | 24 +++---------
 src/{runtime => }/ranger/CMakeLists.txt            |  6 +--
 src/{runtime => }/ranger/access_type.h             | 12 ++++--
 .../ranger/ranger_resource_policy.cpp              |  2 +-
 src/{runtime => }/ranger/ranger_resource_policy.h  |  0
 .../ranger/ranger_resource_policy_manager.cpp      |  8 ++--
 .../ranger/ranger_resource_policy_manager.h        |  2 +-
 src/{runtime/ranger => ranger/test}/CMakeLists.txt | 14 ++++---
 .../access_type.cpp => ranger/test/main.cpp}       | 20 +++-------
 .../test/ranger_resource_policy_manager_test.cpp   |  6 +--
 .../test/ranger_resource_policy_test.cpp           |  4 +-
 .../ranger/CMakeLists.txt => ranger/test/run.sh}   | 15 ++++----
 src/replica/backup/test/CMakeLists.txt             | 13 ++-----
 src/replica/bulk_load/test/CMakeLists.txt          | 13 ++-----
 src/replica/duplication/test/CMakeLists.txt        | 13 ++-----
 src/replica/replica.h                              |  2 +-
 src/replica/replica_2pc.cpp                        |  2 +-
 src/replica/replica_stub.cpp                       |  2 +-
 src/replica/replica_stub.h                         |  2 +-
 src/replica/split/test/CMakeLists.txt              | 16 +++-----
 src/replica/storage/simple_kv/CMakeLists.txt       | 22 ++---------
 src/replica/storage/simple_kv/test/CMakeLists.txt  | 21 +++--------
 src/replica/test/CMakeLists.txt                    | 17 +++------
 src/runtime/CMakeLists.txt                         |  5 +--
 src/runtime/security/access_controller.h           |  2 +-
 src/runtime/security/client_negotiation.cpp        |  7 ++--
 src/runtime/security/meta_access_controller.cpp    |  4 +-
 src/runtime/security/negotiation.cpp               |  5 +--
 src/runtime/security/negotiation.h                 |  5 +++
 src/runtime/security/replica_access_controller.h   |  4 +-
 src/runtime/security/server_negotiation.cpp        |  7 ++--
 src/runtime/security/server_negotiation.h          |  2 -
 src/runtime/test/CMakeLists.txt                    | 32 ++++++----------
 src/runtime/test/async_call.cpp                    |  5 ++-
 src/runtime/test/corrupt_message.cpp               |  2 +-
 src/runtime/test/host_port_test.cpp                |  2 +-
 src/runtime/test/lpc.cpp                           |  2 +-
 src/runtime/test/main.cpp                          |  2 +-
 src/runtime/test/netprovider.cpp                   |  2 +-
 .../test/replica_access_controller_test.cpp        |  2 +-
 src/runtime/test/rpc.cpp                           |  2 +-
 src/runtime/test/task_engine.cpp                   |  2 +-
 src/runtime/{test => }/test_utils.h                |  0
 src/server/CMakeLists.txt                          | 19 ++--------
 src/server/test/CMakeLists.txt                     | 44 ++++++++++------------
 src/shell/CMakeLists.txt                           | 23 ++++-------
 src/utils/filesystem.cpp                           | 11 ++++++
 src/utils/filesystem.h                             |  2 +
 65 files changed, 239 insertions(+), 395 deletions(-)

diff --git a/.github/workflows/lint_and_test_cpp.yaml 
b/.github/workflows/lint_and_test_cpp.yaml
index f90a18074..324bf00c6 100644
--- a/.github/workflows/lint_and_test_cpp.yaml
+++ b/.github/workflows/lint_and_test_cpp.yaml
@@ -128,6 +128,7 @@ jobs:
           # TODO(wangdan): Since builtin_counters (memused.virt and 
memused.res) for perf-counters
           # have been removed and dsn_perf_counter_test depends on them, 
disable it.
           # - dsn_perf_counter_test
+          - dsn_ranger_tests
           - dsn_replica_backup_test
           - dsn_replica_bulk_load_test
           - dsn_replica_dup_test
@@ -202,6 +203,7 @@ jobs:
           # TODO(wangdan): Since builtin_counters (memused.virt and 
memused.res) for perf-counters
           # have been removed and dsn_perf_counter_test depends on them, 
disable it.
           # - dsn_perf_counter_test
+          - dsn_ranger_tests
           - dsn_replica_backup_test
           - dsn_replica_bulk_load_test
           - dsn_replica_dup_test
@@ -281,6 +283,7 @@ jobs:
 #          # TODO(wangdan): Since builtin_counters (memused.virt and 
memused.res) for perf-counters
 #          # have been removed and dsn_perf_counter_test depends on them, 
disable it.
 #          # - dsn_perf_counter_test
+#          - dsn_ranger_tests
 #          - dsn_replica_backup_test
 #          - dsn_replica_bulk_load_test
 #          - dsn_replica_dup_test
diff --git a/.licenserc.yaml b/.licenserc.yaml
index 1c5804759..9f7aa61c2 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -594,7 +594,7 @@ header:
     - 'src/runtime/test/service_api_c.cpp'
     - 'src/runtime/test/sim_lock.cpp'
     - 'src/runtime/test/task_engine.cpp'
-    - 'src/runtime/test/test_utils.h'
+    - 'src/runtime/test_utils.h'
     - 'src/runtime/threadpool_code.cpp'
     - 'src/runtime/tool_api.cpp'
     - 'src/runtime/tracer.cpp'
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 00b8a0914..253cb6cf6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -45,6 +45,7 @@ add_subdirectory(http)
 add_subdirectory(meta)
 add_subdirectory(nfs)
 add_subdirectory(perf_counter)
+add_subdirectory(ranger)
 add_subdirectory(redis_protocol)
 add_subdirectory(remote_cmd)
 add_subdirectory(replica)
diff --git a/src/aio/test/CMakeLists.txt b/src/aio/test/CMakeLists.txt
index 2eb437146..cbc853d83 100644
--- a/src/aio/test/CMakeLists.txt
+++ b/src/aio/test/CMakeLists.txt
@@ -23,36 +23,24 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn_aio_test)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC "")
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
+        dsn_runtime
         dsn_meta_server
+        dsn_ranger
         dsn_replication_common
-        gtest
-        dsn_runtime
         dsn_aio
         test_utils
+        gtest
         rocksdb
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES
-    "${CMAKE_CURRENT_SOURCE_DIR}/config.ini"
-    "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
-    "${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
-    "${CMAKE_CURRENT_SOURCE_DIR}/copy_source.txt"
-)
-
+        config.ini
+        clear.sh
+        run.sh
+        copy_source.txt)
 dsn_add_test()
diff --git a/src/common/json_helper.h b/src/common/json_helper.h
index 39c1ad1be..291909bc8 100644
--- a/src/common/json_helper.h
+++ b/src/common/json_helper.h
@@ -59,7 +59,7 @@
 #include "consensus_types.h"
 #include "replica_admin_types.h"
 #include "common/replication_enums.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 
 #define JSON_ENCODE_ENTRY(out, prefix, T)                                      
                    \
     out.Key(#T);                                                               
                    \
diff --git a/src/failure_detector/test/CMakeLists.txt 
b/src/failure_detector/test/CMakeLists.txt
index 5b5a6832a..54907d6ee 100644
--- a/src/failure_detector/test/CMakeLists.txt
+++ b/src/failure_detector/test/CMakeLists.txt
@@ -23,19 +23,12 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn.failure_detector.tests)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC "")
-
-#  Search mode for source files under CURRENT project directory?
-#  "GLOB_RECURSE" for recursive search
-#  "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn_runtime
         dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn_replication_common
         dsn.failure_detector
@@ -45,17 +38,12 @@ set(MY_PROJ_LIBS
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES
-    "${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
-    "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
-    "${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini"
-    "${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test.ini"
-    "${CMAKE_CURRENT_SOURCE_DIR}/config-whitelist-test-failed.ini"
-    "${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter"
-)
-
+        run.sh
+        clear.sh
+        config-test.ini
+        config-whitelist-test.ini
+        config-whitelist-test-failed.ini
+        gtest.filter)
 dsn_add_test()
diff --git a/src/meta/CMakeLists.txt b/src/meta/CMakeLists.txt
index a52a607f6..95ecb3b9a 100644
--- a/src/meta/CMakeLists.txt
+++ b/src/meta/CMakeLists.txt
@@ -23,17 +23,12 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn_meta_server)
-
 set(DUPLICATION_SRC
         duplication/duplication_info.cpp
-        duplication/meta_duplication_service.cpp
-        )
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
+        duplication/meta_duplication_service.cpp)
 set(MY_PROJ_SRC "${DUPLICATION_SRC}")
-
 set(MY_PROJ_LIBS
+        dsn_ranger
         dsn_replication_common
         dsn.block_service
         dsn.block_service.local
@@ -51,12 +46,7 @@ set(MY_PROJ_LIBS
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES "")
-
 dsn_add_shared_library()
-
 add_subdirectory(test)
diff --git a/src/meta/meta_options.cpp b/src/meta/meta_options.cpp
index 7956ff35e..cb1e770be 100644
--- a/src/meta/meta_options.cpp
+++ b/src/meta/meta_options.cpp
@@ -26,7 +26,6 @@
 
 #include "meta_options.h"
 
-#include <stddef.h>
 #include <map>
 #include <utility>
 
@@ -55,18 +54,6 @@ DSN_DEFINE_string(meta_server,
                   "",
                   "white list of replica-servers in meta-server");
 
-std::string meta_options::concat_path_unix_style(const std::string &prefix,
-                                                 const std::string &postfix)
-{
-    size_t pos1 = prefix.size(); // last_valid_pos + 1
-    while (pos1 > 0 && prefix[pos1 - 1] == '/')
-        pos1--;
-    size_t pos2 = 0; // first non '/' position
-    while (pos2 < postfix.size() && postfix[pos2] == '/')
-        pos2++;
-    return prefix.substr(0, pos1) + "/" + postfix.substr(pos2);
-}
-
 void meta_options::initialize()
 {
     utils::split_args(FLAGS_meta_state_service_parameters, 
meta_state_service_args);
diff --git a/src/meta/meta_options.h b/src/meta/meta_options.h
index f33d83174..ffda22eae 100644
--- a/src/meta/meta_options.h
+++ b/src/meta/meta_options.h
@@ -54,10 +54,6 @@ public:
 
 public:
     void initialize();
-
-public:
-    static std::string concat_path_unix_style(const std::string &prefix,
-                                              const std::string &postfix);
 };
 } // namespace replication
 } // namespace dsn
diff --git a/src/meta/meta_service.cpp b/src/meta/meta_service.cpp
index c35e3be99..0acd4890a 100644
--- a/src/meta/meta_service.cpp
+++ b/src/meta/meta_service.cpp
@@ -56,7 +56,7 @@
 #include "meta_split_service.h"
 #include "partition_split_types.h"
 #include "remote_cmd/remote_command.h"
-#include "runtime/ranger/ranger_resource_policy_manager.h"
+#include "ranger/ranger_resource_policy_manager.h"
 #include "runtime/rpc/rpc_holder.h"
 #include "runtime/task/async_calls.h"
 #include "server_load_balancer.h"
@@ -64,6 +64,7 @@
 #include "utils/autoref_ptr.h"
 #include "utils/command_manager.h"
 #include "utils/factory_store.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
 #include "utils/string_conv.h"
@@ -224,7 +225,7 @@ error_code meta_service::remote_storage_initialize()
     utils::split_args(FLAGS_cluster_root, slices, '/');
     std::string current = "";
     for (unsigned int i = 0; i != slices.size(); ++i) {
-        current = meta_options::concat_path_unix_style(current, slices[i]);
+        current = utils::filesystem::concat_path_unix_style(current, 
slices[i]);
         task_ptr tsk =
             _storage->create_node(current, LPC_META_CALLBACK, 
[&err](error_code ec) { err = ec; });
         tsk->wait();
@@ -445,16 +446,16 @@ error_code meta_service::start()
         LOG_INFO("initialize backup handler");
         _backup_handler = std::make_shared<backup_service>(
             this,
-            meta_options::concat_path_unix_style(_cluster_root, "backup"),
+            utils::filesystem::concat_path_unix_style(_cluster_root, "backup"),
             FLAGS_cold_backup_root,
             [](backup_service *bs) { return 
std::make_shared<policy_context>(bs); });
     }
 
     _bulk_load_svc = std::make_unique<bulk_load_service>(
-        this, meta_options::concat_path_unix_style(_cluster_root, 
"bulk_load"));
+        this, utils::filesystem::concat_path_unix_style(_cluster_root, 
"bulk_load"));
 
     // initialize the server_state
-    _state->initialize(this, 
meta_options::concat_path_unix_style(_cluster_root, "apps"));
+    _state->initialize(this, 
utils::filesystem::concat_path_unix_style(_cluster_root, "apps"));
     while ((err = _state->initialize_data_structure()) != ERR_OK) {
         if (err == ERR_OBJECT_NOT_FOUND && FLAGS_recover_from_replica_server) {
             LOG_INFO("can't find apps from remote storage, and "
diff --git a/src/meta/test/CMakeLists.txt b/src/meta/test/CMakeLists.txt
index 49c9e4994..13a1efe9d 100644
--- a/src/meta/test/CMakeLists.txt
+++ b/src/meta/test/CMakeLists.txt
@@ -23,20 +23,11 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn.meta.test)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 file(GLOB MY_PROJ_SRC
         ${PROJECT_SOURCE_DIR}/src/meta/*.cpp
-        ${PROJECT_SOURCE_DIR}/src/meta/duplication/*.cpp
-        )
+        ${PROJECT_SOURCE_DIR}/src/meta/duplication/*.cpp)
 set(MY_PROJ_SRC ${MY_PROJ_SRC} misc/misc.cpp)
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn.replication.zookeeper_provider
         dsn_replication_common
@@ -47,18 +38,20 @@ set(MY_PROJ_LIBS
         dsn_dist_cmd
         dsn_http
         dsn_meta_server
+        dsn_ranger
         dsn_runtime
         dsn_aio
         zookeeper
         hashtable
         gtest
         hdfs)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
-set(MY_BINPLACES clear.sh run.sh config-test.ini suite1 suite2)
-
+set(MY_BINPLACES
+        clear.sh
+        run.sh
+        config-test.ini
+        suite1
+        suite2)
 dsn_add_test()
 
 add_subdirectory(balancer_simulator)
diff --git a/src/meta/test/balancer_simulator/CMakeLists.txt 
b/src/meta/test/balancer_simulator/CMakeLists.txt
index 7fe9925da..69ddfc4a4 100644
--- a/src/meta/test/balancer_simulator/CMakeLists.txt
+++ b/src/meta/test/balancer_simulator/CMakeLists.txt
@@ -23,26 +23,14 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME sim_lb)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC ../misc/misc.cpp)
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
-    dsn_meta_server
-    dsn_replication_common
-    dsn_runtime
-    hashtable
-    gtest)
-
+        dsn_runtime
+        dsn_meta_server
+        dsn_ranger
+        dsn_replication_common
+        gtest)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES "")
-
 dsn_add_test()
diff --git a/src/meta/test/meta_bulk_load_service_test.cpp 
b/src/meta/test/meta_bulk_load_service_test.cpp
index c83f8cbbb..d3ae38a1e 100644
--- a/src/meta/test/meta_bulk_load_service_test.cpp
+++ b/src/meta/test/meta_bulk_load_service_test.cpp
@@ -41,7 +41,6 @@
 #include "gtest/gtest.h"
 #include "meta/meta_bulk_load_service.h"
 #include "meta/meta_data.h"
-#include "meta/meta_options.h"
 #include "meta/meta_server_failure_detector.h"
 #include "meta/meta_service.h"
 #include "meta/meta_state_service_utils.h"
@@ -54,6 +53,7 @@
 #include "utils/blob.h"
 #include "utils/error_code.h"
 #include "utils/fail_point.h"
+#include "utils/filesystem.h"
 #include "utils/fmt_logging.h"
 
 namespace dsn {
@@ -344,7 +344,7 @@ public:
 
         // initialize bulk load service
         _ms->_bulk_load_svc = std::make_unique<bulk_load_service>(
-            _ms.get(), 
meta_options::concat_path_unix_style(_ms->_cluster_root, "bulk_load"));
+            _ms.get(), 
utils::filesystem::concat_path_unix_style(_ms->_cluster_root, "bulk_load"));
         mock_bulk_load_on_remote_storage(
             app_id_set, app_bulk_load_info_map, partition_bulk_load_info_map);
 
diff --git a/src/meta/test/meta_partition_guardian_test.cpp 
b/src/meta/test/meta_partition_guardian_test.cpp
index 403dcb3fe..e4f62f1fb 100644
--- a/src/meta/test/meta_partition_guardian_test.cpp
+++ b/src/meta/test/meta_partition_guardian_test.cpp
@@ -45,7 +45,6 @@
 #include "gtest/gtest.h"
 #include "meta/greedy_load_balancer.h"
 #include "meta/meta_data.h"
-#include "meta/meta_options.h"
 #include "meta/meta_server_failure_detector.h"
 #include "meta/meta_service.h"
 #include "meta/partition_guardian.h"
@@ -62,6 +61,7 @@
 #include "runtime/task/task.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
+#include "utils/filesystem.h"
 
 namespace dsn {
 namespace replication {
@@ -179,7 +179,8 @@ void meta_partition_guardian_test::cure_test()
     svc->_balancer.reset(new dummy_balancer(svc.get()));
 
     server_state *state = svc->_state.get();
-    state->initialize(svc.get(), 
meta_options::concat_path_unix_style(svc->_cluster_root, "apps"));
+    state->initialize(svc.get(),
+                      
utils::filesystem::concat_path_unix_style(svc->_cluster_root, "apps"));
     dsn::app_info info;
     info.is_stateful = true;
     info.status = dsn::app_status::AS_CREATING;
diff --git a/src/meta/test/meta_state/CMakeLists.txt 
b/src/meta/test/meta_state/CMakeLists.txt
index 9f480e780..dbb7be2eb 100644
--- a/src/meta/test/meta_state/CMakeLists.txt
+++ b/src/meta/test/meta_state/CMakeLists.txt
@@ -23,33 +23,20 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn_meta_state_tests)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC "")
-
-#  Search mode for source files under CURRENT project directory?
-#  "GLOB_RECURSE" for recursive search
-#  "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS 
-    dsn_meta_server
-    dsn_replica_server
-    dsn_replication_common
-    dsn_runtime
-    hashtable
-    gtest
-    )
-
+set(MY_PROJ_LIBS
+        dsn_meta_server
+        dsn_ranger
+        dsn_replica_server
+        dsn_replication_common
+        dsn_runtime
+        hashtable
+        gtest)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES
-    "run.sh"
-    "clear.sh"
-    "config-test.ini"
-    "gtest.filter"
-)
-
+        run.sh
+        clear.sh
+        config-test.ini
+        gtest.filter)
 dsn_add_test()
diff --git a/src/meta/test/meta_test_base.cpp b/src/meta/test/meta_test_base.cpp
index d05d8a145..9b0a86545 100644
--- a/src/meta/test/meta_test_base.cpp
+++ b/src/meta/test/meta_test_base.cpp
@@ -28,7 +28,6 @@
 #include "gtest/gtest.h"
 #include "meta/meta_bulk_load_service.h"
 #include "meta/meta_data.h"
-#include "meta/meta_options.h"
 #include "meta/meta_rpc_types.h"
 #include "meta/meta_server_failure_detector.h"
 #include "meta/meta_service.h"
@@ -44,6 +43,7 @@
 #include "runtime/task/task_tracker.h"
 #include "utils/error_code.h"
 #include "utils/factory_store.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
 #include "utils/zlocks.h"
@@ -71,7 +71,7 @@ void meta_test_base::SetUp()
     _ms->_split_svc = std::make_unique<meta_split_service>(_ms.get());
     ASSERT_TRUE(_ms->_split_svc);
     _ms->_bulk_load_svc = std::make_unique<bulk_load_service>(
-        _ms.get(), meta_options::concat_path_unix_style(_ms->_cluster_root, 
"bulk_load"));
+        _ms.get(), 
utils::filesystem::concat_path_unix_style(_ms->_cluster_root, "bulk_load"));
     ASSERT_TRUE(_ms->_bulk_load_svc);
     _ms->_bulk_load_svc->initialize_bulk_load_service();
 
diff --git a/src/meta/test/update_configuration_test.cpp 
b/src/meta/test/update_configuration_test.cpp
index d80b32a3e..2c23d231c 100644
--- a/src/meta/test/update_configuration_test.cpp
+++ b/src/meta/test/update_configuration_test.cpp
@@ -45,7 +45,6 @@
 #include "gtest/gtest.h"
 #include "meta/greedy_load_balancer.h"
 #include "meta/meta_data.h"
-#include "meta/meta_options.h"
 #include "meta/meta_server_failure_detector.h"
 #include "meta/meta_service.h"
 #include "meta/partition_guardian.h"
@@ -63,6 +62,7 @@
 #include "runtime/task/task.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
 #include "utils/zlocks.h"
@@ -224,7 +224,8 @@ void meta_service_test_app::update_configuration_test()
     svc->_balancer.reset(new dummy_balancer(svc.get()));
 
     server_state *ss = svc->_state.get();
-    ss->initialize(svc.get(), 
meta_options::concat_path_unix_style(svc->_cluster_root, "apps"));
+    ss->initialize(svc.get(),
+                   
utils::filesystem::concat_path_unix_style(svc->_cluster_root, "apps"));
     dsn::app_info info;
     info.is_stateful = true;
     info.status = dsn::app_status::AS_CREATING;
@@ -303,7 +304,8 @@ void meta_service_test_app::adjust_dropped_size()
     svc->_balancer.reset(new dummy_balancer(svc.get()));
 
     server_state *ss = svc->_state.get();
-    ss->initialize(svc.get(), 
meta_options::concat_path_unix_style(svc->_cluster_root, "apps"));
+    ss->initialize(svc.get(),
+                   
utils::filesystem::concat_path_unix_style(svc->_cluster_root, "apps"));
     dsn::app_info info;
     info.is_stateful = true;
     info.status = dsn::app_status::AS_CREATING;
diff --git a/src/perf_counter/test/CMakeLists.txt 
b/src/perf_counter/test/CMakeLists.txt
index f924437de..1b1a8d229 100644
--- a/src/perf_counter/test/CMakeLists.txt
+++ b/src/perf_counter/test/CMakeLists.txt
@@ -23,32 +23,20 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn_perf_counter_test)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC "")
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
+        dsn_runtime
         dsn_meta_server
+        dsn_ranger
         dsn_replication_common
-        gtest
-        dsn_runtime
         rocksdb
         lz4
         zstd
-        snappy)
-
+        snappy
+        gtest)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 set(MY_BINPLACES
-    "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
-    "${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
-)
-
+        clear.sh
+        run.sh)
 dsn_add_test()
diff --git a/src/runtime/ranger/CMakeLists.txt b/src/ranger/CMakeLists.txt
similarity index 92%
copy from src/runtime/ranger/CMakeLists.txt
copy to src/ranger/CMakeLists.txt
index fbbceb570..79b489609 100644
--- a/src/runtime/ranger/CMakeLists.txt
+++ b/src/ranger/CMakeLists.txt
@@ -16,11 +16,11 @@
 # under the License.
 
 set(MY_PROJ_NAME dsn_ranger)
-
 set(MY_PROJ_SRC "")
 set(MY_SRC_SEARCH_MODE "GLOB")
 set(MY_PROJ_LIBS
         dsn_meta_server
-        dsn_replication_common)
-
+        dsn_replication_common
+        dsn_utils)
 dsn_add_static_library()
+add_subdirectory(test)
diff --git a/src/runtime/ranger/access_type.h b/src/ranger/access_type.h
similarity index 83%
rename from src/runtime/ranger/access_type.h
rename to src/ranger/access_type.h
index b28795b65..74dae6a1f 100644
--- a/src/runtime/ranger/access_type.h
+++ b/src/ranger/access_type.h
@@ -49,11 +49,17 @@ ENUM_END(access_type)
 
 using act = std::underlying_type<access_type>::type;
 
-access_type operator|(access_type lhs, access_type rhs);
+inline access_type operator|(access_type lhs, access_type rhs)
+{
+    return access_type(static_cast<act>(lhs) | static_cast<act>(rhs));
+}
 
-access_type operator&(access_type lhs, access_type rhs);
+inline access_type operator&(access_type lhs, access_type rhs)
+{
+    return access_type(static_cast<act>(lhs) & static_cast<act>(rhs));
+}
 
-access_type &operator|=(access_type &lhs, access_type rhs);
+inline access_type &operator|=(access_type &lhs, access_type rhs) { return lhs 
= lhs | rhs; }
 
 const access_type kAccessTypeNone = access_type::kInvalid;
 const access_type kAccessTypeAll = access_type::kRead | access_type::kWrite | 
access_type::kCreate |
diff --git a/src/runtime/ranger/ranger_resource_policy.cpp 
b/src/ranger/ranger_resource_policy.cpp
similarity index 99%
rename from src/runtime/ranger/ranger_resource_policy.cpp
rename to src/ranger/ranger_resource_policy.cpp
index 2342da754..ae6262be0 100644
--- a/src/runtime/ranger/ranger_resource_policy.cpp
+++ b/src/ranger/ranger_resource_policy.cpp
@@ -17,7 +17,7 @@
 
 #include "ranger_resource_policy.h"
 
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "utils/fmt_logging.h"
 
 namespace dsn {
diff --git a/src/runtime/ranger/ranger_resource_policy.h 
b/src/ranger/ranger_resource_policy.h
similarity index 100%
rename from src/runtime/ranger/ranger_resource_policy.h
rename to src/ranger/ranger_resource_policy.h
diff --git a/src/runtime/ranger/ranger_resource_policy_manager.cpp 
b/src/ranger/ranger_resource_policy_manager.cpp
similarity index 99%
rename from src/runtime/ranger/ranger_resource_policy_manager.cpp
rename to src/ranger/ranger_resource_policy_manager.cpp
index 4bc5ee54f..d9fb6c30d 100644
--- a/src/runtime/ranger/ranger_resource_policy_manager.cpp
+++ b/src/ranger/ranger_resource_policy_manager.cpp
@@ -38,19 +38,19 @@
 #include "common/replication_common.h"
 #include "dsn.layer2_types.h"
 #include "fmt/core.h"
-#include "meta/meta_options.h"
 #include "meta/meta_service.h"
 #include "meta/meta_state_service.h"
 #include "meta/server_state.h"
 #include "meta_admin_types.h"
+#include "ranger/ranger_resource_policy.h"
+#include "ranger/ranger_resource_policy_manager.h"
 #include "ranger_resource_policy_manager.h"
 #include "rapidjson/allocators.h"
-#include "runtime/ranger/ranger_resource_policy.h"
-#include "runtime/ranger/ranger_resource_policy_manager.h"
 #include "runtime/task/async_calls.h"
 #include "runtime/task/task.h"
 #include "runtime/task/task_code.h"
 #include "utils/blob.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
 #include "utils/process_utils.h"
@@ -205,7 +205,7 @@ 
ranger_resource_policy_manager::ranger_resource_policy_manager(
 void ranger_resource_policy_manager::start()
 {
     CHECK_NOTNULL(_meta_svc, "");
-    _ranger_policy_meta_root = 
dsn::replication::meta_options::concat_path_unix_style(
+    _ranger_policy_meta_root = dsn::utils::filesystem::concat_path_unix_style(
         _meta_svc->cluster_root(), "ranger_policy_meta_root");
     tasking::enqueue_timer(LPC_USE_RANGER_ACCESS_CONTROL,
                            &_tracker,
diff --git a/src/runtime/ranger/ranger_resource_policy_manager.h 
b/src/ranger/ranger_resource_policy_manager.h
similarity index 99%
rename from src/runtime/ranger/ranger_resource_policy_manager.h
rename to src/ranger/ranger_resource_policy_manager.h
index 52aeb2c72..974c0fe84 100644
--- a/src/runtime/ranger/ranger_resource_policy_manager.h
+++ b/src/ranger/ranger_resource_policy_manager.h
@@ -27,7 +27,7 @@
 #include "gtest/gtest_prod.h"
 #include "ranger_resource_policy.h"
 #include "rapidjson/document.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/task/task_tracker.h"
 #include "utils/enum_helper.h"
 #include "utils/error_code.h"
diff --git a/src/runtime/ranger/CMakeLists.txt b/src/ranger/test/CMakeLists.txt
similarity index 82%
copy from src/runtime/ranger/CMakeLists.txt
copy to src/ranger/test/CMakeLists.txt
index fbbceb570..443791ff2 100644
--- a/src/runtime/ranger/CMakeLists.txt
+++ b/src/ranger/test/CMakeLists.txt
@@ -15,12 +15,16 @@
 # specific language governing permissions and limitations
 # under the License.
 
-set(MY_PROJ_NAME dsn_ranger)
-
+set(MY_PROJ_NAME dsn_ranger_tests)
 set(MY_PROJ_SRC "")
 set(MY_SRC_SEARCH_MODE "GLOB")
 set(MY_PROJ_LIBS
+        dsn_ranger
+        dsn_runtime
         dsn_meta_server
-        dsn_replication_common)
-
-dsn_add_static_library()
+        dsn_replication_common
+        dsn_utils
+        gtest)
+set(MY_BINPLACES
+        run.sh)
+dsn_add_test()
diff --git a/src/runtime/ranger/access_type.cpp b/src/ranger/test/main.cpp
similarity index 64%
rename from src/runtime/ranger/access_type.cpp
rename to src/ranger/test/main.cpp
index c26ddb71b..8255bf063 100644
--- a/src/runtime/ranger/access_type.cpp
+++ b/src/ranger/test/main.cpp
@@ -15,22 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "access_type.h"
+#include <gtest/gtest.h>
 
-namespace dsn {
-namespace ranger {
+#include "runtime/app_model.h"
 
-access_type operator|(access_type lhs, access_type rhs)
+GTEST_API_ int main(int argc, char **argv)
 {
-    return access_type(static_cast<act>(lhs) | static_cast<act>(rhs));
-}
+    testing::InitGoogleTest(&argc, argv);
 
-access_type operator&(access_type lhs, access_type rhs)
-{
-    return access_type(static_cast<act>(lhs) & static_cast<act>(rhs));
+    int ret = RUN_ALL_TESTS();
+    dsn_exit(ret);
 }
-
-access_type &operator|=(access_type &lhs, access_type rhs) { return lhs = lhs 
| rhs; }
-
-} // namespace ranger
-} // namespace dsn
diff --git a/src/runtime/test/ranger_resource_policy_manager_test.cpp 
b/src/ranger/test/ranger_resource_policy_manager_test.cpp
similarity index 99%
rename from src/runtime/test/ranger_resource_policy_manager_test.cpp
rename to src/ranger/test/ranger_resource_policy_manager_test.cpp
index c17c51dfc..ba355970a 100644
--- a/src/runtime/test/ranger_resource_policy_manager_test.cpp
+++ b/src/ranger/test/ranger_resource_policy_manager_test.cpp
@@ -27,9 +27,9 @@
 
 #include "common/json_helper.h"
 #include "gtest/gtest.h"
-#include "runtime/ranger/access_type.h"
-#include "runtime/ranger/ranger_resource_policy.h"
-#include "runtime/ranger/ranger_resource_policy_manager.h"
+#include "ranger/access_type.h"
+#include "ranger/ranger_resource_policy.h"
+#include "ranger/ranger_resource_policy_manager.h"
 #include "runtime/task/task_code.h"
 #include "utils/blob.h"
 #include "utils/flags.h"
diff --git a/src/runtime/test/ranger_resource_policy_test.cpp 
b/src/ranger/test/ranger_resource_policy_test.cpp
similarity index 99%
rename from src/runtime/test/ranger_resource_policy_test.cpp
rename to src/ranger/test/ranger_resource_policy_test.cpp
index a9025d9bb..ff6199d82 100644
--- a/src/runtime/test/ranger_resource_policy_test.cpp
+++ b/src/ranger/test/ranger_resource_policy_test.cpp
@@ -20,8 +20,8 @@
 #include <vector>
 
 #include "gtest/gtest.h"
-#include "runtime/ranger/access_type.h"
-#include "runtime/ranger/ranger_resource_policy.h"
+#include "ranger/access_type.h"
+#include "ranger/ranger_resource_policy.h"
 
 namespace dsn {
 namespace ranger {
diff --git a/src/runtime/ranger/CMakeLists.txt b/src/ranger/test/run.sh
old mode 100644
new mode 100755
similarity index 79%
rename from src/runtime/ranger/CMakeLists.txt
rename to src/ranger/test/run.sh
index fbbceb570..c518a6d6d
--- a/src/runtime/ranger/CMakeLists.txt
+++ b/src/ranger/test/run.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
 # 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
@@ -15,12 +16,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
-set(MY_PROJ_NAME dsn_ranger)
+if [ -z "${REPORT_DIR}" ]; then
+    REPORT_DIR="."
+fi
 
-set(MY_PROJ_SRC "")
-set(MY_SRC_SEARCH_MODE "GLOB")
-set(MY_PROJ_LIBS
-        dsn_meta_server
-        dsn_replication_common)
-
-dsn_add_static_library()
+rm -rf data dsn_ranger_tests.xml
+output_xml="${REPORT_DIR}/dsn_ranger_tests.xml"
+GTEST_OUTPUT="xml:${output_xml}" ./dsn_ranger_tests
diff --git a/src/replica/backup/test/CMakeLists.txt 
b/src/replica/backup/test/CMakeLists.txt
index fed60e312..bacb77ada 100644
--- a/src/replica/backup/test/CMakeLists.txt
+++ b/src/replica/backup/test/CMakeLists.txt
@@ -16,12 +16,11 @@
 # under the License.
 
 set(MY_PROJ_NAME dsn_replica_backup_test)
-
 set(MY_PROJ_SRC "")
-
 set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS dsn_meta_server
+set(MY_PROJ_LIBS
+        dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn_replication_common
         dsn.block_service
@@ -33,12 +32,8 @@ set(MY_PROJ_LIBS dsn_meta_server
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
 set(MY_BINPLACES
         config-test.ini
-        run.sh
-)
-
+        run.sh)
 dsn_add_test()
diff --git a/src/replica/bulk_load/test/CMakeLists.txt 
b/src/replica/bulk_load/test/CMakeLists.txt
index bda1a8981..08abb8f9a 100644
--- a/src/replica/bulk_load/test/CMakeLists.txt
+++ b/src/replica/bulk_load/test/CMakeLists.txt
@@ -16,12 +16,11 @@
 # under the License.
 
 set(MY_PROJ_NAME dsn_replica_bulk_load_test)
-
 set(MY_PROJ_SRC "")
-
 set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS dsn_meta_server
+set(MY_PROJ_LIBS
+        dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn_replication_common
         dsn_runtime
@@ -32,12 +31,8 @@ set(MY_PROJ_LIBS dsn_meta_server
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
 set(MY_BINPLACES
         config-test.ini
-        run.sh
-)
-
+        run.sh)
 dsn_add_test()
diff --git a/src/replica/duplication/test/CMakeLists.txt 
b/src/replica/duplication/test/CMakeLists.txt
index 26e461bd7..57915bbe0 100644
--- a/src/replica/duplication/test/CMakeLists.txt
+++ b/src/replica/duplication/test/CMakeLists.txt
@@ -16,12 +16,11 @@
 # under the License.
 
 set(MY_PROJ_NAME dsn_replica_dup_test)
-
 set(MY_PROJ_SRC "")
-
 set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS dsn_meta_server
+set(MY_PROJ_LIBS
+        dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn.replication.zookeeper_provider
         dsn_replication_common
@@ -35,15 +34,11 @@ set(MY_PROJ_LIBS dsn_meta_server
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
 set(MY_BINPLACES
         config-test.ini
         log.1.0.handle_real_private_log
         log.1.0.all_loaded_are_write_empties
         log.1.0.handle_real_private_log2
-        run.sh
-)
-
+        run.sh)
 dsn_add_test()
diff --git a/src/replica/replica.h b/src/replica/replica.h
index c4f3d2ff4..e552a33b0 100644
--- a/src/replica/replica.h
+++ b/src/replica/replica.h
@@ -46,7 +46,7 @@
 #include "replica/replica_base.h"
 #include "replica_context.h"
 #include "runtime/api_layer1.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/rpc/rpc_message.h"
 #include "runtime/serverlet.h"
 #include "runtime/task/task.h"
diff --git a/src/replica/replica_2pc.cpp b/src/replica/replica_2pc.cpp
index ebba712cc..084bba023 100644
--- a/src/replica/replica_2pc.cpp
+++ b/src/replica/replica_2pc.cpp
@@ -55,7 +55,7 @@
 #include "replica/replication_app_base.h"
 #include "replica_stub.h"
 #include "runtime/api_layer1.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/rpc/network.h"
 #include "runtime/rpc/rpc_address.h"
 #include "runtime/rpc/rpc_message.h"
diff --git a/src/replica/replica_stub.cpp b/src/replica/replica_stub.cpp
index cc0c46cd5..44c6e6bf4 100644
--- a/src/replica/replica_stub.cpp
+++ b/src/replica/replica_stub.cpp
@@ -62,7 +62,7 @@
 #include "replica_disk_migrator.h"
 #include "replica_stub.h"
 #include "runtime/api_layer1.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/rpc/rpc_message.h"
 #include "runtime/rpc/serialization.h"
 #include "runtime/security/access_controller.h"
diff --git a/src/replica/replica_stub.h b/src/replica/replica_stub.h
index e702f7048..de158f992 100644
--- a/src/replica/replica_stub.h
+++ b/src/replica/replica_stub.h
@@ -53,7 +53,7 @@
 #include "replica.h"
 #include "replica/mutation_log.h"
 #include "replica_admin_types.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/rpc/rpc_address.h"
 #include "runtime/rpc/rpc_holder.h"
 #include "runtime/security/access_controller.h"
diff --git a/src/replica/split/test/CMakeLists.txt 
b/src/replica/split/test/CMakeLists.txt
index 7e77ba730..6bacdf05c 100644
--- a/src/replica/split/test/CMakeLists.txt
+++ b/src/replica/split/test/CMakeLists.txt
@@ -16,24 +16,18 @@
 # under the License.
 
 set(MY_PROJ_NAME dsn_replica_split_test)
-
 set(MY_PROJ_SRC "")
-
 set(MY_SRC_SEARCH_MODE "GLOB")
-
-set(MY_PROJ_LIBS dsn_meta_server
+set(MY_PROJ_LIBS
+        dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn_replication_common
         dsn_runtime
         hashtable
-        gtest
-)
-
+        gtest)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
 set(MY_BINPLACES
         config-test.ini
-        run.sh
-)
-
+        run.sh)
 dsn_add_test()
diff --git a/src/replica/storage/simple_kv/CMakeLists.txt 
b/src/replica/storage/simple_kv/CMakeLists.txt
index a2f850677..f8595297e 100644
--- a/src/replica/storage/simple_kv/CMakeLists.txt
+++ b/src/replica/storage/simple_kv/CMakeLists.txt
@@ -23,23 +23,17 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn.replication.simple_kv)
-
 thrift_generate_cpp(
     SIMPLE_KV_THRIFT_SRCS
     SIMPLE_KV_THRIFT_HDRS
     ${CMAKE_CURRENT_SOURCE_DIR}/simple_kv.thrift
 )
-
 set(MY_PROJ_SRC ${SIMPLE_KV_THRIFT_SRCS})
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn_replica_server
         dsn_meta_server
+        dsn_ranger
         dsn_client
         dsn_runtime
         hashtable
@@ -47,19 +41,11 @@ set(MY_PROJ_LIBS
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-set(INI_FILES "")
-file(GLOB
-    RES_FILES
-    "${CMAKE_CURRENT_SOURCE_DIR}/*.ini"
-    "${CMAKE_CURRENT_SOURCE_DIR}/*.sh"
-    )
-
-# Extra files that will be installed
+file(GLOB RES_FILES
+        *.ini
+        *.sh)
 set(MY_BINPLACES ${RES_FILES})
-
 dsn_add_test()
 
 add_subdirectory(test)
diff --git a/src/replica/storage/simple_kv/test/CMakeLists.txt 
b/src/replica/storage/simple_kv/test/CMakeLists.txt
index 0bce41b71..1aa7dbaa1 100644
--- a/src/replica/storage/simple_kv/test/CMakeLists.txt
+++ b/src/replica/storage/simple_kv/test/CMakeLists.txt
@@ -23,15 +23,11 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn.rep_tests.simple_kv)
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
-        dsn_replica_server
         dsn_meta_server
+        dsn_ranger
+        dsn_replica_server
         dsn_replication_common
         dsn_client
         dsn.failure_detector
@@ -45,16 +41,11 @@ set(MY_PROJ_LIBS
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
 FILE(GLOB CASE_FILES "case-*")
 set(MY_BINPLACES
-    "run.sh"
-    "clear.sh"
-    "addcase.sh"
-    "${CASE_FILES}"
-)
-
+        run.sh
+        clear.sh
+        addcase.sh
+        ${CASE_FILES})
 dsn_add_test()
diff --git a/src/replica/test/CMakeLists.txt b/src/replica/test/CMakeLists.txt
index 94b5c8934..ef30c7d03 100644
--- a/src/replica/test/CMakeLists.txt
+++ b/src/replica/test/CMakeLists.txt
@@ -23,18 +23,11 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn.replica.test)
-
-#Source files under CURRENT project directory will be automatically included.
-#You can manually set MY_PROJ_SRC to include source files under other 
directories.
 set(MY_PROJ_SRC "")
-
-#Search mode for source files under CURRENT project directory ?
-#"GLOB_RECURSE" for recursive search
-#"GLOB" for non - recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn_meta_server
+        dsn_ranger
         dsn_replica_server
         dsn.replication.zookeeper_provider
         dsn_replication_common
@@ -52,9 +45,9 @@ set(MY_PROJ_LIBS
         lz4
         zstd
         snappy)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-#Extra files that will be installed
-set(MY_BINPLACES clear.sh run.sh config-test.ini)
+set(MY_BINPLACES
+        clear.sh
+        run.sh
+        config-test.ini)
 dsn_add_test()
diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt
index d5757717a..ac98bfc5d 100644
--- a/src/runtime/CMakeLists.txt
+++ b/src/runtime/CMakeLists.txt
@@ -26,11 +26,9 @@ add_subdirectory(test)
 add_subdirectory(rpc)
 add_subdirectory(task)
 add_subdirectory(security)
-add_subdirectory(ranger)
 
 # TODO(zlw) remove perf_counter from dsn_runtime after the refactor by WuTao
 add_library(dsn_runtime STATIC
-        $<TARGET_OBJECTS:dsn_ranger>
         $<TARGET_OBJECTS:dsn.security>
         $<TARGET_OBJECTS:dsn.rpc>
         $<TARGET_OBJECTS:dsn.task>
@@ -51,8 +49,7 @@ add_library(dsn_runtime STATIC
         threadpool_code.cpp
         tool_api.cpp
         tracer.cpp
-        zlocks.cpp
-        )
+        zlocks.cpp)
 target_link_libraries(dsn_runtime PRIVATE dsn_utils sasl2 gssapi_krb5 krb5)
 define_file_basename_for_sources(dsn_runtime)
 install(TARGETS dsn_runtime DESTINATION "lib")
diff --git a/src/runtime/security/access_controller.h 
b/src/runtime/security/access_controller.h
index 863779deb..7770cdc16 100644
--- a/src/runtime/security/access_controller.h
+++ b/src/runtime/security/access_controller.h
@@ -21,7 +21,7 @@
 #include <string>
 #include <unordered_set>
 
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 
 namespace dsn {
 class message_ex;
diff --git a/src/runtime/security/client_negotiation.cpp 
b/src/runtime/security/client_negotiation.cpp
index 88aa15802..bd8946faa 100644
--- a/src/runtime/security/client_negotiation.cpp
+++ b/src/runtime/security/client_negotiation.cpp
@@ -17,13 +17,13 @@
 
 #include "client_negotiation.h"
 
-#include <boost/algorithm/string/join.hpp>
 #include <memory>
 #include <set>
 #include <utility>
 #include <vector>
 
 #include "fmt/core.h"
+#include "fmt/format.h"
 #include "negotiation_manager.h"
 #include "negotiation_utils.h"
 #include "runtime/rpc/network.h"
@@ -38,7 +38,6 @@
 
 namespace dsn {
 namespace security {
-extern const std::set<std::string> supported_mechanisms;
 
 client_negotiation::client_negotiation(rpc_session_ptr session) : 
negotiation(session)
 {
@@ -108,7 +107,7 @@ void client_negotiation::on_recv_mechanisms(const 
negotiation_response &resp)
     utils::split_args(resp_string.c_str(), server_support_mechanisms, ',');
 
     for (const std::string &server_support_mechanism : 
server_support_mechanisms) {
-        if (supported_mechanisms.find(server_support_mechanism) != 
supported_mechanisms.end()) {
+        if (kSupportedMechanisms.find(server_support_mechanism) != 
kSupportedMechanisms.end()) {
             match_mechanism = server_support_mechanism;
             break;
         }
@@ -116,7 +115,7 @@ void client_negotiation::on_recv_mechanisms(const 
negotiation_response &resp)
 
     if (match_mechanism.empty()) {
         LOG_WARNING("server only support mechanisms of ({}), can't find 
expected ({})",
-                    boost::join(supported_mechanisms, ","),
+                    fmt::join(kSupportedMechanisms, ","),
                     resp_string);
         fail_negotiation();
         return;
diff --git a/src/runtime/security/meta_access_controller.cpp 
b/src/runtime/security/meta_access_controller.cpp
index 833481595..8133d7533 100644
--- a/src/runtime/security/meta_access_controller.cpp
+++ b/src/runtime/security/meta_access_controller.cpp
@@ -19,8 +19,8 @@
 
 #include <vector>
 
-#include "runtime/ranger/ranger_resource_policy_manager.h"
-#include "runtime/ranger/ranger_resource_policy.h"
+#include "ranger/ranger_resource_policy_manager.h"
+#include "ranger/ranger_resource_policy.h"
 #include "runtime/rpc/network.h"
 #include "runtime/rpc/rpc_message.h"
 #include "runtime/task/task_code.h"
diff --git a/src/runtime/security/negotiation.cpp 
b/src/runtime/security/negotiation.cpp
index dc6f29a11..a63d9cb61 100644
--- a/src/runtime/security/negotiation.cpp
+++ b/src/runtime/security/negotiation.cpp
@@ -28,9 +28,6 @@
 
 namespace dsn {
 namespace security {
-/// TODO(zlw):we can't get string list from cflags now,
-/// so we should get supported mechanisms from config in the later
-const std::set<std::string> supported_mechanisms{"GSSAPI"};
 
 DSN_DEFINE_bool(security, enable_auth, false, "whether open auth or not");
 DSN_DEFINE_bool(security,
@@ -40,6 +37,8 @@ DSN_DEFINE_bool(security,
 DSN_DEFINE_bool(security, mandatory_auth, false, "wheter to do authertication 
mandatorily");
 DSN_TAG_VARIABLE(mandatory_auth, FT_MUTABLE);
 
+const std::set<std::string> negotiation::kSupportedMechanisms{"GSSAPI"};
+
 negotiation::~negotiation() {}
 
 std::unique_ptr<negotiation> create_negotiation(bool is_client, rpc_session 
*session)
diff --git a/src/runtime/security/negotiation.h 
b/src/runtime/security/negotiation.h
index 90e135b35..c9098a249 100644
--- a/src/runtime/security/negotiation.h
+++ b/src/runtime/security/negotiation.h
@@ -18,6 +18,7 @@
 #pragma once
 
 #include <memory>
+#include <set>
 #include <string>
 #include <utility>
 
@@ -54,6 +55,10 @@ public:
     bool check_status(negotiation_status::type status, 
negotiation_status::type expected_status);
 
 protected:
+    // TODO(zlw):we can't get string list from cflags now,
+    //  so we should get supported mechanisms from config in the later
+    static const std::set<std::string> kSupportedMechanisms;
+
     rpc_session_ptr _session;
     std::string _name;
     negotiation_status::type _status;
diff --git a/src/runtime/security/replica_access_controller.h 
b/src/runtime/security/replica_access_controller.h
index dcaeaa758..834bdc614 100644
--- a/src/runtime/security/replica_access_controller.h
+++ b/src/runtime/security/replica_access_controller.h
@@ -23,8 +23,8 @@
 
 #include "access_controller.h"
 #include "common/json_helper.h"
-#include "runtime/ranger/access_type.h"
-#include "runtime/ranger/ranger_resource_policy.h"
+#include "ranger/access_type.h"
+#include "ranger/ranger_resource_policy.h"
 #include "utils/synchronize.h"
 
 namespace dsn {
diff --git a/src/runtime/security/server_negotiation.cpp 
b/src/runtime/security/server_negotiation.cpp
index 23926c3f5..373dd2e7e 100644
--- a/src/runtime/security/server_negotiation.cpp
+++ b/src/runtime/security/server_negotiation.cpp
@@ -17,10 +17,11 @@
 
 #include "server_negotiation.h"
 
-#include <boost/algorithm/string/join.hpp>
 #include <memory>
+#include <set>
 
 #include "fmt/core.h"
+#include "fmt/format.h"
 #include "runtime/rpc/network.h"
 #include "runtime/rpc/rpc_address.h"
 #include "runtime/security/negotiation.h"
@@ -76,7 +77,7 @@ void server_negotiation::on_list_mechanisms(negotiation_rpc 
rpc)
         return;
     }
 
-    std::string mech_list = boost::join(supported_mechanisms, ",");
+    std::string mech_list = fmt::format("{}", fmt::join(kSupportedMechanisms, 
","));
     negotiation_response &response = rpc.response();
     _status = response.status = 
negotiation_status::type::SASL_LIST_MECHANISMS_RESP;
     response.msg = blob::create_from_bytes(mech_list.data(), 
mech_list.length());
@@ -91,7 +92,7 @@ void server_negotiation::on_select_mechanism(negotiation_rpc 
rpc)
     }
 
     _selected_mechanism = request.msg.to_string();
-    if (supported_mechanisms.find(_selected_mechanism) == 
supported_mechanisms.end()) {
+    if (kSupportedMechanisms.find(_selected_mechanism) == 
kSupportedMechanisms.end()) {
         LOG_WARNING("the mechanism of {} is not supported", 
_selected_mechanism);
         fail_negotiation();
         return;
diff --git a/src/runtime/security/server_negotiation.h 
b/src/runtime/security/server_negotiation.h
index 8db26f1ba..c43e55c02 100644
--- a/src/runtime/security/server_negotiation.h
+++ b/src/runtime/security/server_negotiation.h
@@ -17,7 +17,6 @@
 
 #pragma once
 
-#include <set>
 #include <string>
 
 #include "negotiation.h"
@@ -28,7 +27,6 @@ class blob;
 class error_s;
 
 namespace security {
-extern const std::set<std::string> supported_mechanisms;
 
 // server_negotiation negotiates a session on server side.
 class server_negotiation : public negotiation
diff --git a/src/runtime/test/CMakeLists.txt b/src/runtime/test/CMakeLists.txt
index 38e52a4f5..83e355c44 100644
--- a/src/runtime/test/CMakeLists.txt
+++ b/src/runtime/test/CMakeLists.txt
@@ -23,32 +23,24 @@
 # THE SOFTWARE.
 
 set(MY_PROJ_NAME dsn_runtime_tests)
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
-        gtest
+        dsn_meta_server
+        dsn_ranger
         dsn_runtime
         dsn_aio
-        dsn_meta_server
         rocksdb
         lz4
         zstd
-        snappy)
-
+        snappy
+        gtest)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-# Extra files that will be installed
-set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-test-corrupt-message.ini"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/config-test.ini"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/config-test-sim.ini"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/command.txt"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/run.sh"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/clear.sh"
-                 "${CMAKE_CURRENT_SOURCE_DIR}/gtest.filter"
-)
-add_definitions(-Wno-dangling-else)
+set(MY_BINPLACES
+        config-test-corrupt-message.ini
+        config-test.ini
+        config-test-sim.ini
+        command.txt
+        run.sh
+        clear.sh
+        gtest.filter)
 dsn_add_test()
diff --git a/src/runtime/test/async_call.cpp b/src/runtime/test/async_call.cpp
index 0b55f2e78..0a266cbcf 100644
--- a/src/runtime/test/async_call.cpp
+++ b/src/runtime/test/async_call.cpp
@@ -42,7 +42,7 @@
 #include "runtime/task/task.h"
 #include "runtime/task/task_code.h"
 #include "runtime/task/task_tracker.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
 #include "utils/fmt_logging.h"
@@ -137,8 +137,9 @@ TEST(async_call, rpc_call)
                        *str_command,
                        &tc->_tracker,
                        [str_command](error_code ec, std::string &&resp) {
-                           if (ERR_OK == ec)
+                           if (ERR_OK == ec) {
                                EXPECT_TRUE(str_command->substr(5) == resp);
+                           }
                        });
     task_vec.push_back(t);
     t = rpc::call(addr2,
diff --git a/src/runtime/test/corrupt_message.cpp 
b/src/runtime/test/corrupt_message.cpp
index 88a07cfc6..1db983b25 100644
--- a/src/runtime/test/corrupt_message.cpp
+++ b/src/runtime/test/corrupt_message.cpp
@@ -32,7 +32,7 @@
 #include "gtest/gtest.h"
 #include "runtime/rpc/rpc_address.h"
 #include "runtime/task/async_calls.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/error_code.h"
 
 // this only works with the fault injector
diff --git a/src/runtime/test/host_port_test.cpp 
b/src/runtime/test/host_port_test.cpp
index c2e5445cf..0cd656a07 100644
--- a/src/runtime/test/host_port_test.cpp
+++ b/src/runtime/test/host_port_test.cpp
@@ -34,7 +34,7 @@
 #include "runtime/task/task.h"
 #include "runtime/task/task_spec.h"
 #include "runtime/task/task_tracker.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
 #include "utils/errors.h"
diff --git a/src/runtime/test/lpc.cpp b/src/runtime/test/lpc.cpp
index 286cf1c48..c0d63b3a8 100644
--- a/src/runtime/test/lpc.cpp
+++ b/src/runtime/test/lpc.cpp
@@ -32,7 +32,7 @@
 #include "runtime/task/task.h"
 #include "runtime/task/task_code.h"
 #include "runtime/task/task_worker.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/autoref_ptr.h"
 
 DEFINE_TASK_CODE(LPC_TEST_HASH, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
diff --git a/src/runtime/test/main.cpp b/src/runtime/test/main.cpp
index 0e0400eb6..23b64deb6 100644
--- a/src/runtime/test/main.cpp
+++ b/src/runtime/test/main.cpp
@@ -31,7 +31,7 @@
 #include <gtest/gtest.h>
 #include "runtime/app_model.h"
 #include "runtime/service_app.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/flags.h"
 #include "utils/strings.h"
 
diff --git a/src/runtime/test/netprovider.cpp b/src/runtime/test/netprovider.cpp
index f0b568300..cef7f40ec 100644
--- a/src/runtime/test/netprovider.cpp
+++ b/src/runtime/test/netprovider.cpp
@@ -46,7 +46,7 @@
 #include "runtime/task/task.h"
 #include "runtime/task/task_code.h"
 #include "runtime/task/task_spec.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
 #include "utils/flags.h"
diff --git a/src/runtime/test/replica_access_controller_test.cpp 
b/src/runtime/test/replica_access_controller_test.cpp
index d801d7755..b0d17da75 100644
--- a/src/runtime/test/replica_access_controller_test.cpp
+++ b/src/runtime/test/replica_access_controller_test.cpp
@@ -22,7 +22,7 @@
 
 #include "common/replication.codes.h"
 #include "gtest/gtest.h"
-#include "runtime/ranger/access_type.h"
+#include "ranger/access_type.h"
 #include "runtime/rpc/network.h"
 #include "runtime/rpc/network.sim.h"
 #include "runtime/rpc/rpc_address.h"
diff --git a/src/runtime/test/rpc.cpp b/src/runtime/test/rpc.cpp
index 0acebc16f..17c95fb5f 100644
--- a/src/runtime/test/rpc.cpp
+++ b/src/runtime/test/rpc.cpp
@@ -41,7 +41,7 @@
 #include "runtime/rpc/serialization.h"
 #include "runtime/task/async_calls.h"
 #include "runtime/task/task.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
 #include "utils/fmt_logging.h"
diff --git a/src/runtime/test/task_engine.cpp b/src/runtime/test/task_engine.cpp
index 573e931ec..38374f455 100644
--- a/src/runtime/test/task_engine.cpp
+++ b/src/runtime/test/task_engine.cpp
@@ -32,7 +32,7 @@
 #include "runtime/global_config.h"
 #include "runtime/service_engine.h"
 #include "runtime/task/task.h"
-#include "test_utils.h"
+#include "runtime/test_utils.h"
 #include "utils/enum_helper.h"
 #include "utils/threadpool_code.h"
 
diff --git a/src/runtime/test/test_utils.h b/src/runtime/test_utils.h
similarity index 100%
rename from src/runtime/test/test_utils.h
rename to src/runtime/test_utils.h
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index 8c8daa4d1..11673f693 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -15,20 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
-set(MY_PROJ_NAME "pegasus_server")
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
+set(MY_PROJ_NAME pegasus_server)
 set(MY_PROJ_SRC "")
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn_replica_server
         dsn_meta_server
+        dsn_ranger
         dsn_replication_common
         dsn_client
         dsn.block_service.local
@@ -44,15 +37,11 @@ set(MY_PROJ_LIBS
         pegasus_client_static
         event
         hashtable)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")
-
+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()
diff --git a/src/server/test/CMakeLists.txt b/src/server/test/CMakeLists.txt
index 2b4c96ac1..5907476d3 100644
--- a/src/server/test/CMakeLists.txt
+++ b/src/server/test/CMakeLists.txt
@@ -16,28 +16,26 @@
 # under the License.
 
 set(MY_PROJ_NAME pegasus_unit_test)
-
-set(MY_PROJ_SRC "../pegasus_server_impl.cpp"
-                "../pegasus_server_impl_init.cpp"
-                "../pegasus_manual_compact_service.cpp"
-                "../pegasus_event_listener.cpp"
-                "../pegasus_write_service.cpp"
-                "../pegasus_server_write.cpp"
-                "../capacity_unit_calculator.cpp"
-                "../pegasus_mutation_duplicator.cpp"
-                "../hotspot_partition_calculator.cpp"
-                "../meta_store.cpp"
-                "../hotkey_collector.cpp"
-                "../rocksdb_wrapper.cpp"
-                "../compaction_filter_rule.cpp"
-                "../compaction_operation.cpp"
-        )
-
+set(MY_PROJ_SRC
+        "../pegasus_server_impl.cpp"
+        "../pegasus_server_impl_init.cpp"
+        "../pegasus_manual_compact_service.cpp"
+        "../pegasus_event_listener.cpp"
+        "../pegasus_write_service.cpp"
+        "../pegasus_server_write.cpp"
+        "../capacity_unit_calculator.cpp"
+        "../pegasus_mutation_duplicator.cpp"
+        "../hotspot_partition_calculator.cpp"
+        "../meta_store.cpp"
+        "../hotkey_collector.cpp"
+        "../rocksdb_wrapper.cpp"
+        "../compaction_filter_rule.cpp"
+        "../compaction_operation.cpp")
 set(MY_SRC_SEARCH_MODE "GLOB")
-
 set(MY_PROJ_LIBS
         dsn_replica_server
         dsn_meta_server
+        dsn_ranger
         dsn_replication_common
         dsn_client
         dsn.block_service.local
@@ -54,13 +52,11 @@ set(MY_PROJ_LIBS
         pegasus_base
         gtest
         gmock
-        hashtable
-)
+        hashtable)
 add_definitions(-DPEGASUS_UNIT_TEST)
 add_definitions(-DENABLE_FAIL)
-
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
-set(MY_BINPLACES config.ini run.sh)
-
+set(MY_BINPLACES
+        config.ini
+        run.sh)
 dsn_add_test()
diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt
index 81271006e..121f1b04c 100644
--- a/src/shell/CMakeLists.txt
+++ b/src/shell/CMakeLists.txt
@@ -15,23 +15,18 @@
 # specific language governing permissions and limitations
 # under the License.
 
-set(MY_PROJ_NAME "pegasus_shell")
+set(MY_PROJ_NAME pegasus_shell)
 project(${MY_PROJ_NAME} C CXX)
-
-# Source files under CURRENT project directory will be automatically included.
-# You can manually set MY_PROJ_SRC to include source files under other 
directories.
-set(MY_PROJ_SRC "linenoise/linenoise.c" "sds/sds.c")
-
-# Search mode for source files under CURRENT project directory?
-# "GLOB_RECURSE" for recursive search
-# "GLOB" for non-recursive search
+set(MY_PROJ_SRC
+        linenoise/linenoise.c
+        sds/sds.c)
 set(MY_SRC_SEARCH_MODE "GLOB_RECURSE")
-
 set(MY_PROJ_LIBS
         pegasus_base
         dsn.replication.tool
         dsn_replica_server
         dsn_meta_server
+        dsn_ranger
         dsn_replication_common
         dsn_client
         dsn_utils
@@ -49,15 +44,11 @@ set(MY_PROJ_LIBS
         absl::strings
         s2
         hdfs)
-
-set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")
-
+set(MY_BINPLACES
+        ${CMAKE_CURRENT_SOURCE_DIR}/config.ini)
 set(MY_BOOST_LIBS Boost::system Boost::filesystem)
-
 SET(CMAKE_INSTALL_RPATH ".")
 SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-
 add_definitions(-Wno-attributes)
-
 dsn_add_executable()
 dsn_install_executable()
diff --git a/src/utils/filesystem.cpp b/src/utils/filesystem.cpp
index 0ebe07ef7..d0d439664 100644
--- a/src/utils/filesystem.cpp
+++ b/src/utils/filesystem.cpp
@@ -569,6 +569,17 @@ std::string path_combine(const std::string &path1, const 
std::string &path2)
     return npath;
 }
 
+std::string concat_path_unix_style(const std::string &prefix, const 
std::string &postfix)
+{
+    size_t pos1 = prefix.size(); // last_valid_pos + 1
+    while (pos1 > 0 && prefix[pos1 - 1] == '/')
+        pos1--;
+    size_t pos2 = 0; // first non '/' position
+    while (pos2 < postfix.size() && postfix[pos2] == '/')
+        pos2++;
+    return prefix.substr(0, pos1) + "/" + postfix.substr(pos2);
+}
+
 bool get_current_directory(std::string &path)
 {
     bool succ;
diff --git a/src/utils/filesystem.h b/src/utils/filesystem.h
index 2142d1be1..29524c9c3 100644
--- a/src/utils/filesystem.h
+++ b/src/utils/filesystem.h
@@ -75,7 +75,9 @@ std::string remove_file_name(const std::string &path);
 
 std::string get_file_name(const std::string &path);
 
+// TODO(yingchun): The 2 functions are similar, remove concat_path_unix_style.
 std::string path_combine(const std::string &path1, const std::string &path2);
+std::string concat_path_unix_style(const std::string &prefix, const 
std::string &postfix);
 
 typedef std::function<int(const char *, int, struct FTW *)> ftw_handler;
 bool file_tree_walk(const std::string &dirpath, ftw_handler handler, bool 
recursive = true);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to