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/11/12 08:39:43 UTC

[GitHub] [ozone] JacksonYao287 commented on a change in pull request #2808: HDDS-5517. Support multiple container moves from a source datanode in one balance iteration

JacksonYao287 commented on a change in pull request #2808:
URL: https://github.com/apache/ozone/pull/2808#discussion_r748058383



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -518,6 +485,27 @@ private ContainerMoveSelection matchSourceWithTarget(
       }
       return null;
     }
+
+    //if the utilization of the source data node becomes lower than lowerLimit
+    //after the container is moved out , then the container can not be
+    // a candidate one, and we should remove it from the candidateContainers.
+    candidateContainers.removeIf(c -> {
+      ContainerInfo cInfo;
+      try {
+        cInfo = containerManager.getContainer(c);
+      } catch (ContainerNotFoundException e) {
+        LOG.warn("Could not find container {} when " +
+            "be matched with a move target", c);
+        //remove this not found container
+        return true;
+      }
+      Long totalLeavingSize = sizeLeavingNode.get(source) +
+          cInfo.getUsedBytes();
+      return Double.compare(nodeManager.getUsageInfo(source)
+        .calculateUtilization(totalLeavingSize), lowerLimit) < 0 ||
+          totalLeavingSize > config.getMaxSizeLeavingSource();
+    });

Review comment:
       thanks for pointing out this,  will fix it!
   

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -262,20 +261,17 @@ private boolean initializeIteration() {
           clusterAvgUtilisation);
     }
 
-    // under utilized nodes have utilization(that is, used / capacity) less
-    // than lower limit

Review comment:
       sorry for this, i did not meant to remove this comment, i will add it back

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/SourceDataNodeSelectionCriteria.java
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.container.balancer;
+
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.scm.node.DatanodeUsageInfo;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The selection criteria for selecting source datanodes , the containers of
+ * which will be moved out.
+ */
+public class SourceDataNodeSelectionCriteria {
+  private static final Logger LOG =
+      LoggerFactory.getLogger(SourceDataNodeSelectionCriteria.class);
+  private Map<DatanodeDetails, Long> sizeLeavingNode;
+  private List<DatanodeUsageInfo> overUtilizedNodes;
+
+  public SourceDataNodeSelectionCriteria(
+      List<DatanodeUsageInfo> overUtilizedNodes,
+      Map<DatanodeDetails, Long> sizeLeavingNode) {
+    this.sizeLeavingNode = sizeLeavingNode;
+    this.overUtilizedNodes = overUtilizedNodes;
+  }
+
+  public DatanodeDetails getNextCandidateSourceDataNode() {
+    if (overUtilizedNodes.isEmpty()) {
+      LOG.info("no more candidate data node");
+      return null;
+    }
+    //TODOļ¼šuse a more quick data structure, which will hava a
+    // better performance when changing or deleting one element at once
+    overUtilizedNodes.sort((a, b) -> {
+      double currentUsageOfA = a.calculateUtilization(
+          sizeLeavingNode.get(a.getDatanodeDetails()));
+      double currentUsageOfB = b.calculateUtilization(
+          sizeLeavingNode.get(b.getDatanodeDetails()));
+      //in descending order
+      return Double.compare(currentUsageOfB, currentUsageOfA);
+    });

Review comment:
       >I think we want to sort by reducing the used space (subtracting sizeLeavingNode) and then calculating utilization.
   
   yes , that is correct. `getNextCandidateSourceDataNode` always try to return a source data node with the highest usage. thanks very much for pointing out this mistake!

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -708,8 +696,8 @@ boolean canSizeEnterTarget(DatanodeDetails target, long size) {
       //2 current usage of target datanode plus sizeEnteringAfterMove
       // is smaller than or equal to upperLimit
       return sizeEnteringAfterMove <= config.getMaxSizeEnteringTarget() &&
-           nodeManager.getUsageInfo(target)
-               .calculateUtilization(sizeEnteringAfterMove) <= upperLimit;
+           Double.compare(nodeManager.getUsageInfo(target)
+               .calculateUtilization(sizeEnteringAfterMove), upperLimit) < 1;

Review comment:
       the return type of `Double.compare` is int , so `< 1`  is equal to `<= 0` here. but `<=0` seems more clear, will fix this, thanks.




-- 
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@ozone.apache.org

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