You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "xiaobiaozhao (via GitHub)" <gi...@apache.org> on 2023/05/05 14:22:17 UTC

[GitHub] [incubator-kvrocks] xiaobiaozhao commented on a diff in pull request #1418: support sync migration

xiaobiaozhao commented on code in PR #1418:
URL: https://github.com/apache/incubator-kvrocks/pull/1418#discussion_r1186022617


##########
src/commands/cmd_cluster.cc:
##########
@@ -126,11 +127,28 @@ class CommandClusterX : public Commander {
     if (subcommand_ == "setnodeid" && args_.size() == 3 && args_[2].size() == kClusterNodeIdLen) return Status::OK();
 
     if (subcommand_ == "migrate") {
-      if (args.size() != 4) return {Status::RedisParseErr, errWrongNumOfArguments};
+      if (args.size() < 4) return {Status::RedisParseErr, errWrongNumOfArguments};

Review Comment:
   I think we can do a strong check here
   eg : args.size() must be 5/6



##########
src/cluster/slot_migrate.h:
##########
@@ -80,8 +82,8 @@ class SlotMigrator : public redis::Database {
   ~SlotMigrator();
 
   Status CreateMigrationThread();
-  Status PerformSlotMigration(const std::string &node_id, std::string &dst_ip, int dst_port, int slot_id, int speed,
-                              int pipeline_size, int seq_gap);
+  Status PerformSlotMigration(const std::string &node_id, std::string &dst_ip, int dst_port, int slot_id,
+                              const std::shared_ptr<SyncMigrateContext> &blocking_ctx = nullptr);

Review Comment:
   I think std::shared_ptr<T> blocking_ctx is enough



##########
src/commands/cmd_cluster.cc:
##########
@@ -126,11 +127,28 @@ class CommandClusterX : public Commander {
     if (subcommand_ == "setnodeid" && args_.size() == 3 && args_[2].size() == kClusterNodeIdLen) return Status::OK();
 
     if (subcommand_ == "migrate") {
-      if (args.size() != 4) return {Status::RedisParseErr, errWrongNumOfArguments};
+      if (args.size() < 4) return {Status::RedisParseErr, errWrongNumOfArguments};
 
       slot_ = GET_OR_RET(ParseInt<int64_t>(args[2], 10));
 
       dst_node_id_ = args[3];
+
+      if (args.size() >= 5) {
+        auto sync_flag = util::ToLower(args[4]);
+        if (sync_flag == "async") {
+          sync_migrate_ = false;
+        } else if (sync_flag == "sync") {
+          sync_migrate_ = true;
+
+          if (args.size() == 6) {
+            sync_migrate_timeout_ = GET_OR_RET(ParseInt<int64_t>(args[5], 10));
+          } else if (args.size() > 6) {
+            return {Status::RedisParseErr, "Wrong number of arguments for MIGRATE SYNC option"};
+          }
+        } else {
+          return {Status::RedisParseErr, "Invalid sync flag"};
+        }
+      }

Review Comment:
   I think it's a little bit clearer
   
   if (args.size() == 5) {
      ...
   }
   
   if (args.size() == 6) {
      ...
   }



-- 
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: issues-unsubscribe@kvrocks.apache.org

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