siddhantsangwan commented on a change in pull request #2808:
URL: https://github.com/apache/ozone/pull/2808#discussion_r748021058
##########
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:
```suggestion
.calculateUtilization(sizeEnteringAfterMove), upperLimit) <=
0;
```
##########
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:
Let's keep this comment as documentation?
##########
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:
This block of code is analogous to what `canSizeEnterTarget` does for
target nodes. Can we have a similar method called `canSizeLeaveSource` for
source nodes?
Also, the `calculateUtilization(long plusSize)` method adds the specified
plus size to used space. Here, I think we want to subtract `totalLeavingSize`
from used space, instead.
##########
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:
My understanding of this method is unclear, so I might be wrong. I think
we want to sort by reducing the used space (subtracting `sizeLeavingNode`) and
then calculating utilization.
--
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]