You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/06/04 16:11:44 UTC

[GitHub] [ozone] lokeshj1703 commented on a change in pull request #2278: HDDS-4926. Support start/stop for container balancer via command line

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



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -111,27 +112,42 @@ public boolean start(ContainerBalancerConfiguration balancerConfiguration) {
 
     ozoneConfiguration = new OzoneConfiguration();
     this.config = balancerConfiguration;
+    this.idleIteration = config.getIdleIteration();
     this.threshold = config.getThreshold();
     this.maxDatanodesToBalance = config.getMaxDatanodesToBalance();
     this.maxSizeToMove = config.getMaxSizeToMove();
     this.unBalancedNodes = new ArrayList<>();
-
     LOG.info("Starting Container Balancer...{}", this);
-    balance();
+    //we should start a new balancer thread async
+    //and response to cli as soon as possible
+
+
+    //this is a temporary implementation

Review comment:
       NIT: Can we specify TODO: in the comment?

##########
File path: hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStartSubcommand.java
##########
@@ -0,0 +1,64 @@
+/*
+ * 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;
+import picocli.CommandLine.Command;
+
+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 {
+
+  @CommandLine.Option(names = {"-t", "--threshold"},
+      description = "Threshold target whether the cluster is balanced")
+  private double threshold;

Review comment:
       We can specify all these options as Optional<Double> etc. The SCMClient could also use Optional as parameter.

##########
File path: hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto
##########
@@ -445,6 +454,32 @@ message GetContainerTokenResponseProto {
   required TokenProto token = 1;
 }
 
+message StartContainerBalancerRequestProto {
+  optional string traceID = 1;
+  required double threshold = 2;

Review comment:
       I think @ChenSammi is pointing out that since all these fields do not have default values they should be optional.

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -323,8 +344,22 @@ public static double calculateUtilization(
    * Stops ContainerBalancer.
    */
   public void stop() {

Review comment:
       We will need to make start and stop synchronized. In a race condition it is possible for balancerRunning to be set as true but thread may not be running.

##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/balancer/TestContainerBalancer.java
##########
@@ -96,11 +97,18 @@ public void setup() {
 
       balancerConfiguration.setThreshold(randomThreshold);
       containerBalancer.start(balancerConfiguration);
+
+      // waiting for balance completed.
+      // this is a temporary implementation for now
+      // modify this after balancer is fully completed

Review comment:
       NIT: Can we add a TODO: in comments?




-- 
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org