You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by la...@apache.org on 2022/12/01 11:27:12 UTC

[incubator-pegasus] branch master updated: refactor(rpc_address): simple refactor on rpc_address (#1251)

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 06a0ad9bb refactor(rpc_address): simple refactor on rpc_address (#1251)
06a0ad9bb is described below

commit 06a0ad9bb40babc4e6a70d97c527a4f66115399a
Author: Yingchun Lai <la...@apache.org>
AuthorDate: Thu Dec 1 19:27:06 2022 +0800

    refactor(rpc_address): simple refactor on rpc_address (#1251)
---
 .licenserc.yaml                                    |   6 +-
 scripts/recompile_thrift.sh                        |   2 +-
 src/aio/test/main.cpp                              |  13 +--
 src/base/pegasus_utils.h                           |   8 +-
 src/block_service/block_service.h                  |   2 +-
 src/block_service/fds/fds_service.cpp              |  29 +++---
 src/block_service/test/main.cpp                    |   2 +-
 src/client/partition_resolver.h                    |   2 +-
 src/client/partition_resolver_manager.h            |   2 +-
 src/client/replication_ddl_client.cpp              |   6 +-
 src/client/replication_ddl_client.h                |   2 +-
 src/common/fs_manager.h                            |   2 +-
 src/common/replication_common.cpp                  |  10 +-
 src/common/replication_common.h                    |   2 +-
 src/common/storage_serverlet.h                     |   2 +-
 src/common/test/main.cpp                           |   2 +-
 .../failure_detector_multimaster.cpp               |   8 +-
 src/failure_detector/fd.code.definition.h          |   2 +-
 src/failure_detector/test/failure_detector.cpp     |   2 +-
 src/failure_detector/test/main.cpp                 |   2 +-
 src/geo/lib/geo_client.cpp                         |   2 +-
 src/geo/lib/latlng_codec.cpp                       |   2 +-
 src/meta/dump_file.h                               |   2 +-
 src/meta/load_balance_policy.cpp                   |   7 +-
 src/meta/meta_bulk_load_ingestion_context.cpp      |   5 +-
 src/meta/meta_bulk_load_service.cpp                |   7 +-
 src/meta/meta_data.cpp                             |   2 +-
 src/meta/meta_options.h                            |   2 +-
 src/meta/meta_server_failure_detector.cpp          |  23 ++---
 src/meta/meta_service_app.cpp                      |   2 +-
 src/meta/meta_state_service.h                      |   2 +-
 src/meta/meta_state_service_utils.cpp              |   2 +-
 src/meta/partition_guardian.cpp                    |   6 +-
 src/meta/server_load_balancer.h                    |   2 +-
 src/meta/test/backup_test.cpp                      |   2 +-
 src/meta/test/balancer_validator.cpp               |   2 +-
 src/meta/test/json_compacity.cpp                   |   2 +-
 src/meta/test/main.cpp                             |   2 +-
 src/meta/test/meta_partition_guardian_test.cpp     |   2 +-
 src/meta/test/meta_service_test_app.h              |   2 +-
 src/meta/test/meta_state/main.cpp                  |   2 +-
 src/meta/test/meta_state_service_utils_test.cpp    |   2 +-
 src/meta/test/misc/misc.h                          |   2 +-
 src/meta/test/state_sync_test.cpp                  |   2 +-
 src/meta/test/update_configuration_test.cpp        |   2 +-
 src/nfs/nfs_client_impl.cpp                        |   1 +
 src/nfs/nfs_server_impl.cpp                        |   5 +-
 src/perf_counter/builtin_counters.cpp              |   9 +-
 src/perf_counter/test/main.cpp                     |   2 +-
 src/redis_protocol/proxy_lib/proxy_layer.h         |   2 +-
 src/replica/backup/test/main.cpp                   |   2 +-
 src/replica/bulk_load/test/main.cpp                |   2 +-
 src/replica/duplication/replica_duplicator.h       |   2 +-
 src/replica/duplication/test/main.cpp              |   2 +-
 src/replica/replica_http_service.cpp               |   9 +-
 src/replica/split/test/main.cpp                    |   2 +-
 src/replica/storage/simple_kv/test/common.h        |   2 +-
 src/runtime/api_layer1.h                           |   2 +-
 src/runtime/rpc/group_address.h                    | 114 +++++++++++----------
 src/runtime/rpc/network.h                          |   2 +-
 src/{utils => runtime/rpc}/rpc_address.cpp         |  80 ++++++++++-----
 src/{utils => runtime/rpc}/rpc_address.h           |  52 ++++------
 src/runtime/rpc/rpc_holder.h                       |   2 +-
 src/runtime/rpc/rpc_message.h                      |   2 +-
 src/runtime/rpc/serialization.h                    |   2 +-
 src/runtime/service_app.h                          |   2 +-
 src/runtime/task/task_engine.cpp                   |   8 +-
 .../address.cpp => runtime/test/address_test.cpp}  |  77 +++++++++-----
 src/runtime/test/async_call.cpp                    |   2 +-
 src/runtime/test/corrupt_message.cpp               |   2 +-
 src/runtime/test/lpc.cpp                           |   2 +-
 src/runtime/test/meta_access_controller_test.cpp   |   2 +-
 src/runtime/test/netprovider.cpp                   |   2 +-
 src/runtime/test/pipeline_test.cpp                 |   2 +-
 .../test/replica_access_controller_test.cpp        |   2 +-
 src/runtime/test/rpc.cpp                           |   4 +-
 src/runtime/test/test_utils.h                      |   2 +-
 src/server/info_collector.cpp                      |   2 +-
 src/server/info_collector.h                        |   2 +-
 src/server/info_collector_app.cpp                  |   2 +-
 src/server/meta_store.cpp                          |   1 +
 src/server/test/main.cpp                           |   2 +-
 .../function_test/throttle_test/test_throttle.cpp  |   2 +-
 src/test/function_test/utils/global_env.cpp        |   2 +-
 src/test/function_test/utils/test_util.cpp         |   2 +-
 src/test/kill_test/data_verifier.cpp               |   2 +-
 src/test/kill_test/kill_testor.cpp                 |   2 +-
 src/utils/distributed_lock_service.h               |   2 +-
 src/utils/test/file_utils.cpp                      |   2 +-
 src/utils/test/hostname_test.cpp                   |   7 +-
 src/utils/utils.cpp                                |   2 +-
 src/utils/utils.h                                  |   4 +-
 src/utils/zlocks.h                                 |   2 +
 src/zookeeper/test/distributed_lock_zookeeper.cpp  |   2 +-
 src/zookeeper/test/main.cpp                        |   2 +-
 src/zookeeper/zookeeper_session_mgr.h              |   2 +-
 96 files changed, 349 insertions(+), 292 deletions(-)

diff --git a/.licenserc.yaml b/.licenserc.yaml
index 093392404..00530aa0d 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -146,7 +146,8 @@ header:
     - 'src/utils/logging_provider.h'
     - 'src/runtime/rpc/message_parser.h'
     - 'src/runtime/rpc/network.h'
-    - 'src/utils/rpc_address.h'
+    - 'src/runtime/rpc/rpc_address.cpp'
+    - 'src/runtime/rpc/rpc_address.h'
     - 'src/runtime/rpc/rpc_message.h'
     - 'src/runtime/task/task.h'
     - 'src/runtime/task/task_code.h'
@@ -562,6 +563,7 @@ header:
     - 'src/runtime/task/task_tracker.cpp'
     - 'src/runtime/task/task_worker.cpp'
     - 'src/runtime/test/CMakeLists.txt'
+    - 'src/runtime/test/address_test.cpp'
     - 'src/runtime/test/async_call.cpp'
     - 'src/runtime/test/clear.sh'
     - 'src/runtime/test/command.txt'
@@ -602,13 +604,11 @@ header:
     - 'src/utils/gpid.cpp'
     - 'src/utils/lockp.std.h'
     - 'src/utils/logging.cpp'
-    - 'src/utils/rpc_address.cpp'
     - 'src/utils/shared_io_service.h'
     - 'src/utils/simple_logger.cpp'
     - 'src/utils/simple_logger.h'
     - 'src/utils/strings.cpp'
     - 'src/utils/test/CMakeLists.txt'
-    - 'src/utils/test/address.cpp'
     - 'src/utils/test/clear.sh'
     - 'src/utils/test/config-bad-section.ini'
     - 'src/utils/test/config-dup-key.ini'
diff --git a/scripts/recompile_thrift.sh b/scripts/recompile_thrift.sh
index 1122daa6f..444a50348 100755
--- a/scripts/recompile_thrift.sh
+++ b/scripts/recompile_thrift.sh
@@ -30,7 +30,7 @@ rm -rf $TMP_DIR
 mkdir -p $TMP_DIR
 $THIRDPARTY_ROOT/output/bin/thrift --gen cpp:moveable_types -out $TMP_DIR ../idl/rrdb.thrift
 
-sed 's/#include "dsn_types.h"/#include "utils\/rpc_address.h"\n#include "runtime\/task\/task_code.h"\n#include "utils\/blob.h"/' $TMP_DIR/rrdb_types.h > ../src/include/rrdb/rrdb_types.h
+sed 's/#include "dsn_types.h"/#include "runtime\/rpc\/rpc_address.h"\n#include "runtime\/task\/task_code.h"\n#include "utils\/blob.h"/' $TMP_DIR/rrdb_types.h > ../src/include/rrdb/rrdb_types.h
 sed 's/#include "rrdb_types.h"/#include <rrdb\/rrdb_types.h>/' $TMP_DIR/rrdb_types.cpp > ../src/base/rrdb_types.cpp
 
 rm -rf $TMP_DIR
diff --git a/src/aio/test/main.cpp b/src/aio/test/main.cpp
index 9d7ebae30..a8901fc90 100644
--- a/src/aio/test/main.cpp
+++ b/src/aio/test/main.cpp
@@ -16,19 +16,8 @@
 // under the License.
 
 #include <gtest/gtest.h>
-#include "runtime/api_task.h"
-#include "runtime/api_layer1.h"
+
 #include "runtime/app_model.h"
-#include "utils/api_utilities.h"
-#include "utils/error_code.h"
-#include "utils/threadpool_code.h"
-#include "runtime/task/task_code.h"
-#include "common/gpid.h"
-#include "runtime/rpc/serialization.h"
-#include "runtime/rpc/rpc_stream.h"
-#include "runtime/serverlet.h"
-#include "runtime/service_app.h"
-#include "utils/rpc_address.h"
 
 GTEST_API_ int main(int argc, char **argv)
 {
diff --git a/src/base/pegasus_utils.h b/src/base/pegasus_utils.h
index c24d2d9b0..f0c89c0ac 100644
--- a/src/base/pegasus_utils.h
+++ b/src/base/pegasus_utils.h
@@ -20,14 +20,18 @@
 #pragma once
 
 #include <time.h>
+
 #include <cctype>
 #include <cstring>
+#include <list>
 #include <queue>
+
 #include <boost/lexical_cast.hpp>
-#include "utils/rpc_address.h"
-#include "utils/string_view.h"
 #include <rocksdb/slice.h>
 
+#include "runtime/rpc/rpc_address.h"
+#include "utils/string_view.h"
+
 namespace pegasus {
 namespace utils {
 
diff --git a/src/block_service/block_service.h b/src/block_service/block_service.h
index ed935fc39..96f141644 100644
--- a/src/block_service/block_service.h
+++ b/src/block_service/block_service.h
@@ -33,7 +33,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include <functional>
diff --git a/src/block_service/fds/fds_service.cpp b/src/block_service/fds/fds_service.cpp
index f4a442d7d..9a89a1726 100644
--- a/src/block_service/fds/fds_service.cpp
+++ b/src/block_service/fds/fds_service.cpp
@@ -15,31 +15,32 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "fds_service.h"
+#include "block_service/fds/fds_service.h"
 
-#include <galaxy_fds_client.h>
+#include <cstring>
+#include <fstream>
+#include <memory>
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/scoped_ptr.hpp>
 #include <fds_client_configuration.h>
+#include <galaxy_fds_client.h>
 #include <galaxy_fds_client_exception.h>
-#include <model/fds_object_metadata.h>
+#include <model/delete_multi_objects_result.h>
 #include <model/fds_object.h>
-#include <model/fds_object_summary.h>
+#include <model/fds_object_metadata.h>
 #include <model/fds_object_listing.h>
-#include <model/delete_multi_objects_result.h>
-#include "utils/error_code.h"
+#include <model/fds_object_summary.h>
 #include <Poco/Net/HTTPResponse.h>
 
-#include <boost/scoped_ptr.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-
-#include <memory>
-#include <fstream>
-#include <string.h>
 #include "utils/defer.h"
+#include "utils/error_code.h"
 #include "utils/filesystem.h"
+#include "utils/flags.h"
+#include "utils/fmt_logging.h"
 #include "utils/safe_strerror_posix.h"
+#include "utils/string_conv.h"
 #include "utils/TokenBucket.h"
-#include "utils/fmt_logging.h"
-#include "utils/flags.h"
 
 namespace dsn {
 namespace dist {
diff --git a/src/block_service/test/main.cpp b/src/block_service/test/main.cpp
index 16a31f3bb..fb8fd40e4 100644
--- a/src/block_service/test/main.cpp
+++ b/src/block_service/test/main.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/client/partition_resolver.h b/src/client/partition_resolver.h
index ecbecd5a9..37ebda3b3 100644
--- a/src/client/partition_resolver.h
+++ b/src/client/partition_resolver.h
@@ -29,7 +29,7 @@
 #include "utils/autoref_ptr.h"
 #include "utils/error_code.h"
 #include "common/gpid.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/rpc/rpc_message.h"
 #include "runtime/task/async_calls.h"
 
diff --git a/src/client/partition_resolver_manager.h b/src/client/partition_resolver_manager.h
index dea506894..87fc55f82 100644
--- a/src/client/partition_resolver_manager.h
+++ b/src/client/partition_resolver_manager.h
@@ -30,7 +30,7 @@
 #include <map>
 #include "utils/singleton.h"
 #include "utils/zlocks.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "client/partition_resolver.h"
 
 namespace dsn {
diff --git a/src/client/replication_ddl_client.cpp b/src/client/replication_ddl_client.cpp
index c8a69a1aa..406b9d073 100644
--- a/src/client/replication_ddl_client.cpp
+++ b/src/client/replication_ddl_client.cpp
@@ -58,8 +58,10 @@ using tp_output_format = ::dsn::utils::table_printer::output_format;
 replication_ddl_client::replication_ddl_client(const std::vector<dsn::rpc_address> &meta_servers)
 {
     _meta_server.assign_group("meta-servers");
-    for (auto &m : meta_servers) {
-        _meta_server.group_address()->add(m);
+    for (const auto &m : meta_servers) {
+        if (!_meta_server.group_address()->add(m)) {
+            LOG_WARNING_F("duplicate adress {}", m);
+        }
     }
 }
 
diff --git a/src/client/replication_ddl_client.h b/src/client/replication_ddl_client.h
index 843fcf2e5..5b562f7bb 100644
--- a/src/client/replication_ddl_client.h
+++ b/src/client/replication_ddl_client.h
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/common/fs_manager.h b/src/common/fs_manager.h
index 572912aca..9df5e8449 100644
--- a/src/common/fs_manager.h
+++ b/src/common/fs_manager.h
@@ -32,7 +32,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/zlocks.h"
 #include "utils/flags.h"
 
diff --git a/src/common/replication_common.cpp b/src/common/replication_common.cpp
index 4f9ca354f..36665f0e3 100644
--- a/src/common/replication_common.cpp
+++ b/src/common/replication_common.cpp
@@ -24,14 +24,15 @@
  * THE SOFTWARE.
  */
 
+#include "common/replication_common.h"
+
 #include <fstream>
 
-#include "utils/fmt_logging.h"
 #include "common/replica_envs.h"
-#include "utils/flags.h"
 #include "utils/filesystem.h"
-
-#include "replication_common.h"
+#include "utils/flags.h"
+#include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
@@ -493,6 +494,7 @@ bool replica_helper::load_meta_servers(/*out*/ std::vector<dsn::rpc_address> &se
             LOG_ERROR_F("invalid address '{}' specified in config [{}].{}", s, section, key);
             return false;
         }
+        // TODO(yingchun): check there is no duplicates
         servers.push_back(addr);
     }
     if (servers.empty()) {
diff --git a/src/common/replication_common.h b/src/common/replication_common.h
index cc6353731..85b019f32 100644
--- a/src/common/replication_common.h
+++ b/src/common/replication_common.h
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include <string>
diff --git a/src/common/storage_serverlet.h b/src/common/storage_serverlet.h
index 90947857b..a06709d41 100644
--- a/src/common/storage_serverlet.h
+++ b/src/common/storage_serverlet.h
@@ -42,7 +42,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/common/test/main.cpp b/src/common/test/main.cpp
index be96d4c28..3b2f06cc9 100644
--- a/src/common/test/main.cpp
+++ b/src/common/test/main.cpp
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/failure_detector/failure_detector_multimaster.cpp b/src/failure_detector/failure_detector_multimaster.cpp
index 0fae1fb1f..907bb3d80 100644
--- a/src/failure_detector/failure_detector_multimaster.cpp
+++ b/src/failure_detector/failure_detector_multimaster.cpp
@@ -34,7 +34,7 @@
  */
 
 #include <cinttypes>
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/rpc/group_address.h"
 #include "failure_detector/failure_detector_multimaster.h"
 #include "utils/rand.h"
@@ -48,8 +48,10 @@ slave_failure_detector_with_multimaster::slave_failure_detector_with_multimaster
     std::function<void()> &&master_connected_callback)
 {
     _meta_servers.assign_group("meta-servers");
-    for (auto &s : meta_servers) {
-        _meta_servers.group_address()->add(s);
+    for (const auto &s : meta_servers) {
+        if (!_meta_servers.group_address()->add(s)) {
+            LOG_WARNING_F("duplicate adress {}", s);
+        }
     }
 
     _meta_servers.group_address()->set_leader(
diff --git a/src/failure_detector/fd.code.definition.h b/src/failure_detector/fd.code.definition.h
index bbe2bb7dd..1f8934aae 100644
--- a/src/failure_detector/fd.code.definition.h
+++ b/src/failure_detector/fd.code.definition.h
@@ -39,7 +39,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "fd_types.h"
 
 namespace dsn {
diff --git a/src/failure_detector/test/failure_detector.cpp b/src/failure_detector/test/failure_detector.cpp
index 505fd2027..af969098c 100644
--- a/src/failure_detector/test/failure_detector.cpp
+++ b/src/failure_detector/test/failure_detector.cpp
@@ -41,7 +41,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include <vector>
 
 using namespace dsn;
diff --git a/src/failure_detector/test/main.cpp b/src/failure_detector/test/main.cpp
index 076922490..ca41073b8 100644
--- a/src/failure_detector/test/main.cpp
+++ b/src/failure_detector/test/main.cpp
@@ -44,7 +44,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/geo/lib/geo_client.cpp b/src/geo/lib/geo_client.cpp
index ad0e160f2..4aa102778 100644
--- a/src/geo/lib/geo_client.cpp
+++ b/src/geo/lib/geo_client.cpp
@@ -34,7 +34,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/fmt_logging.h"
 #include "utils/errors.h"
 
diff --git a/src/geo/lib/latlng_codec.cpp b/src/geo/lib/latlng_codec.cpp
index 8ed1c0a4c..f3f827ca4 100644
--- a/src/geo/lib/latlng_codec.cpp
+++ b/src/geo/lib/latlng_codec.cpp
@@ -31,7 +31,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/fmt_logging.h"
 #include "utils/error_code.h"
 #include "utils/errors.h"
diff --git a/src/meta/dump_file.h b/src/meta/dump_file.h
index fe8bf3d8d..4c115e777 100644
--- a/src/meta/dump_file.h
+++ b/src/meta/dump_file.h
@@ -44,7 +44,7 @@
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
 #include "utils/fmt_logging.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/crc.h"
 #include <cstdio>
 #include <cerrno>
diff --git a/src/meta/load_balance_policy.cpp b/src/meta/load_balance_policy.cpp
index a6002bb2d..cc1f8e6da 100644
--- a/src/meta/load_balance_policy.cpp
+++ b/src/meta/load_balance_policy.cpp
@@ -15,12 +15,13 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "load_balance_policy.h"
-#include "greedy_load_balancer.h"
+#include "meta/load_balance_policy.h"
 
+#include "meta/greedy_load_balancer.h"
 #include "utils/command_manager.h"
-#include "utils/fmt_logging.h"
 #include "utils/fail_point.h"
+#include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/meta/meta_bulk_load_ingestion_context.cpp b/src/meta/meta_bulk_load_ingestion_context.cpp
index effe6c266..cd391330f 100644
--- a/src/meta/meta_bulk_load_ingestion_context.cpp
+++ b/src/meta/meta_bulk_load_ingestion_context.cpp
@@ -15,10 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "meta_bulk_load_ingestion_context.h"
+#include "meta/meta_bulk_load_ingestion_context.h"
 
-#include "utils/fmt_logging.h"
 #include "utils/fail_point.h"
+#include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/meta/meta_bulk_load_service.cpp b/src/meta/meta_bulk_load_service.cpp
index 6dff9c0c6..e30ea5ede 100644
--- a/src/meta/meta_bulk_load_service.cpp
+++ b/src/meta/meta_bulk_load_service.cpp
@@ -15,11 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "utils/fmt_logging.h"
+#include "meta/meta_bulk_load_service.h"
+
 #include "common/replica_envs.h"
 #include "utils/fail_point.h"
-
-#include "meta_bulk_load_service.h"
+#include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/meta/meta_data.cpp b/src/meta/meta_data.cpp
index f9de71fa1..47a0dbe41 100644
--- a/src/meta/meta_data.cpp
+++ b/src/meta/meta_data.cpp
@@ -47,7 +47,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/flags.h"
 
 #include "meta_data.h"
diff --git a/src/meta/meta_options.h b/src/meta/meta_options.h
index 9bb299429..46efef8ce 100644
--- a/src/meta/meta_options.h
+++ b/src/meta/meta_options.h
@@ -47,7 +47,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/meta/meta_server_failure_detector.cpp b/src/meta/meta_server_failure_detector.cpp
index 6f5f830cf..68d124a19 100644
--- a/src/meta/meta_server_failure_detector.cpp
+++ b/src/meta/meta_server_failure_detector.cpp
@@ -24,25 +24,18 @@
  * THE SOFTWARE.
  */
 
-/*
- * Description:
- *     What is this file about?
- *
- * Revision history:
- *     xxxx-xx-xx, author, first version
- *     xxxx-xx-xx, author, fix bug about xxx
- */
+#include "meta/meta_server_failure_detector.h"
 
+#include <chrono>
+#include <thread>
+
+#include "meta/meta_service.h"
+#include "meta/meta_options.h"
+#include "meta/server_state.h"
 #include "utils/factory_store.h"
 #include "utils/fail_point.h"
 #include "utils/fmt_logging.h"
-#include "meta_server_failure_detector.h"
-#include "server_state.h"
-#include "meta_service.h"
-#include "meta_options.h"
-
-#include <chrono>
-#include <thread>
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/meta/meta_service_app.cpp b/src/meta/meta_service_app.cpp
index 69a7525a1..9dbe03a54 100644
--- a/src/meta/meta_service_app.cpp
+++ b/src/meta/meta_service_app.cpp
@@ -36,7 +36,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "utils/factory_store.h"
diff --git a/src/meta/meta_state_service.h b/src/meta/meta_state_service.h
index fe604a3ff..8166b6fc8 100644
--- a/src/meta/meta_state_service.h
+++ b/src/meta/meta_state_service.h
@@ -55,7 +55,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/error_code.h"
 #include "runtime/task/future_types.h"
 #include <string>
diff --git a/src/meta/meta_state_service_utils.cpp b/src/meta/meta_state_service_utils.cpp
index 0e659ea42..07ae78e73 100644
--- a/src/meta/meta_state_service_utils.cpp
+++ b/src/meta/meta_state_service_utils.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/meta/partition_guardian.cpp b/src/meta/partition_guardian.cpp
index 11c010faa..be3b66e4c 100644
--- a/src/meta/partition_guardian.cpp
+++ b/src/meta/partition_guardian.cpp
@@ -15,8 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "partition_guardian.h"
-#include "server_load_balancer.h"
+#include "meta/partition_guardian.h"
+
+#include "meta/server_load_balancer.h"
+#include "utils/string_conv.h"
 #include "utils/time_utils.h"
 
 namespace dsn {
diff --git a/src/meta/server_load_balancer.h b/src/meta/server_load_balancer.h
index c7a63553b..b2bb4d04b 100644
--- a/src/meta/server_load_balancer.h
+++ b/src/meta/server_load_balancer.h
@@ -48,7 +48,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/zlocks.h"
 #include "utils/command_manager.h"
 #include "utils/error_code.h"
diff --git a/src/meta/test/backup_test.cpp b/src/meta/test/backup_test.cpp
index 6c71611cc..3c0896284 100644
--- a/src/meta/test/backup_test.cpp
+++ b/src/meta/test/backup_test.cpp
@@ -27,7 +27,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/fail_point.h"
 #include "utils/time_utils.h"
 #include <gtest/gtest.h>
diff --git a/src/meta/test/balancer_validator.cpp b/src/meta/test/balancer_validator.cpp
index 04d68e9b8..602ab87df 100644
--- a/src/meta/test/balancer_validator.cpp
+++ b/src/meta/test/balancer_validator.cpp
@@ -53,7 +53,7 @@
 #include "utils/api_utilities.h"
 #include "utils/error_code.h"
 #include "utils/fmt_logging.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/threadpool_code.h"
 
 namespace dsn {
diff --git a/src/meta/test/json_compacity.cpp b/src/meta/test/json_compacity.cpp
index 7787365fb..60fb7739b 100644
--- a/src/meta/test/json_compacity.cpp
+++ b/src/meta/test/json_compacity.cpp
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "meta/meta_service.h"
 #include "meta/server_state.h"
diff --git a/src/meta/test/main.cpp b/src/meta/test/main.cpp
index 4d6b93175..db61f17d2 100644
--- a/src/meta/test/main.cpp
+++ b/src/meta/test/main.cpp
@@ -28,7 +28,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include <fstream>
 #include <gtest/gtest.h>
 #include <iostream>
diff --git a/src/meta/test/meta_partition_guardian_test.cpp b/src/meta/test/meta_partition_guardian_test.cpp
index 2ab2695e6..47fe17352 100644
--- a/src/meta/test/meta_partition_guardian_test.cpp
+++ b/src/meta/test/meta_partition_guardian_test.cpp
@@ -39,7 +39,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/meta/test/meta_service_test_app.h b/src/meta/test/meta_service_test_app.h
index 81397558c..ea095b892 100644
--- a/src/meta/test/meta_service_test_app.h
+++ b/src/meta/test/meta_service_test_app.h
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/task/async_calls.h"
 #include "meta_admin_types.h"
 #include "partition_split_types.h"
diff --git a/src/meta/test/meta_state/main.cpp b/src/meta/test/meta_state/main.cpp
index 1eb71d225..9c852d937 100644
--- a/src/meta/test/meta_state/main.cpp
+++ b/src/meta/test/meta_state/main.cpp
@@ -53,7 +53,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/meta/test/meta_state_service_utils_test.cpp b/src/meta/test/meta_state_service_utils_test.cpp
index 3452845d7..28dde5340 100644
--- a/src/meta/test/meta_state_service_utils_test.cpp
+++ b/src/meta/test/meta_state_service_utils_test.cpp
@@ -39,7 +39,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/meta/test/misc/misc.h b/src/meta/test/misc/misc.h
index c52676ed9..99b0c87cc 100644
--- a/src/meta/test/misc/misc.h
+++ b/src/meta/test/misc/misc.h
@@ -39,7 +39,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "meta/meta_data.h"
 #include "common/fs_manager.h"
 
diff --git a/src/meta/test/state_sync_test.cpp b/src/meta/test/state_sync_test.cpp
index 0179de7be..47a4afd0f 100644
--- a/src/meta/test/state_sync_test.cpp
+++ b/src/meta/test/state_sync_test.cpp
@@ -42,7 +42,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "meta/meta_service.h"
 #include "meta/server_state.h"
diff --git a/src/meta/test/update_configuration_test.cpp b/src/meta/test/update_configuration_test.cpp
index ef45f82dc..10ff2e8b3 100644
--- a/src/meta/test/update_configuration_test.cpp
+++ b/src/meta/test/update_configuration_test.cpp
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/zlocks.h"
 
 #include "meta/meta_service.h"
diff --git a/src/nfs/nfs_client_impl.cpp b/src/nfs/nfs_client_impl.cpp
index c34728878..1d5b42363 100644
--- a/src/nfs/nfs_client_impl.cpp
+++ b/src/nfs/nfs_client_impl.cpp
@@ -33,6 +33,7 @@
 #include "utils/command_manager.h"
 #include "utils/filesystem.h"
 #include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace service {
diff --git a/src/nfs/nfs_server_impl.cpp b/src/nfs/nfs_server_impl.cpp
index a93d77a9f..5a90bf4d2 100644
--- a/src/nfs/nfs_server_impl.cpp
+++ b/src/nfs/nfs_server_impl.cpp
@@ -24,7 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "nfs_server_impl.h"
+#include "nfs/nfs_server_impl.h"
 
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -32,8 +32,9 @@
 #include <cstdlib>
 
 #include "aio/disk_engine.h"
-#include "utils/filesystem.h"
 #include "runtime/task/async_calls.h"
+#include "utils/filesystem.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace service {
diff --git a/src/perf_counter/builtin_counters.cpp b/src/perf_counter/builtin_counters.cpp
index ea0bf6f1d..fdbb670f6 100644
--- a/src/perf_counter/builtin_counters.cpp
+++ b/src/perf_counter/builtin_counters.cpp
@@ -17,8 +17,9 @@
 
 #include "builtin_counters.h"
 
-#include "utils/utils.h"
 #include "utils/api_utilities.h"
+#include "utils/fmt_logging.h"
+#include "utils/utils.h"
 
 namespace dsn {
 
@@ -47,7 +48,7 @@ void builtin_counters::update_counters()
     uint64_t memused_res = (uint64_t)resident_set / 1024;
     _memused_virt->set(memused_virt);
     _memused_res->set(memused_res);
-    LOG_INFO(
-        "memused_virt = %" PRIu64 " MB, memused_res = %" PRIu64 "MB", memused_virt, memused_res);
-}
+    LOG_INFO_F("memused_virt = {} MB, memused_res = {} MB", memused_virt, memused_res);
 }
+
+} // namespace dsn
diff --git a/src/perf_counter/test/main.cpp b/src/perf_counter/test/main.cpp
index 644774962..af4a24eaa 100644
--- a/src/perf_counter/test/main.cpp
+++ b/src/perf_counter/test/main.cpp
@@ -28,7 +28,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 GTEST_API_ int main(int argc, char **argv)
 {
diff --git a/src/redis_protocol/proxy_lib/proxy_layer.h b/src/redis_protocol/proxy_lib/proxy_layer.h
index 0599adf85..87f4dc22f 100644
--- a/src/redis_protocol/proxy_lib/proxy_layer.h
+++ b/src/redis_protocol/proxy_lib/proxy_layer.h
@@ -31,7 +31,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/zlocks.h"
 #include <unordered_map>
 #include <functional>
diff --git a/src/replica/backup/test/main.cpp b/src/replica/backup/test/main.cpp
index 16a31f3bb..fb8fd40e4 100644
--- a/src/replica/backup/test/main.cpp
+++ b/src/replica/backup/test/main.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/replica/bulk_load/test/main.cpp b/src/replica/bulk_load/test/main.cpp
index 16a31f3bb..fb8fd40e4 100644
--- a/src/replica/bulk_load/test/main.cpp
+++ b/src/replica/bulk_load/test/main.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/replica/duplication/replica_duplicator.h b/src/replica/duplication/replica_duplicator.h
index 4159980f8..0610c6525 100644
--- a/src/replica/duplication/replica_duplicator.h
+++ b/src/replica/duplication/replica_duplicator.h
@@ -32,7 +32,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "utils/zlocks.h"
diff --git a/src/replica/duplication/test/main.cpp b/src/replica/duplication/test/main.cpp
index 16a31f3bb..fb8fd40e4 100644
--- a/src/replica/duplication/test/main.cpp
+++ b/src/replica/duplication/test/main.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/replica/replica_http_service.cpp b/src/replica/replica_http_service.cpp
index 5c1965781..a9ff53da0 100644
--- a/src/replica/replica_http_service.cpp
+++ b/src/replica/replica_http_service.cpp
@@ -15,11 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include <nlohmann/json.hpp>
+#include "replica/replica_http_service.h"
+
 #include <fmt/format.h>
-#include "utils/output_utils.h"
-#include "replica_http_service.h"
+#include <nlohmann/json.hpp>
+
 #include "duplication/duplication_sync_timer.h"
+#include "utils/output_utils.h"
+#include "utils/string_conv.h"
 
 namespace dsn {
 namespace replication {
diff --git a/src/replica/split/test/main.cpp b/src/replica/split/test/main.cpp
index 16a31f3bb..fb8fd40e4 100644
--- a/src/replica/split/test/main.cpp
+++ b/src/replica/split/test/main.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/replica/storage/simple_kv/test/common.h b/src/replica/storage/simple_kv/test/common.h
index 29a971ff6..044fd9b52 100644
--- a/src/replica/storage/simple_kv/test/common.h
+++ b/src/replica/storage/simple_kv/test/common.h
@@ -47,7 +47,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "common/replication_common.h"
diff --git a/src/runtime/api_layer1.h b/src/runtime/api_layer1.h
index 193ed30a4..dc5e31703 100644
--- a/src/runtime/api_layer1.h
+++ b/src/runtime/api_layer1.h
@@ -32,7 +32,7 @@
 
 #include "runtime/api_task.h"
 #include "common/gpid.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/task/task_tracker.h"
 
 /*!
diff --git a/src/runtime/rpc/group_address.h b/src/runtime/rpc/group_address.h
index ee05cce1f..1af420ed6 100644
--- a/src/runtime/rpc/group_address.h
+++ b/src/runtime/rpc/group_address.h
@@ -24,42 +24,37 @@
  * THE SOFTWARE.
  */
 
-/*
- * Description:
- *     group_address is a collection of rpc_addresses, usually used for replication
- *
- * Revision history:
- *     Sep., 2015, @imzhenyu, first version
- *     xxxx-xx-xx, author, fix bug about xxx
- */
-
 #pragma once
 
 #include <algorithm>
-#include "utils/api_utilities.h"
+
 #include "runtime/api_layer1.h"
-#include "utils/synchronize.h"
+#include "runtime/rpc/rpc_address.h"
+#include "utils/api_utilities.h"
 #include "utils/autoref_ptr.h"
 #include "utils/rand.h"
-#include "utils/rpc_address.h"
+#include "utils/synchronize.h"
 
 namespace dsn {
-class rpc_group_address : public dsn::ref_counter
+class rpc_group_address : public ref_counter
 {
 public:
     rpc_group_address(const char *name);
     rpc_group_address(const rpc_group_address &other);
     rpc_group_address &operator=(const rpc_group_address &other);
-    bool add(rpc_address addr);
-    void add_list(const std::vector<rpc_address> &list)
+    bool add(rpc_address addr) WARN_UNUSED_RESULT;
+    void add_list(const std::vector<rpc_address> &addrs)
     {
-        for (const rpc_address &r : list) {
-            add(r);
+        for (const auto &addr : addrs) {
+            // TODO(yingchun): add LOG_WARNING_IF/LOG_ERROR_IF
+            if (!add(addr)) {
+                LOG_WARNING_F("duplicate adress {}", addr);
+            }
         }
     }
     void set_leader(rpc_address addr);
-    bool remove(rpc_address addr);
-    bool contains(rpc_address addr);
+    bool remove(rpc_address addr) WARN_UNUSED_RESULT;
+    bool contains(rpc_address addr) const WARN_UNUSED_RESULT;
     int count();
 
     const std::vector<rpc_address> &members() const { return _members; }
@@ -83,10 +78,10 @@ public:
 
 private:
     typedef std::vector<rpc_address> members_t;
-    typedef ::dsn::utils::auto_read_lock alr_t;
-    typedef ::dsn::utils::auto_write_lock alw_t;
+    typedef utils::auto_read_lock alr_t;
+    typedef utils::auto_write_lock alw_t;
 
-    mutable ::dsn::utils::rw_lock_nr _lock;
+    mutable utils::rw_lock_nr _lock;
     members_t _members;
     int _leader_index;
     bool _update_leader_automatically;
@@ -112,6 +107,9 @@ inline rpc_group_address::rpc_group_address(const rpc_group_address &other)
 
 inline rpc_group_address &rpc_group_address::operator=(const rpc_group_address &other)
 {
+    if (this == &other) {
+        return *this;
+    }
     _name = other._name;
     _leader_index = other._leader_index;
     _update_leader_automatically = other._update_leader_automatically;
@@ -135,8 +133,9 @@ inline bool rpc_group_address::add(rpc_address addr)
 inline void rpc_group_address::leader_forward()
 {
     alw_t l(_lock);
-    if (_members.empty())
+    if (_members.empty()) {
         return;
+    }
     _leader_index = (_leader_index + 1) % _members.size();
 }
 
@@ -145,27 +144,30 @@ inline void rpc_group_address::set_leader(rpc_address addr)
     alw_t l(_lock);
     if (addr.is_invalid()) {
         _leader_index = -1;
-    } else {
-        CHECK_EQ_MSG(addr.type(), HOST_TYPE_IPV4, "rpc group address member must be ipv4");
-        for (int i = 0; i < (int)_members.size(); i++) {
-            if (_members[i] == addr) {
-                _leader_index = i;
-                return;
-            }
-        }
+        return;
+    }
 
-        _members.push_back(addr);
-        _leader_index = (int)(_members.size() - 1);
+    CHECK_EQ_MSG(addr.type(), HOST_TYPE_IPV4, "rpc group address member must be ipv4");
+    for (int i = 0; i < (int)_members.size(); i++) {
+        if (_members[i] == addr) {
+            _leader_index = i;
+            return;
+        }
     }
+
+    _members.push_back(addr);
+    _leader_index = (int)(_members.size() - 1);
 }
 
 inline rpc_address rpc_group_address::possible_leader()
 {
-    alr_t l(_lock);
-    if (_members.empty())
+    alw_t l(_lock);
+    if (_members.empty()) {
         return rpc_address::s_invalid_address;
-    if (_leader_index == -1)
+    }
+    if (_leader_index == -1) {
         _leader_index = rand::next_u32(0, (uint32_t)_members.size() - 1);
+    }
     return _members[_leader_index];
 }
 
@@ -173,17 +175,20 @@ inline bool rpc_group_address::remove(rpc_address addr)
 {
     alw_t l(_lock);
     auto it = std::find(_members.begin(), _members.end(), addr);
-    bool r = (it != _members.end());
-    if (r) {
-        if (-1 != _leader_index && addr == _members[_leader_index])
-            _leader_index = -1;
+    if (it == _members.end()) {
+        return false;
+    }
 
-        _members.erase(it);
+    if (-1 != _leader_index && addr == _members[_leader_index]) {
+        _leader_index = -1;
     }
-    return r;
+
+    _members.erase(it);
+
+    return true;
 }
 
-inline bool rpc_group_address::contains(rpc_address addr)
+inline bool rpc_group_address::contains(rpc_address addr) const
 {
     alr_t l(_lock);
     return _members.end() != std::find(_members.begin(), _members.end(), addr);
@@ -198,18 +203,21 @@ inline int rpc_group_address::count()
 inline rpc_address rpc_group_address::next(rpc_address current) const
 {
     alr_t l(_lock);
-    if (_members.empty())
+    if (_members.empty()) {
         return rpc_address::s_invalid_address;
-    if (current.is_invalid())
+    }
+
+    if (current.is_invalid()) {
         return _members[rand::next_u32(0, (uint32_t)_members.size() - 1)];
-    else {
-        auto it = std::find(_members.begin(), _members.end(), current);
-        if (it == _members.end())
-            return _members[rand::next_u32(0, (uint32_t)_members.size() - 1)];
-        else {
-            it++;
-            return it == _members.end() ? _members[0] : *it;
-        }
     }
+
+    auto it = std::find(_members.begin(), _members.end(), current);
+    if (it == _members.end()) {
+        return _members[rand::next_u32(0, (uint32_t)_members.size() - 1)];
+    }
+
+    it++;
+    return it == _members.end() ? _members[0] : *it;
 }
+
 } // namespace dsn
diff --git a/src/runtime/rpc/network.h b/src/runtime/rpc/network.h
index 847308aa1..a9fdbd359 100644
--- a/src/runtime/rpc/network.h
+++ b/src/runtime/rpc/network.h
@@ -30,7 +30,7 @@
 
 #include "utils/synchronize.h"
 #include "runtime/rpc/message_parser.h"
-#include "utils/rpc_address.h"
+#include "rpc_address.h"
 #include "utils/exp_delay.h"
 #include "perf_counter/perf_counter_wrapper.h"
 #include <atomic>
diff --git a/src/utils/rpc_address.cpp b/src/runtime/rpc/rpc_address.cpp
similarity index 75%
rename from src/utils/rpc_address.cpp
rename to src/runtime/rpc/rpc_address.cpp
index f99728e0a..50ed9db06 100644
--- a/src/utils/rpc_address.cpp
+++ b/src/runtime/rpc/rpc_address.cpp
@@ -24,20 +24,23 @@
  * THE SOFTWARE.
  */
 
-#include <sys/socket.h>
-#include <netdb.h>
+#include "runtime/rpc/rpc_address.h"
+
+#include <arpa/inet.h>
 #include <ifaddrs.h>
+#include <netdb.h>
 #include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include "utils/ports.h"
-#include "utils/string_view.h"
-#include "utils/fixed_size_buffer_pool.h"
+#include <sys/socket.h>
 
-#include "utils/api_utilities.h"
+#include <thrift/protocol/TProtocol.h>
 
-#include "utils/rpc_address.h"
 #include "runtime/rpc/group_address.h"
+#include "utils/api_utilities.h"
+#include "utils/fixed_size_buffer_pool.h"
+#include "utils/ports.h"
+#include "utils/safe_strerror_posix.h"
+#include "utils/string_conv.h"
+#include "utils/string_view.h"
 
 namespace dsn {
 
@@ -51,15 +54,14 @@ uint32_t rpc_address::ipv4_from_host(const char *name)
 
     addr.sin_family = AF_INET;
     if ((addr.sin_addr.s_addr = inet_addr(name)) == (unsigned int)(-1)) {
+        // TODO(yingchun): use getaddrinfo instead
         hostent *hp = ::gethostbyname(name);
-        int err = h_errno;
-
-        if (hp == nullptr) {
-            LOG_ERROR("gethostbyname failed, name = %s, err = %d.", name, err);
+        if (dsn_unlikely(hp == nullptr)) {
+            LOG_ERROR_F("gethostbyname failed, name = {}, err = {}", name, hstrerror(h_errno));
             return 0;
-        } else {
-            memcpy((void *)&(addr.sin_addr.s_addr), (const void *)hp->h_addr, (size_t)hp->h_length);
         }
+
+        memcpy((void *)&(addr.sin_addr.s_addr), (const void *)hp->h_addr, (size_t)hp->h_length);
     }
 
     // converts from network byte order to host byte order
@@ -79,8 +81,9 @@ bool rpc_address::is_site_local_address(uint32_t ip_net)
 /*static*/
 bool rpc_address::is_docker_netcard(const char *netcard_interface, uint32_t ip_net)
 {
-    if (dsn::string_view(netcard_interface).find("docker") != dsn::string_view::npos)
+    if (string_view(netcard_interface).find("docker") != string_view::npos) {
         return true;
+    }
     uint32_t iphost = ntohl(ip_net);
     return iphost == 0xAC112A01; // 172.17.42.1
 }
@@ -102,23 +105,22 @@ uint32_t rpc_address::ipv4_from_network_interface(const char *network_interface)
                      is_site_local_address(ip_val))) {
                     ret = (uint32_t)ntohl(ip_val);
                     break;
-                } else {
-                    LOG_DEBUG("skip interface(%s), address(%s)",
-                              i->ifa_name,
-                              rpc_address(ip_val, 0).ipv4_str());
                 }
+                LOG_DEBUG_F("skip interface({}), address({})",
+                            i->ifa_name,
+                            rpc_address(ip_val, 0).ipv4_str());
             }
             i = i->ifa_next;
         }
 
         if (i == nullptr) {
-            LOG_ERROR("get local ip from network interfaces failed, network_interface = %s",
-                      network_interface);
+            LOG_ERROR_F("get local ip from network interfaces failed, network_interface = {}",
+                        network_interface);
         } else {
-            LOG_INFO("get ip address from network interface(%s), addr(%s), input interface(\"%s\")",
-                     i->ifa_name,
-                     rpc_address(ret, 0).ipv4_str(),
-                     network_interface);
+            LOG_INFO_F("get ip address from network interface({}), addr({}), input interface({})",
+                       i->ifa_name,
+                       rpc_address(ret, 0).ipv4_str(),
+                       network_interface);
         }
 
         if (ifa != nullptr) {
@@ -156,7 +158,7 @@ void rpc_address::assign_group(const char *name)
 {
     set_invalid();
     _addr.group.type = HOST_TYPE_GROUP;
-    dsn::rpc_group_address *addr = new dsn::rpc_group_address(name);
+    rpc_group_address *addr = new rpc_group_address(name);
     // take the lifetime of rpc_uri_address, release_ref when change value or call destructor
     addr->add_ref();
     _addr.group.group = (uint64_t)addr;
@@ -191,6 +193,30 @@ const char *rpc_address::ipv4_str() const
     return p;
 }
 
+bool rpc_address::from_string_ipv4(const char *s)
+{
+    set_invalid();
+    std::string ip_port(s);
+    auto pos = ip_port.find_last_of(':');
+    if (pos == std::string::npos) {
+        return false;
+    }
+    std::string ip = ip_port.substr(0, pos);
+    std::string port = ip_port.substr(pos + 1);
+    // check port
+    unsigned int port_num;
+    if (!internal::buf2unsigned(port, port_num) || port_num > UINT16_MAX) {
+        return false;
+    }
+    // check localhost & IP
+    uint32_t ip_addr;
+    if (ip == "localhost" || inet_pton(AF_INET, ip.c_str(), &ip_addr)) {
+        assign_ipv4(ip.c_str(), (uint16_t)port_num);
+        return true;
+    }
+    return false;
+}
+
 const char *rpc_address::to_string() const
 {
     char *p = bf.next();
diff --git a/src/utils/rpc_address.h b/src/runtime/rpc/rpc_address.h
similarity index 85%
rename from src/utils/rpc_address.h
rename to src/runtime/rpc/rpc_address.h
index 662019096..3748bb015 100644
--- a/src/utils/rpc_address.h
+++ b/src/runtime/rpc/rpc_address.h
@@ -23,14 +23,19 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+
 #pragma once
 
+#include <sstream>
 #include <string>
 
-#include <arpa/inet.h>
-#include <thrift/protocol/TProtocol.h>
-
-#include "string_conv.h"
+namespace apache {
+namespace thrift {
+namespace protocol {
+class TProtocol;
+} // namespace protocol
+} // namespace thrift
+} // namespace apache
 
 typedef enum dsn_host_type_t {
     HOST_TYPE_INVALID = 0,
@@ -64,7 +69,7 @@ public:
         assign_ipv4(ip, port);
         static_assert(sizeof(rpc_address) == sizeof(uint64_t),
                       "make sure rpc_address does not "
-                      "add new payload to dsn::rpc_address "
+                      "add new payload to rpc_address "
                       "to keep it sizeof(uint64_t)");
     }
 
@@ -106,29 +111,7 @@ public:
     // This function is used for validating the format of ipv4 like "192.168.0.1:12345"
     // Due to historical legacy, we also consider "localhost:8080" is in a valid format
     // IP address without port like "127.0.0.1" is invalid here
-    bool from_string_ipv4(const char *s)
-    {
-        set_invalid();
-        std::string ip_port = std::string(s);
-        auto pos = ip_port.find_last_of(':');
-        if (pos == std::string::npos) {
-            return false;
-        }
-        std::string ip = ip_port.substr(0, pos);
-        std::string port = ip_port.substr(pos + 1);
-        // check port
-        unsigned int port_num;
-        if (!dsn::internal::buf2unsigned(port, port_num) || port_num > UINT16_MAX) {
-            return false;
-        }
-        // check localhost & IP
-        uint32_t ip_addr;
-        if (ip == "localhost" || inet_pton(AF_INET, ip.c_str(), &ip_addr)) {
-            assign_ipv4(ip.c_str(), (uint16_t)port_num);
-            return true;
-        }
-        return false;
-    }
+    bool from_string_ipv4(const char *s);
 
     uint64_t &value() { return _addr.value; }
 
@@ -151,10 +134,15 @@ public:
     // and you MUST ensure that _addr is INITIALIZED before you call this function
     void set_invalid();
 
-    bool operator==(::dsn::rpc_address r) const
+    bool operator==(const rpc_address &r) const
     {
-        if (type() != r.type())
+        if (this == &r) {
+            return true;
+        }
+
+        if (type() != r.type()) {
             return false;
+        }
 
         switch (type()) {
         case HOST_TYPE_IPV4:
@@ -166,9 +154,9 @@ public:
         }
     }
 
-    bool operator!=(::dsn::rpc_address r) const { return !(*this == r); }
+    bool operator!=(const rpc_address &r) const { return !(*this == r); }
 
-    bool operator<(::dsn::rpc_address r) const
+    bool operator<(const rpc_address &r) const
     {
         if (type() != r.type())
             return type() < r.type();
diff --git a/src/runtime/rpc/rpc_holder.h b/src/runtime/rpc/rpc_holder.h
index b9c1ae66b..6c8b5de65 100644
--- a/src/runtime/rpc/rpc_holder.h
+++ b/src/runtime/rpc/rpc_holder.h
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "rpc_address.h"
 #include "runtime/rpc/rpc_message.h"
 #include "runtime/task/async_calls.h"
 #include "runtime/task/task_tracker.h"
diff --git a/src/runtime/rpc/rpc_message.h b/src/runtime/rpc/rpc_message.h
index 79336e93c..25bde2a80 100644
--- a/src/runtime/rpc/rpc_message.h
+++ b/src/runtime/rpc/rpc_message.h
@@ -44,7 +44,7 @@
 #include "utils/threadpool_code.h"
 #include "runtime/task/task_code.h"
 #include "common/gpid.h"
-#include "utils/rpc_address.h"
+#include "rpc_address.h"
 #include "runtime/global_config.h"
 
 #define DSN_MAX_TASK_CODE_NAME_LENGTH 48
diff --git a/src/runtime/rpc/serialization.h b/src/runtime/rpc/serialization.h
index 046e68ca3..6d9eec3d5 100644
--- a/src/runtime/rpc/serialization.h
+++ b/src/runtime/rpc/serialization.h
@@ -27,7 +27,7 @@
 #pragma once
 
 #include "utils/utils.h"
-#include "utils/rpc_address.h"
+#include "rpc_address.h"
 #include "runtime/rpc/rpc_stream.h"
 #include "common/serialization_helper/thrift_helper.h"
 
diff --git a/src/runtime/service_app.h b/src/runtime/service_app.h
index 4bf686522..31b6382b0 100644
--- a/src/runtime/service_app.h
+++ b/src/runtime/service_app.h
@@ -44,7 +44,7 @@
 #include "utils/threadpool_code.h"
 #include "runtime/task/task_code.h"
 #include "common/gpid.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/gpid.h"
 #include "utils/factory_store.h"
 #include <vector>
diff --git a/src/runtime/task/task_engine.cpp b/src/runtime/task/task_engine.cpp
index a0f1ed730..fa24dfc07 100644
--- a/src/runtime/task/task_engine.cpp
+++ b/src/runtime/task/task_engine.cpp
@@ -24,11 +24,13 @@
  * THE SOFTWARE.
  */
 
-#include "utils/fmt_logging.h"
-#include "utils/command_manager.h"
+#include "runtime/task/task_engine.h"
+
 #include <fmt/format.h>
 
-#include "task_engine.h"
+#include "utils/command_manager.h"
+#include "utils/fmt_logging.h"
+#include "utils/string_conv.h"
 
 using namespace dsn::utils;
 
diff --git a/src/utils/test/address.cpp b/src/runtime/test/address_test.cpp
similarity index 82%
rename from src/utils/test/address.cpp
rename to src/runtime/test/address_test.cpp
index 3c071355b..5dfd3d59f 100644
--- a/src/utils/test/address.cpp
+++ b/src/runtime/test/address_test.cpp
@@ -24,20 +24,12 @@
  * THE SOFTWARE.
  */
 
-/*
- * Description:
- *     Unit-test for rpc_address.
- *
- * Revision history:
- *     Nov., 2015, @qinzuoyan (Zuoyan Qin), first version
- *     xxxx-xx-xx, author, fix bug about xxx
- */
+#include <gtest/gtest.h>
 
-#include "utils/rpc_address.h"
 #include "runtime/rpc/group_address.h"
-#include <gtest/gtest.h>
+#include "runtime/rpc/rpc_address.h"
 
-using namespace ::dsn;
+namespace dsn {
 
 static inline uint32_t host_ipv4(uint8_t sec1, uint8_t sec2, uint8_t sec3, uint8_t sec4)
 {
@@ -49,7 +41,7 @@ static inline uint32_t host_ipv4(uint8_t sec1, uint8_t sec2, uint8_t sec3, uint8
     return ip;
 }
 
-TEST(core, rpc_address_ipv4_from_host)
+TEST(rpc_address_test, rpc_address_ipv4_from_host)
 {
     // localhost --> 127.0.0.1
     // on some systems "localhost" could be "127.0.1.1" (debian)
@@ -60,14 +52,14 @@ TEST(core, rpc_address_ipv4_from_host)
     ASSERT_EQ(host_ipv4(127, 0, 0, 1), rpc_address::ipv4_from_host("127.0.0.1"));
 }
 
-TEST(core, rpc_address_ipv4_from_network_interface)
+TEST(rpc_address_test, rpc_address_ipv4_from_network_interface)
 {
     ASSERT_EQ(host_ipv4(127, 0, 0, 1), rpc_address::ipv4_from_network_interface("lo"));
     ASSERT_EQ(host_ipv4(0, 0, 0, 0),
               rpc_address::ipv4_from_network_interface("not_exist_interface"));
 }
 
-TEST(core, is_site_local_address)
+TEST(rpc_address_test, is_site_local_address)
 {
     ASSERT_FALSE(rpc_address::is_site_local_address(htonl(host_ipv4(1, 2, 3, 4))));
     ASSERT_TRUE(rpc_address::is_site_local_address(htonl(host_ipv4(10, 235, 111, 111))));
@@ -79,7 +71,7 @@ TEST(core, is_site_local_address)
     ASSERT_FALSE(rpc_address::is_site_local_address(htonl(host_ipv4(201, 201, 201, 201))));
 }
 
-TEST(core, is_docker_netcard)
+TEST(rpc_address_test, is_docker_netcard)
 {
     ASSERT_TRUE(rpc_address::is_docker_netcard("docker0", htonl(host_ipv4(1, 2, 3, 4))));
     ASSERT_TRUE(rpc_address::is_docker_netcard("10docker5", htonl(host_ipv4(4, 5, 6, 8))));
@@ -87,45 +79,45 @@ TEST(core, is_docker_netcard)
     ASSERT_TRUE(rpc_address::is_docker_netcard("eth0", htonl(host_ipv4(172, 17, 42, 1))));
 }
 
-TEST(core, rpc_address_to_string)
+TEST(rpc_address_test, rpc_address_to_string)
 {
     {
-        dsn::rpc_address addr;
+        rpc_address addr;
         addr.assign_ipv4(host_ipv4(127, 0, 0, 1), 8080);
         ASSERT_EQ(std::string("127.0.0.1:8080"), addr.to_std_string());
     }
 
     {
         const char *name = "test_group";
-        dsn::rpc_address addr;
+        rpc_address addr;
         addr.assign_group(name);
         ASSERT_EQ(std::string(name), addr.to_std_string());
     }
 
     {
-        dsn::rpc_address addr;
+        rpc_address addr;
         ASSERT_EQ(std::string("invalid address"), addr.to_std_string());
     }
 }
 
-TEST(core, dsn_address_build)
+TEST(rpc_address_test, dsn_address_build)
 {
     {
-        dsn::rpc_address addr;
+        rpc_address addr;
         addr.assign_ipv4(host_ipv4(127, 0, 0, 1), 8080);
         ASSERT_EQ(HOST_TYPE_IPV4, addr.type());
         ASSERT_EQ(host_ipv4(127, 0, 0, 1), addr.ip());
         ASSERT_EQ(8080, addr.port());
 
-        ASSERT_TRUE(dsn::rpc_address("127.0.0.1", 8080) == dsn::rpc_address("localhost", 8080) ||
-                    dsn::rpc_address("127.0.1.1", 8080) == dsn::rpc_address("localhost", 8080));
-        ASSERT_EQ(addr, dsn::rpc_address("127.0.0.1", 8080));
-        ASSERT_EQ(addr, dsn::rpc_address(host_ipv4(127, 0, 0, 1), 8080));
+        ASSERT_TRUE(rpc_address("127.0.0.1", 8080) == rpc_address("localhost", 8080) ||
+                    rpc_address("127.0.1.1", 8080) == rpc_address("localhost", 8080));
+        ASSERT_EQ(addr, rpc_address("127.0.0.1", 8080));
+        ASSERT_EQ(addr, rpc_address(host_ipv4(127, 0, 0, 1), 8080));
     }
 
     {
         const char *name = "test_group";
-        dsn::rpc_address addr;
+        rpc_address addr;
         addr.assign_group(name);
 
         ASSERT_EQ(HOST_TYPE_GROUP, addr.type());
@@ -134,7 +126,36 @@ TEST(core, dsn_address_build)
     }
 }
 
-TEST(core, rpc_group_address)
+TEST(rpc_address_test, operators)
+{
+    rpc_address addr(1234, 123);
+    ASSERT_EQ(addr, addr);
+
+    {
+        rpc_address new_addr(addr);
+        ASSERT_EQ(addr, new_addr);
+    }
+
+    {
+        rpc_address new_addr(1234, 321);
+        ASSERT_NE(addr, new_addr);
+    }
+
+    rpc_address addr_grp;
+    ASSERT_EQ(addr_grp, addr_grp);
+    ASSERT_NE(addr, addr_grp);
+
+    addr_grp.assign_group("test_group");
+    ASSERT_TRUE(addr_grp.group_address()->add(addr));
+    ASSERT_NE(addr, addr_grp);
+
+    {
+        rpc_address new_addr_grp(addr_grp);
+        ASSERT_EQ(addr_grp, new_addr_grp);
+    }
+}
+
+TEST(rpc_address_test, rpc_group_address)
 {
     rpc_address addr("127.0.0.1", 8080);
     rpc_address invalid_addr;
@@ -221,3 +242,5 @@ TEST(core, rpc_group_address)
     ASSERT_EQ(0u, g->members().size());
     ASSERT_EQ(invalid_addr, g->leader());
 }
+
+} // namespace dsn
diff --git a/src/runtime/test/async_call.cpp b/src/runtime/test/async_call.cpp
index aa850f3d9..fd161911c 100644
--- a/src/runtime/test/async_call.cpp
+++ b/src/runtime/test/async_call.cpp
@@ -47,7 +47,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include <gtest/gtest.h>
 #include <functional>
diff --git a/src/runtime/test/corrupt_message.cpp b/src/runtime/test/corrupt_message.cpp
index 81e9f2738..afca863f9 100644
--- a/src/runtime/test/corrupt_message.cpp
+++ b/src/runtime/test/corrupt_message.cpp
@@ -39,7 +39,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/task/async_calls.h"
 
 #include <boost/lexical_cast.hpp>
diff --git a/src/runtime/test/lpc.cpp b/src/runtime/test/lpc.cpp
index 2991619ab..8a0efbf5f 100644
--- a/src/runtime/test/lpc.cpp
+++ b/src/runtime/test/lpc.cpp
@@ -46,7 +46,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "test_utils.h"
 
 DEFINE_TASK_CODE(LPC_TEST_HASH, TASK_PRIORITY_COMMON, THREAD_POOL_TEST_SERVER)
diff --git a/src/runtime/test/meta_access_controller_test.cpp b/src/runtime/test/meta_access_controller_test.cpp
index 169a40a92..145dc0173 100644
--- a/src/runtime/test/meta_access_controller_test.cpp
+++ b/src/runtime/test/meta_access_controller_test.cpp
@@ -30,7 +30,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "runtime/security/access_controller.h"
diff --git a/src/runtime/test/netprovider.cpp b/src/runtime/test/netprovider.cpp
index cf188cfb4..62705d121 100644
--- a/src/runtime/test/netprovider.cpp
+++ b/src/runtime/test/netprovider.cpp
@@ -50,7 +50,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "runtime/task/task.h"
 #include "runtime/task/task_spec.h"
diff --git a/src/runtime/test/pipeline_test.cpp b/src/runtime/test/pipeline_test.cpp
index 7cc90f951..2bebfb649 100644
--- a/src/runtime/test/pipeline_test.cpp
+++ b/src/runtime/test/pipeline_test.cpp
@@ -38,7 +38,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 
diff --git a/src/runtime/test/replica_access_controller_test.cpp b/src/runtime/test/replica_access_controller_test.cpp
index 0615c35ba..c18b84801 100644
--- a/src/runtime/test/replica_access_controller_test.cpp
+++ b/src/runtime/test/replica_access_controller_test.cpp
@@ -29,7 +29,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "runtime/security/replica_access_controller.h"
diff --git a/src/runtime/test/rpc.cpp b/src/runtime/test/rpc.cpp
index 1864fe4e7..7d52973c2 100644
--- a/src/runtime/test/rpc.cpp
+++ b/src/runtime/test/rpc.cpp
@@ -43,7 +43,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "utils/priority_queue.h"
 #include "runtime/rpc/group_address.h"
@@ -59,7 +59,7 @@ static dsn::rpc_address build_group()
     server_group.assign_group("server_group.test");
     dsn::rpc_group_address *g = server_group.group_address();
     for (uint16_t p = TEST_PORT_BEGIN; p <= TEST_PORT_END; ++p) {
-        g->add(dsn::rpc_address("localhost", p));
+        CHECK(g->add(dsn::rpc_address("localhost", p)), "");
     }
 
     g->set_leader(dsn::rpc_address("localhost", TEST_PORT_BEGIN));
diff --git a/src/runtime/test/test_utils.h b/src/runtime/test/test_utils.h
index 50c47c79f..9bd90b625 100644
--- a/src/runtime/test/test_utils.h
+++ b/src/runtime/test/test_utils.h
@@ -47,7 +47,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/task/task.h"
 #include "runtime/task/task_worker.h"
 #include <gtest/gtest.h>
diff --git a/src/server/info_collector.cpp b/src/server/info_collector.cpp
index 33eedd809..36ac5606d 100644
--- a/src/server/info_collector.cpp
+++ b/src/server/info_collector.cpp
@@ -52,7 +52,7 @@ info_collector::info_collector()
 
     _meta_servers.assign_group("meta-servers");
     for (auto &ms : meta_servers) {
-        _meta_servers.group_address()->add(ms);
+        CHECK(_meta_servers.group_address()->add(ms), "");
     }
 
     _cluster_name = dsn::get_current_cluster_name();
diff --git a/src/server/info_collector.h b/src/server/info_collector.h
index db595b6a9..d0187eea2 100644
--- a/src/server/info_collector.h
+++ b/src/server/info_collector.h
@@ -32,7 +32,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "common/replication_other_types.h"
diff --git a/src/server/info_collector_app.cpp b/src/server/info_collector_app.cpp
index c04a8faea..87683b516 100644
--- a/src/server/info_collector_app.cpp
+++ b/src/server/info_collector_app.cpp
@@ -32,7 +32,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "common/replication_other_types.h"
 #include "common/replication.codes.h"
 #include "common/replication_other_types.h"
diff --git a/src/server/meta_store.cpp b/src/server/meta_store.cpp
index 6a4e69541..fd370e507 100644
--- a/src/server/meta_store.cpp
+++ b/src/server/meta_store.cpp
@@ -21,6 +21,7 @@
 
 #include "utils/fmt_logging.h"
 #include "utils/flags.h"
+#include "utils/string_conv.h"
 
 namespace pegasus {
 namespace server {
diff --git a/src/server/test/main.cpp b/src/server/test/main.cpp
index 23b0efaab..66ed54509 100644
--- a/src/server/test/main.cpp
+++ b/src/server/test/main.cpp
@@ -30,7 +30,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "replica/replication_service_app.h"
 #include "server/compaction_operation.h"
 #include "server/pegasus_server_impl.h"
diff --git a/src/test/function_test/throttle_test/test_throttle.cpp b/src/test/function_test/throttle_test/test_throttle.cpp
index b53cbce29..6ed974401 100644
--- a/src/test/function_test/throttle_test/test_throttle.cpp
+++ b/src/test/function_test/throttle_test/test_throttle.cpp
@@ -36,7 +36,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/fmt_logging.h"
 #include <fstream>
 
diff --git a/src/test/function_test/utils/global_env.cpp b/src/test/function_test/utils/global_env.cpp
index 91653bfe4..77eefd4f7 100644
--- a/src/test/function_test/utils/global_env.cpp
+++ b/src/test/function_test/utils/global_env.cpp
@@ -30,7 +30,7 @@
 
 #include "utils/fmt_logging.h"
 #include "utils/utils.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "runtime/api_layer1.h"
 #include "test/function_test/utils/utils.h"
 
diff --git a/src/test/function_test/utils/test_util.cpp b/src/test/function_test/utils/test_util.cpp
index 321e3b8fc..de82baf2a 100644
--- a/src/test/function_test/utils/test_util.cpp
+++ b/src/test/function_test/utils/test_util.cpp
@@ -24,7 +24,7 @@
 #include "base/pegasus_const.h"
 #include "client/replication_ddl_client.h"
 #include "common/replication_other_types.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "include/pegasus/client.h"
 #include "test/function_test/utils/global_env.h"
 #include "test/function_test/utils/utils.h"
diff --git a/src/test/kill_test/data_verifier.cpp b/src/test/kill_test/data_verifier.cpp
index 68a15c0fe..d92aa40d4 100644
--- a/src/test/kill_test/data_verifier.cpp
+++ b/src/test/kill_test/data_verifier.cpp
@@ -41,7 +41,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "pegasus/client.h"
 #include "data_verifier.h"
diff --git a/src/test/kill_test/kill_testor.cpp b/src/test/kill_test/kill_testor.cpp
index 6f506b26d..3dcf0b98c 100644
--- a/src/test/kill_test/kill_testor.cpp
+++ b/src/test/kill_test/kill_testor.cpp
@@ -32,7 +32,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "client/replication_ddl_client.h"
 #include <pegasus/client.h>
 
diff --git a/src/utils/distributed_lock_service.h b/src/utils/distributed_lock_service.h
index 0517f067e..87c1fee8e 100644
--- a/src/utils/distributed_lock_service.h
+++ b/src/utils/distributed_lock_service.h
@@ -53,7 +53,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/error_code.h"
 #include "runtime/task/future_types.h"
 #include <string>
diff --git a/src/utils/test/file_utils.cpp b/src/utils/test/file_utils.cpp
index 0a567721a..a2c5a64c9 100644
--- a/src/utils/test/file_utils.cpp
+++ b/src/utils/test/file_utils.cpp
@@ -37,7 +37,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/utils.h"
 #include "utils/filesystem.h"
 #include <fstream>
diff --git a/src/utils/test/hostname_test.cpp b/src/utils/test/hostname_test.cpp
index 42452bbe0..9f4c8a69e 100644
--- a/src/utils/test/hostname_test.cpp
+++ b/src/utils/test/hostname_test.cpp
@@ -15,11 +15,12 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "utils/utils.h"
-
-#include "utils/rpc_address.h"
+#include <arpa/inet.h>
 #include <gtest/gtest.h>
 
+#include "runtime/rpc/rpc_address.h"
+#include "utils/utils.h"
+
 namespace dsn {
 namespace replication {
 
diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp
index 874951420..f6262fa8c 100644
--- a/src/utils/utils.cpp
+++ b/src/utils/utils.cpp
@@ -59,7 +59,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "utils/singleton.h"
 #include <sys/stat.h>
 #include <sys/types.h>
diff --git a/src/utils/utils.h b/src/utils/utils.h
index d770b7fb3..8fc2edb72 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -27,9 +27,11 @@
 #pragma once
 
 #include <functional>
+#include <map>
 #include <memory>
+#include <set>
 
-#include "rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include "string_view.h"
 
 #define TIME_MS_MAX 0xffffffff
diff --git a/src/utils/zlocks.h b/src/utils/zlocks.h
index de8c5e170..36cfbba8f 100644
--- a/src/utils/zlocks.h
+++ b/src/utils/zlocks.h
@@ -27,6 +27,8 @@
 #pragma once
 
 #include <algorithm>
+#include <atomic>
+
 #include "utils/utils.h"
 
 ///
diff --git a/src/zookeeper/test/distributed_lock_zookeeper.cpp b/src/zookeeper/test/distributed_lock_zookeeper.cpp
index b55f656e1..338a9c4d7 100644
--- a/src/zookeeper/test/distributed_lock_zookeeper.cpp
+++ b/src/zookeeper/test/distributed_lock_zookeeper.cpp
@@ -44,7 +44,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 #include "zookeeper/distributed_lock_service_zookeeper.h"
 #include "zookeeper/lock_struct.h"
diff --git a/src/zookeeper/test/main.cpp b/src/zookeeper/test/main.cpp
index e9a80d00d..a450e019b 100644
--- a/src/zookeeper/test/main.cpp
+++ b/src/zookeeper/test/main.cpp
@@ -44,7 +44,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 
 int g_test_count = 0;
 int g_test_ret = 0;
diff --git a/src/zookeeper/zookeeper_session_mgr.h b/src/zookeeper/zookeeper_session_mgr.h
index 83e130bfb..de9d86f0a 100644
--- a/src/zookeeper/zookeeper_session_mgr.h
+++ b/src/zookeeper/zookeeper_session_mgr.h
@@ -46,7 +46,7 @@
 #include "runtime/rpc/rpc_stream.h"
 #include "runtime/serverlet.h"
 #include "runtime/service_app.h"
-#include "utils/rpc_address.h"
+#include "runtime/rpc/rpc_address.h"
 #include <string>
 
 #pragma once


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org