Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GehaFearless committed Feb 2, 2024
1 parent db125b6 commit 205daf8
Show file tree
Hide file tree
Showing 28 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion idl/bulk_load.thrift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// licensed to the apache software foundation (asf) under one
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
Expand Down
2 changes: 1 addition & 1 deletion idl/partition_split.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct update_child_group_partition_count_request
2:i32 new_partition_count;
3:dsn.gpid child_pid;
4:i64 ballot;
5:optional dsn.host_port target_host_port;
5:optional dsn.host_port hp_target_address;
}

struct update_child_group_partition_count_response
Expand Down
2 changes: 1 addition & 1 deletion src/client/partition_resolver_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ partition_resolver_manager::find_or_create(const char *cluster_name,
ptr = new partition_resolver_simple(meta_group, app_name, dns_resolver);
return ptr;
} else {
dsn::host_port meta_group = ptr->get_meta_server();
const auto &meta_group = ptr->get_meta_server();
const auto &existing_list = meta_group.group_host_port()->members();
if (!vector_equal(meta_list, existing_list)) {
LOG_ERROR("meta list not match for cluster({})", cluster_name);
Expand Down
4 changes: 2 additions & 2 deletions src/failure_detector/failure_detector_multimaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void slave_failure_detector_with_multimaster::end_ping(::dsn::error_code err,
CHECK_EQ(hp_this_node, _meta_servers.group_host_port()->leader());

if (ERR_OK != err) {
host_port next = _meta_servers.group_host_port()->next(hp_this_node);
auto next = _meta_servers.group_host_port()->next(hp_this_node);
if (next != hp_this_node) {
_meta_servers.group_host_port()->set_leader(next);
// do not start next send_beacon() immediately to avoid send rpc too frequently
Expand All @@ -105,7 +105,7 @@ void slave_failure_detector_with_multimaster::end_ping(::dsn::error_code err,
if (ack.is_master) {
// do nothing
} else if (hp_primary_node.is_invalid()) {
host_port next = _meta_servers.group_host_port()->next(hp_this_node);
auto next = _meta_servers.group_host_port()->next(hp_this_node);
if (next != hp_this_node) {
_meta_servers.group_host_port()->set_leader(next);
// do not start next send_beacon() immediately to avoid send rpc too frequently
Expand Down
1 change: 0 additions & 1 deletion src/meta/app_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ void app_balance_policy::balance(bool checker, const meta_view *global_view, mig
{
init(global_view, list);
const app_mapper &apps = *_global_view->apps;

if (!execute_balance(apps,
checker,
_balancer_in_turn,
Expand Down
4 changes: 2 additions & 2 deletions src/meta/load_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ gpid copy_replica_operation::select_max_load_gpid(const partition_set *partition

void copy_replica_operation::copy_once(gpid selected_pid, migration_list *result)
{
auto from = _host_port_vec[*_ordered_host_port_ids.rbegin()];
auto to = _host_port_vec[*_ordered_host_port_ids.begin()];
const auto &from = _host_port_vec[*_ordered_host_port_ids.rbegin()];
const auto &to = _host_port_vec[*_ordered_host_port_ids.begin()];

auto pc = _app->partitions[selected_pid.get_partition_index()];
auto request = generate_balancer_request(_apps,
Expand Down
3 changes: 1 addition & 2 deletions src/meta/meta_bulk_load_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ void bulk_load_service::partition_bulk_load(const std::string &app_name, const g
if (!bulk_load_resp.__isset.hp_group_bulk_load_state) {
bulk_load_resp.__set_hp_group_bulk_load_state({});
for (const auto &kv : bulk_load_resp.group_bulk_load_state) {
auto hp = host_port(kv.first);
bulk_load_resp.hp_group_bulk_load_state[hp] = kv.second;
bulk_load_resp.hp_group_bulk_load_state[host_port(kv.first)] = kv.second;
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/meta/server_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,8 +1640,7 @@ void server_state::update_configuration_locally(
}
} else {
for (const auto &secondary : config_request->config.secondaries) {
auto hp_secondary = host_port(secondary);
auto secondary_node = get_node_state(_nodes, hp_secondary, false);
auto secondary_node = get_node_state(_nodes, host_port(secondary), false);
secondary_node->put_partition(gpid, false);
}
}
Expand Down
66 changes: 33 additions & 33 deletions src/meta/test/copy_replica_operation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ TEST(copy_primary_operation, misc)
app_mapper apps;
apps[app_id] = app;

const auto &addr1 = host_port("localhost", 1);
const auto &addr2 = host_port("localhost", 2);
const auto &addr3 = host_port("localhost", 3);
const auto &hp1 = host_port("localhost", 1);
const auto &hp2 = host_port("localhost", 2);
const auto &hp3 = host_port("localhost", 3);

node_mapper nodes;
node_state ns1;
ns1.put_partition(gpid(app_id, 2), true);
ns1.put_partition(gpid(app_id, 0), false);
nodes[addr1] = ns1;
nodes[hp1] = ns1;
node_state ns2;
ns2.put_partition(gpid(app_id, 0), true);
ns2.put_partition(gpid(app_id, 1), true);
nodes[addr2] = ns2;
nodes[hp2] = ns2;
node_state ns3;
ns3.put_partition(gpid(app_id, 2), false);
nodes[addr3] = ns3;
nodes[hp3] = ns3;

std::vector<dsn::host_port> host_port_vec{addr1, addr2, addr3};
std::vector<dsn::host_port> host_port_vec{hp1, hp2, hp3};
std::unordered_map<dsn::host_port, int> host_port_id;
host_port_id[addr1] = 0;
host_port_id[addr2] = 1;
host_port_id[addr3] = 2;
host_port_id[hp1] = 0;
host_port_id[hp2] = 1;
host_port_id[hp3] = 2;
auto resolver = std::make_shared<dns_resolver>();
copy_primary_operation op(app, apps, nodes, host_port_vec, host_port_id, false, 0, resolver);

Expand Down Expand Up @@ -99,14 +99,14 @@ TEST(copy_primary_operation, misc)
disk_load load;
load[disk1] = 2;
load[disk2] = 6;
op._node_loads[addr2] = load;
op._node_loads[hp2] = load;

serving_replica serving_partition0;
serving_partition0.node = addr2;
serving_partition0.node = hp2;
serving_partition0.disk_tag = disk1;
app->helpers->contexts[0].serving.push_back(serving_partition0);
serving_replica serving_partition1;
serving_partition1.node = addr2;
serving_partition1.node = hp2;
serving_partition1.disk_tag = disk2;
app->helpers->contexts[1].serving.push_back(serving_partition1);

Expand All @@ -128,17 +128,17 @@ TEST(copy_primary_operation, misc)
ASSERT_TRUE(op.can_continue());
op._replicas_low = 0;

nodes[addr2].remove_partition(gpid(app_id, 1), false);
nodes[hp2].remove_partition(gpid(app_id, 1), false);
op.init_ordered_host_port_ids();
ASSERT_FALSE(op.can_continue());
nodes[addr2].put_partition(gpid(app_id, 1), true);
nodes[hp2].put_partition(gpid(app_id, 1), true);

/**
* Test update_ordered_host_port_ids
*/
nodes[addr1].put_partition(gpid(app_id, 3), true);
nodes[addr2].put_partition(gpid(app_id, 4), true);
nodes[addr2].put_partition(gpid(app_id, 5), true);
nodes[hp1].put_partition(gpid(app_id, 3), true);
nodes[hp2].put_partition(gpid(app_id, 4), true);
nodes[hp2].put_partition(gpid(app_id, 5), true);
op.init_ordered_host_port_ids();
op.update_ordered_host_port_ids();
ASSERT_EQ(op._ordered_host_port_ids.size(), 3);
Expand Down Expand Up @@ -206,27 +206,27 @@ TEST(copy_secondary_operation, misc)
app_mapper apps;
apps[app_id] = app;

const auto &addr1 = host_port("localhost", 1);
const auto &addr2 = host_port("localhost", 2);
const auto &addr3 = host_port("localhost", 3);
const auto &hp1 = host_port("localhost", 1);
const auto &hp2 = host_port("localhost", 2);
const auto &hp3 = host_port("localhost", 3);

node_mapper nodes;
node_state ns1;
ns1.put_partition(gpid(app_id, 2), true);
ns1.put_partition(gpid(app_id, 0), false);
nodes[addr1] = ns1;
nodes[hp1] = ns1;
node_state ns2;
ns2.put_partition(gpid(app_id, 0), true);
ns2.put_partition(gpid(app_id, 1), true);
nodes[addr2] = ns2;
nodes[hp2] = ns2;
node_state ns3;
nodes[addr3] = ns3;
nodes[hp3] = ns3;

std::vector<dsn::host_port> host_port_vec{addr1, addr2, addr3};
std::vector<dsn::host_port> host_port_vec{hp1, hp2, hp3};
std::unordered_map<dsn::host_port, int> host_port_id;
host_port_id[addr1] = 0;
host_port_id[addr2] = 1;
host_port_id[addr3] = 2;
host_port_id[hp1] = 0;
host_port_id[hp2] = 1;
host_port_id[hp3] = 2;
auto resolver = std::make_shared<dns_resolver>();
copy_secondary_operation op(app, apps, nodes, host_port_vec, host_port_id, resolver, 0);
op.init_ordered_host_port_ids();
Expand All @@ -249,16 +249,16 @@ TEST(copy_secondary_operation, misc)
ASSERT_FALSE(res);
op._replicas_low = 0;

nodes[addr3].put_partition(gpid(app_id, 2), false);
nodes[hp3].put_partition(gpid(app_id, 2), false);
op.init_ordered_host_port_ids();
res = op.can_continue();
ASSERT_FALSE(res);
nodes[addr3].remove_partition(gpid(app_id, 2), false);
nodes[hp3].remove_partition(gpid(app_id, 2), false);

/**
* Test copy_secondary_operation::can_select
*/
nodes[addr1].put_partition(gpid(app_id, 3), true);
nodes[hp1].put_partition(gpid(app_id, 3), true);
op.init_ordered_host_port_ids();
migration_list list;
res = op.can_select(gpid(app_id, 3), &list);
Expand All @@ -270,12 +270,12 @@ TEST(copy_secondary_operation, misc)
ASSERT_FALSE(res);
list.clear();

nodes[addr3].put_partition(secondary_gpid, true);
nodes[hp3].put_partition(secondary_gpid, true);
op.init_ordered_host_port_ids();
res = op.can_select(secondary_gpid, &list);
ASSERT_FALSE(res);

nodes[addr3].remove_partition(secondary_gpid, false);
nodes[hp3].remove_partition(secondary_gpid, false);
op.init_ordered_host_port_ids();
res = op.can_select(secondary_gpid, &list);
ASSERT_TRUE(res);
Expand Down
4 changes: 2 additions & 2 deletions src/meta/test/state_sync_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ static void random_assign_partition_config(
indices.push_back(random32(start, max_servers));
start = indices.back() + 1;
}
auto server = get_server(indices[0]);
const auto &server = get_server(indices[0]);
pc.primary = server.second;
pc.__set_hp_primary(server.first);
if (!pc.__isset.hp_secondaries) {
pc.__set_hp_secondaries({});
}
for (int i = 1; i < indices.size(); ++i) {
auto s = get_server(indices[i]);
const auto &s = get_server(indices[i]);
if (!s.first.is_invalid()) {
pc.secondaries.push_back(s.second);
pc.hp_secondaries.push_back(s.first);
Expand Down
36 changes: 18 additions & 18 deletions src/nfs/nfs.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ namespace cpp dsn.service

struct copy_request
{
1: dsn.rpc_address source;
2: string source_dir;
3: string dst_dir;
4: string file_name;
5: i64 offset;
6: i32 size;
7: bool is_last;
8: bool overwrite;
9: optional string source_disk_tag;
10: optional dsn.gpid pid;
1: dsn.rpc_address source;
2: string source_dir;
3: string dst_dir;
4: string file_name;
5: i64 offset;
6: i32 size;
7: bool is_last;
8: bool overwrite;
9: optional string source_disk_tag;
10: optional dsn.gpid pid;
11: optional dsn.host_port hp_source;
}

Expand All @@ -53,14 +53,14 @@ struct copy_response

struct get_file_size_request
{
1: dsn.rpc_address source;
2: string dst_dir;
3: list<string> file_list;
4: string source_dir;
5: bool overwrite;
6: optional string source_disk_tag;
7: optional string dest_disk_tag;
8: optional dsn.gpid pid;
1: dsn.rpc_address source;
2: string dst_dir;
3: list<string> file_list;
4: string source_dir;
5: bool overwrite;
6: optional string source_disk_tag;
7: optional string dest_disk_tag;
8: optional dsn.gpid pid;
9: optional dsn.host_port hp_source;
}

Expand Down
1 change: 0 additions & 1 deletion src/nfs/nfs_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
namespace dsn {
class command_deregister;
class disk_file;

namespace utils {
class token_buckets;
} // namespace utils
Expand Down
1 change: 0 additions & 1 deletion src/nfs/nfs_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

namespace dsn {
class task_tracker;

namespace service {
class copy_request;
class copy_response;
Expand Down
2 changes: 1 addition & 1 deletion src/replica/bulk_load/replica_bulk_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void replica_bulk_loader::broadcast_group_bulk_load(const bulk_load_request &met

auto request = std::make_unique<group_bulk_load_request>();
request->app_name = _replica->_app_info.app_name;
auto addr = _stub->get_dns_resolver()->resolve_address(hp);
const auto &addr = _stub->get_dns_resolver()->resolve_address(hp);
request->target = addr;
request->__set_hp_target(hp);
_replica->_primary_states.get_replica_config(partition_status::PS_SECONDARY,
Expand Down
2 changes: 1 addition & 1 deletion src/replica/replica_2pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void replica::on_prepare_reply(std::pair<mutation_ptr, partition_status::type> p

CHECK_EQ_MSG(mu->data.header.ballot, get_ballot(), "{}: invalid mutation ballot", mu->name());

auto node = request->to_host_port;
const auto &node = request->to_host_port;
partition_status::type st = _primary_states.get_node_status(node);

// handle reply
Expand Down
4 changes: 2 additions & 2 deletions src/replica/replica_restore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ void replica::tell_meta_to_restore_rollback()
dsn::message_ex *msg = dsn::message_ex::create_request(RPC_CM_DROP_APP);
::dsn::marshall(msg, request);

auto target =
const auto &target =
_stub->get_dns_resolver()->resolve_address(_stub->_failure_detector->get_servers());
rpc::call(target,
msg,
Expand Down Expand Up @@ -433,7 +433,7 @@ void replica::report_restore_status_to_meta()

dsn::message_ex *msg = dsn::message_ex::create_request(RPC_CM_REPORT_RESTORE_STATUS);
::dsn::marshall(msg, request);
auto target =
const auto &target =
_stub->get_dns_resolver()->resolve_address(_stub->_failure_detector->get_servers());
rpc::call(target,
msg,
Expand Down
5 changes: 2 additions & 3 deletions src/replica/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,6 @@ void replica_stub::initialize_start()

// init liveness monitor
CHECK_EQ(NS_Disconnected, _state);

if (!FLAGS_fd_disabled) {
_failure_detector = std::make_shared<dsn::dist::slave_failure_detector_with_multimaster>(
_dns_resolver,
Expand Down Expand Up @@ -1223,7 +1222,7 @@ void replica_stub::query_configuration_by_node()
LOG_INFO("send query node partitions request to meta server, stored_replicas_count = {}",
req.stored_replicas.size());

auto target = _dns_resolver->resolve_address(_failure_detector->get_servers());
const auto &target = _dns_resolver->resolve_address(_failure_detector->get_servers());
_config_query_task =
rpc::call(target,
msg,
Expand Down Expand Up @@ -1433,7 +1432,7 @@ void replica_stub::remove_replica_on_meta_server(const app_info &info,

::dsn::marshall(msg, *request);

auto target = _dns_resolver->resolve_address(_failure_detector->get_servers());
const auto &target = _dns_resolver->resolve_address(_failure_detector->get_servers());
rpc::call(target, msg, nullptr, [](error_code err, dsn::message_ex *, dsn::message_ex *) {});
}

Expand Down
Loading

0 comments on commit 205daf8

Please sign in to comment.