@@ -167,9 +167,19 @@ dsn::error_code replication_ddl_client::wait_app_ready(const std::string &app_na
167167 int ready_count = 0 ;
168168 for (int i = 0 ; i < partition_count; i++) {
169169 const auto &pc = query_resp.partitions [i];
170- if (pc.hp_primary && (pc.hp_secondaries .size () + 1 >= max_replica_count)) {
171- ready_count++;
170+ host_port primary;
171+ GET_HOST_PORT (pc, primary, primary);
172+ if (!primary) {
173+ continue ;
174+ }
175+
176+ std::vector<host_port> secondaries;
177+ GET_HOST_PORTS (pc, secondaries, secondaries);
178+ if (secondaries.size () + 1 < max_replica_count) {
179+ continue ;
172180 }
181+
182+ ready_count++;
173183 }
174184 if (ready_count == partition_count) {
175185 std::cout << app_name << " is ready now: (" << ready_count << " /" << partition_count
@@ -435,11 +445,16 @@ dsn::error_code replication_ddl_client::list_apps(const dsn::app_status::type st
435445 int read_unhealthy = 0 ;
436446 for (const auto &pc : pcs) {
437447 int replica_count = 0 ;
438- if (pc.hp_primary ) {
448+ host_port primary;
449+ GET_HOST_PORT (pc, primary, primary);
450+ if (primary) {
439451 replica_count++;
440452 }
441- replica_count += pc.hp_secondaries .size ();
442- if (pc.hp_primary ) {
453+
454+ std::vector<host_port> secondaries;
455+ GET_HOST_PORTS (pc, secondaries, secondaries);
456+ replica_count += secondaries.size ();
457+ if (primary) {
443458 if (replica_count >= pc.max_replica_count ) {
444459 fully_healthy++;
445460 } else if (replica_count < 2 ) {
@@ -573,13 +588,18 @@ dsn::error_code replication_ddl_client::list_nodes(const dsn::replication::node_
573588 }
574589
575590 for (const auto &pc : pcs) {
576- if (pc.hp_primary ) {
577- auto find = tmp_map.find (pc.hp_primary );
591+ host_port primary;
592+ GET_HOST_PORT (pc, primary, primary);
593+ if (primary) {
594+ auto find = tmp_map.find (primary);
578595 if (find != tmp_map.end ()) {
579596 find->second .primary_count ++;
580597 }
581598 }
582- for (const auto &secondary : pc.hp_secondaries ) {
599+
600+ std::vector<host_port> secondaries;
601+ GET_HOST_PORTS (pc, secondaries, secondaries);
602+ for (const auto &secondary : secondaries) {
583603 auto find = tmp_map.find (secondary);
584604 if (find != tmp_map.end ()) {
585605 find->second .secondary_count ++;
@@ -766,14 +786,18 @@ dsn::error_code replication_ddl_client::list_app(const std::string &app_name,
766786 int read_unhealthy = 0 ;
767787 for (const auto &pc : pcs) {
768788 int replica_count = 0 ;
769- if (pc.hp_primary ) {
789+ host_port primary;
790+ GET_HOST_PORT (pc, primary, primary);
791+ if (primary) {
770792 replica_count++;
771- node_stat[pc. hp_primary ].first ++;
793+ node_stat[primary ].first ++;
772794 total_prim_count++;
773795 }
774- replica_count += pc.hp_secondaries .size ();
775- total_sec_count += pc.hp_secondaries .size ();
776- if (pc.hp_primary ) {
796+ std::vector<host_port> secondaries;
797+ GET_HOST_PORTS (pc, secondaries, secondaries);
798+ replica_count += secondaries.size ();
799+ total_sec_count += secondaries.size ();
800+ if (primary) {
777801 if (replica_count >= pc.max_replica_count ) {
778802 fully_healthy++;
779803 } else if (replica_count < 2 ) {
@@ -783,14 +807,14 @@ dsn::error_code replication_ddl_client::list_app(const std::string &app_name,
783807 write_unhealthy++;
784808 read_unhealthy++;
785809 }
786- for (const auto &secondary : pc. hp_secondaries ) {
810+ for (const auto &secondary : secondaries ) {
787811 node_stat[secondary].second ++;
788812 }
789813 tp_details.add_row (pc.pid .get_partition_index ());
790814 tp_details.append_data (pc.ballot );
791815 tp_details.append_data (fmt::format (" {}/{}" , replica_count, pc.max_replica_count ));
792- tp_details.append_data (pc. hp_primary ? pc. hp_primary .to_string () : " -" );
793- tp_details.append_data (fmt::format (" [{}]" , fmt::join (pc. hp_secondaries , " ," )));
816+ tp_details.append_data (primary ? primary .to_string () : " -" );
817+ tp_details.append_data (fmt::format (" [{}]" , fmt::join (secondaries , " ," )));
794818 }
795819 mtp.add (std::move (tp_details));
796820
0 commit comments