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


##########
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:
   There will be some duplicate code checking the `sync_flag` like:
   ```c++
   if (args.size() == 5) {
    // check sync_flag = args[4]
   }
   
   if (args.size() == 6) {
    // check sync_flag = args[4]
   }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to