Skip to content

Commit

Permalink
refactor(rpc_address): simple refactor on rpc_address
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Nov 22, 2022
1 parent b26a113 commit 08a3f0b
Show file tree
Hide file tree
Showing 95 changed files with 340 additions and 283 deletions.
6 changes: 3 additions & 3 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion scripts/recompile_thrift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions src/aio/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 6 additions & 2 deletions src/base/pegasus_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion src/block_service/block_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
28 changes: 15 additions & 13 deletions src/block_service/fds/fds_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,33 @@
// 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 <string.h>

#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/delete_multi_objects_result.h>
#include <model/fds_object_metadata.h>
#include <model/fds_object.h>
#include <model/fds_object_summary.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/error_code.h"
#include "utils/defer.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 {
Expand Down
2 changes: 1 addition & 1 deletion src/block_service/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/client/partition_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/client/partition_resolver_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/replication_ddl_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/common/fs_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 6 additions & 4 deletions src/common/replication_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/common/replication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/common/storage_serverlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/common/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions src/failure_detector/failure_detector_multimaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/failure_detector/fd.code.definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/failure_detector/test/failure_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/failure_detector/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/geo/lib/geo_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion src/geo/lib/latlng_codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/meta/dump_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
7 changes: 4 additions & 3 deletions src/meta/load_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/meta/meta_bulk_load_ingestion_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions src/meta/meta_bulk_load_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/meta/meta_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading

0 comments on commit 08a3f0b

Please sign in to comment.