empiredan commented on code in PR #1035: URL: https://github.com/apache/incubator-pegasus/pull/1035#discussion_r918516377
########## rdsn/src/meta/meta_service.cpp: ########## @@ -1306,5 +1306,15 @@ void meta_service::on_set_max_replica_count(configuration_set_max_replica_count_ server_state::sStateHash); } +int32_t meta_service::mutation_2pc_min_replica_count(int32_t app_max_replica_count) const +{ + dassert_f(app_max_replica_count > 0, "max_replica_count > 0"); + if (_opts.mutation_2pc_min_replica_count > 0) { // >0 means use the user config + return _opts.mutation_2pc_min_replica_count; + } else { // otherwise, the value based on the table max_replica_count + return app_max_replica_count <= 2 ? 1 : app_max_replica_count / 2 + 1; + } +} + Review Comment: I think we can encapsulate this logic into a function `int32_t mutation_2pc_min_replica_count(int32_t 2pc_min_replica_count, int32_t app_max_replica_count)`, and put in `rdsn/src/common/replication_common.h` ? Therefore both functions can just be implemented like this: ```C++ int32_t meta_service::mutation_2pc_min_replica_count(int32_t app_max_replica_count) const { return mutation_2pc_min_replica_count(_opts.mutation_2pc_min_replica_count, app_max_replica_count); } int32_t replica::mutation_2pc_min_replica_count() const { return mutation_2pc_min_replica_count(_options->mutation_2pc_min_replica_count, _app_info.max_replica_count); } ``` ########## rdsn/src/meta/meta_service.cpp: ########## @@ -1306,5 +1306,15 @@ void meta_service::on_set_max_replica_count(configuration_set_max_replica_count_ server_state::sStateHash); } +int32_t meta_service::mutation_2pc_min_replica_count(int32_t app_max_replica_count) const +{ + dassert_f(app_max_replica_count > 0, "max_replica_count > 0"); Review Comment: dcheck_gt(app_max_replica_count, 0); -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pegasus.apache.org For additional commands, e-mail: dev-h...@pegasus.apache.org