siddhantsangwan commented on a change in pull request #2441:
URL: https://github.com/apache/ozone/pull/2441#discussion_r680950553
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -351,6 +491,87 @@ public static double calculateUtilization(
stat.getCapacity().get().doubleValue();
}
+ boolean canSizeLeaveSource(DatanodeDetails source, long size) {
+ if (sizeLeavingNode.containsKey(source)) {
+ return sizeLeavingNode.get(source) + size <=
+ config.getMaxSizeLeavingSource();
+ }
+ return false;
+ }
+
+ /**
+ * Checks if specified size can enter specified target datanode
+ * according to configuration.
+ * @param target target datanode in which size is entering
+ * @param size size in bytes
+ * @return true if size can enter target, else false
+ */
+ boolean canSizeEnterTarget(DatanodeDetails target,
+ long size) {
+ if (sizeEnteringNode.containsKey(target)) {
+ return sizeEnteringNode.get(target) + size <=
+ config.getMaxSizeEnteringTarget();
+ }
+ return false;
+ }
+
+ /**
+ * Get potential targets for container move. Potential targets are under
+ * utilized and within threshold utilized nodes.
+ * @return A list of potential target DatanodeDetails.
+ */
+ private List<DatanodeDetails> getPotentialTargets() {
+ List<DatanodeDetails> potentialTargets = new ArrayList<>(
+ underUtilizedNodes.size() + withinThresholdUtilizedNodes.size());
+
+ underUtilizedNodes
+ .forEach(node -> potentialTargets.add(node.getDatanodeDetails()));
+ withinThresholdUtilizedNodes
+ .forEach(node -> potentialTargets.add(node.getDatanodeDetails()));
+ return potentialTargets;
+ }
+
+ /**
+ * Updates conditions for balancing, such as total size moved by balancer,
+ * total size that has entered a datanode, and total size that has left a
+ * datanode in this iteration.
+ * @param source source datanode
+ * @param moveSelection selected target datanode and container
+ */
+ private void incSizeSelectedForMoving(DatanodeDetails source,
+ ContainerMoveSelection moveSelection) {
+ DatanodeDetails target =
+ moveSelection.getTargetNode();
+ ContainerInfo container;
+ try {
+ container =
+ containerManager.getContainer(moveSelection.getContainerID());
+ } catch (ContainerNotFoundException e) {
+ LOG.warn("Could not find Container {} while matching source and " +
+ "target nodes in ContainerBalancer",
+ moveSelection.getContainerID(), e);
+ return;
+ }
+ long size = container.getUsedBytes();
+ totalSizeMoved += size;
+
+ // update sizeLeavingNode map with the recent moveSelection
+ if (sizeLeavingNode.containsKey(source)) {
Review comment:
Done.
--
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]