From b46d823652d1ea395a890f3d0ccc8b51a4b2ee0e Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Tue, 30 Apr 2024 01:07:24 +0800 Subject: [PATCH] 8 --- src/meta/cluster_balance_policy.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/meta/cluster_balance_policy.cpp b/src/meta/cluster_balance_policy.cpp index e6897cc7e7..faa2e9f461 100644 --- a/src/meta/cluster_balance_policy.cpp +++ b/src/meta/cluster_balance_policy.cpp @@ -226,13 +226,18 @@ bool cluster_balance_policy::get_app_migration_info(std::shared_ptr a info.partitions.resize(app->pcs.size()); for (auto i = 0; i < app->pcs.size(); ++i) { std::map 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 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; }