lokeshj1703 commented on a change in pull request #2278:
URL: https://github.com/apache/ozone/pull/2278#discussion_r650016785



##########
File path: 
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
##########
@@ -675,17 +676,21 @@ public boolean startContainerBalancer(double threshold, 
int idleiterations,
     AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
         SCMAction.START_CONTAINER_BALANCER, null));
     ContainerBalancerConfiguration cbc = new ContainerBalancerConfiguration();
+
     if (threshold > 0) {
       cbc.setThreshold(threshold);
     }
     if (maxDatanodesToBalance > 0) {
       cbc.setMaxDatanodesToBalance(maxDatanodesToBalance);
     }
     if (maxSizeToMove > 0) {
-      cbc.setMaxSizeToMove(maxSizeToMove);
+      cbc.setMaxSizeToMove(maxSizeToMove * OzoneConsts.GB);

Review comment:
       Can we also update the description for option maxSizeToMove? We can 
mention that for 10GB it should be mentioned as 10. I think it would be good to 
update the option name to maxSizeToMoveInGB.

##########
File path: 
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStartSubcommand.java
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.scm.cli;
+
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+import java.io.IOException;
+
+/**
+ * Handler to start container balancer.
+ */
+@Command(
+    name = "start",
+    description = "Start ContainerBalancer",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class ContainerBalancerStartSubcommand extends ScmSubcommand {
+
+  @Option(names = {"-t", "--threshold"},
+      description = "Threshold target whether the cluster is balanced")
+  private double threshold;
+
+  @Option(names = {"-i", "--idleiterations"},
+      description = "Maximum consecutive idle iterations",
+      //idleiteration could be as follows:
+      // 0 : indicate running infinitely
+      // positive number : indicate the specific iterations
+      // -1 : user does not set this value
+      defaultValue = "-1")
+  private int idleiterations;
+
+  @Option(names = {"-d", "--maxDatanodesToBalance"},
+      description = "Maximum datanodes to move")
+  private int maxDatanodesToBalance;
+
+  @Option(names = {"-s", "--maxSizeToMove"},
+      description = "Maximum size to move")
+  private long maxSizeToMove;
+
+  @Override
+  public void execute(ScmClient scmClient) throws IOException {
+    boolean result = scmClient.startContainerBalancer(threshold, 
idleiterations,
+        maxDatanodesToBalance, maxSizeToMove);
+    if (result) {
+      System.out.println("Starting ContainerBalancer Successfully.");
+      return;
+    }
+    System.out.println("ContainerBalancer has been started" +
+        " by another cli command.");

Review comment:
       Maybe we can print sth like "Container balancer is already running. 
Please stop it first."

##########
File path: 
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStartSubcommand.java
##########
@@ -39,7 +39,12 @@
   private double threshold;
 
   @Option(names = {"-i", "--idleiterations"},
-      description = "Maximum consecutive idle iterations")
+      description = "Maximum consecutive idle iterations",
+      //idleiteration could be as follows:
+      // 0 : indicate running infinitely
+      // positive number : indicate the specific iterations
+      // -1 : user does not set this value
+      defaultValue = "-1")

Review comment:
       How about we use -1 as the value for running balancer infinitely? The 
possible value are >= -1 then. We don't need a default value.
   Maybe internally in start balancer command it would be better to use 
Optional. So that you would know if user has specified an option like 
idleIteration 0. For input 0 I think the command should throw an exception 
because that is like not starting the balancer.




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

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