Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
refactor: move on_redundant_secondary from simple_load_balancer to pa…
Browse files Browse the repository at this point in the history
…rtition_guardian (#854)
  • Loading branch information
levy5307 authored Jul 14, 2021
1 parent 1275b1b commit e31d49c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/meta/partition_guardian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,26 @@ pc_status partition_guardian::on_missing_secondary(meta_view &view, const dsn::g

pc_status partition_guardian::on_redundant_secondary(meta_view &view, const dsn::gpid &gpid)
{
// TBD(zlw)
return pc_status::invalid;
const node_mapper &nodes = *(view.nodes);
const partition_configuration &pc = *get_config(*(view.apps), gpid);
int target = 0;
int load = nodes.find(pc.secondaries.front())->second.partition_count();
for (int i = 0; i != pc.secondaries.size(); ++i) {
int l = nodes.find(pc.secondaries[i])->second.partition_count();
if (l > load) {
load = l;
target = i;
}
}

configuration_proposal_action action;
action.type = config_type::CT_REMOVE;
action.node = pc.secondaries[target];
action.target = pc.primary;

// TODO: treat remove as cure proposals too
get_config_context(*view.apps, gpid)->lb_actions.assign_balancer_proposals({action});
return pc_status::ill;
}
} // namespace replication
} // namespace dsn

0 comments on commit e31d49c

Please sign in to comment.