janhoy commented on code in PR #4267:
URL: https://github.com/apache/solr/pull/4267#discussion_r3044847538


##########
solr/core/src/java/org/apache/solr/cli/ZkMvTool.java:
##########
@@ -70,37 +100,52 @@ public String getHeader() {
   @Override
   public void runImpl(CommandLine cli) throws Exception {
     String zkHost = CLIUtils.getZkHost(cli);
+    String src = cli.getArgs()[0];
+    String dst = cli.getArgs()[1];
 
     try (SolrZkClient zkClient = CLIUtils.getSolrZkClient(cli, zkHost)) {
-      echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");
-      String src = cli.getArgs()[0];
-      String dst = cli.getArgs()[1];
-
-      if (src.toLowerCase(Locale.ROOT).startsWith("file:")
-          || dst.toLowerCase(Locale.ROOT).startsWith("file:")) {
-        throw new SolrServerException(
-            "mv command operates on znodes and 'file:' has been specified.");
-      }
-      String source = src;
-      if (src.toLowerCase(Locale.ROOT).startsWith("zk")) {
-        source = src.substring(3);
-      }
-
-      String dest = dst;
-      if (dst.toLowerCase(Locale.ROOT).startsWith("zk")) {
-        dest = dst.substring(3);
-      }
-
-      echo("Moving Znode " + source + " to " + dest + " on ZooKeeper at " + 
zkHost);
-      zkClient.moveZnode(source, dest);
+      doMv(zkClient, zkHost, src, dst);
     } catch (Exception e) {
       log.error("Could not complete mv operation for reason: ", e);
       throw (e);
     }
   }
 
+  private void doMv(SolrZkClient zkClient, String zkHost, String src, String 
dst) throws Exception {
+    echoIfVerbose("\nConnecting to ZooKeeper at " + zkHost + " ...");
+    if (src.toLowerCase(Locale.ROOT).startsWith("file:")
+        || dst.toLowerCase(Locale.ROOT).startsWith("file:")) {
+      throw new SolrServerException(
+          "mv command operates on znodes and 'file:' has been specified.");
+    }
+    String source = src;
+    if (src.toLowerCase(Locale.ROOT).startsWith("zk")) {
+      source = src.substring(3);
+    }
+
+    String dest = dst;
+    if (dst.toLowerCase(Locale.ROOT).startsWith("zk")) {

Review Comment:
   Also a suggestion to improve pre-existing code



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to