Skip to content

Commit

Permalink
8
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Apr 29, 2024
1 parent b0a5829 commit b46d823
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/meta/cluster_balance_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,18 @@ bool cluster_balance_policy::get_app_migration_info(std::shared_ptr<app_state> a
info.partitions.resize(app->pcs.size());
for (auto i = 0; i < app->pcs.size(); ++i) {
std::map<host_port, partition_status::type> pstatus_map;
pstatus_map[app->pcs[i].hp_primary1] = partition_status::PS_PRIMARY;
if (app->pcs[i].hp_secondaries1.size() != app->pcs[i].max_replica_count - 1) {
host_port primary;
GET_HOST_PORT(app->pcs[i], primary1, primary);
pstatus_map[primary] = partition_status::PS_PRIMARY;

std::vector<host_port> secondaries;
GET_HOST_PORTS(app->pcs[i], secondaries1, secondaries);
if (secondaries.size() != app->pcs[i].max_replica_count - 1) {
// partition is unhealthy
return false;
}
for (const auto &hp : app->pcs[i].hp_secondaries1) {
pstatus_map[hp] = partition_status::PS_SECONDARY;
for (const auto &secondary : secondaries) {
pstatus_map[secondary] = partition_status::PS_SECONDARY;
}
info.partitions[i] = pstatus_map;
}
Expand Down

0 comments on commit b46d823

Please sign in to comment.