You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by GitBox <gi...@apache.org> on 2022/02/18 03:45:58 UTC

[GitHub] [incubator-pegasus] empiredan opened a new pull request #914: feat: support to get/set the replication factor of each table

empiredan opened a new pull request #914:
URL: https://github.com/apache/incubator-pegasus/pull/914


   https://github.com/apache/incubator-pegasus/issues/865


-- 
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-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #914: feat: support to get/set the replication factor of each table

Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #914:
URL: https://github.com/apache/incubator-pegasus/pull/914#discussion_r817382122



##########
File path: src/shell/command_utils.cpp
##########
@@ -45,3 +45,35 @@ bool validate_ip(shell_context *sc,
     err_info = fmt::format("invalid ip:port={}, can't find it in the cluster", ip_str);
     return false;
 }
+
+bool confirm_unsafe_command(const char *action)

Review comment:
       const char *action ==> const std::string &action




-- 
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-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


[GitHub] [incubator-pegasus] levy5307 commented on a change in pull request #914: feat: support to get/set the replication factor of each table

Posted by GitBox <gi...@apache.org>.
levy5307 commented on a change in pull request #914:
URL: https://github.com/apache/incubator-pegasus/pull/914#discussion_r817381454



##########
File path: src/shell/commands/table_management.cpp
##########
@@ -886,3 +886,108 @@ bool clear_app_envs(command_executor *e, shell_context *sc, arguments args)
     }
     return true;
 }
+
+bool get_max_replica_count(command_executor *e, shell_context *sc, arguments args)
+{
+    if (args.argc < 2) {
+        return false;
+    }
+
+    std::string app_name(args.argv[1]);
+
+    auto err_resp = sc->ddl_client->get_max_replica_count(app_name);
+    auto err = err_resp.get_error();
+    const auto &resp = err_resp.get_value();
+
+    if (err.is_ok()) {
+        err = dsn::error_s::make(resp.err);
+    }
+
+    std::string escaped_app_name(pegasus::utils::c_escape_string(app_name));
+    if (err.is_ok()) {
+        fmt::print(stdout,
+                   "the replica count of app({}) is {}\n",
+                   escaped_app_name,
+                   resp.max_replica_count);
+    } else {
+        fmt::print(stdout,
+                   "get replica count of app({}) failed: {}\n",
+                   escaped_app_name,
+                   err);
+    }
+
+    return true;
+}
+
+bool set_max_replica_count(command_executor *e, shell_context *sc, arguments args)
+{
+    if (args.argc < 3) {
+        return false;
+    }
+
+    int new_max_replica_count;
+    if (!dsn::buf2int32(args.argv[2], new_max_replica_count)) {
+        fmt::print(stderr, "parse {} as replica count failed\n", args.argv[2]);
+        return false;
+    }
+
+    if (new_max_replica_count < 1) {
+        fmt::print(stderr, "replica count should be >= 1\n");
+        return false;
+    }
+
+    std::string app_name(args.argv[1]);
+    std::string escaped_app_name(pegasus::utils::c_escape_string(app_name));
+    std::string action(fmt::format(
+        "set the replica count of app({}) to {}", escaped_app_name, new_max_replica_count));
+    if (!confirm_unsafe_command(action.c_str())) {
+        return true;
+    }
+
+    auto err_resp = sc->ddl_client->set_max_replica_count(app_name, new_max_replica_count);
+    auto err = err_resp.get_error();
+    const auto &resp = err_resp.get_value();
+
+    if (err.is_ok()) {

Review comment:
       dsn_likely




-- 
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-unsubscribe@pegasus.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org