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/15 11:30:40 UTC

[GitHub] [ozone] lokeshj1703 commented on a change in pull request #2786: HDDS-5897. Support configuration for including/excluding datanodes for balancing

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



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancerConfiguration.java
##########
@@ -292,6 +312,86 @@ public void setBalancingInterval(Duration balancingInterval) {
     }
   }
 
+  /**
+   * Gets a set of datanode hostnames or ip addresses that will be the exclusive
+   * participants in balancing.
+   * @return Set of hostname or ip address strings, or an empty set if the
+   * configuration is empty
+   */
+  public Set<String> getIncludeNodes() {
+    if (includeNodes.isEmpty()) {
+      return Collections.emptySet();
+    }
+    return Arrays.stream(includeNodes.split(","))
+        .map(String::trim)
+        .collect(Collectors.toSet());
+  }
+
+  /**
+   * Sets the datanodes that will be the exclusive participants in balancing.
+   * Applicable only if the specified string is non-empty.
+   * @param includeNodes a String of datanode hostnames or ip addresses
+   *                     separated by commas
+   */
+  public void setIncludeNodes(String includeNodes) {
+    this.includeNodes = includeNodes;
+  }
+
+  /**
+   * Sets the datanodes that will be the exclusive participants in balancing.
+   * Applicable only if the specified file is non-empty.
+   * @param includeNodes a File of datanode hostnames or ip addresses
+   * @throws IOException if an I/O error occurs when opening the file
+   */
+  public void setIncludeNodes(File includeNodes) throws IOException {
+    try (Stream<String> strings = Files.lines(includeNodes.toPath(),
+        StandardCharsets.UTF_8)) {
+      this.includeNodes = strings.collect(Collectors.joining(","));
+    } catch (IOException e) {
+      LOG.debug("Could not read the specified includeNodes file.");
+      throw new IOException(e);
+    }
+  }
+
+  /**
+   * Gets a set of datanode hostnames or ip addresses that will be excluded
+   * from balancing.
+   * @return Set of hostname or ip address strings, or an empty set if the
+   * configuration is empty
+   */
+  public Set<String> getExcludeNodes() {
+    if (excludeNodes.isEmpty()) {
+      return Collections.emptySet();
+    }
+    return Arrays.stream(excludeNodes.split(","))
+        .map(String::trim)
+        .collect(Collectors.toSet());
+  }
+
+  /**
+   * Sets the datanodes that will be excluded from balancing.
+   * @param excludeNodes a String of datanode hostnames or ip addresses
+   *                     separated by commas
+   */
+  public void setExcludeNodes(String excludeNodes) {
+    this.excludeNodes = excludeNodes;
+  }
+
+  /**
+   * Sets the datanodes that will be excluded from balancing.
+   * @param excludeNodes a File of datanode hostnames or ip addresses
+   * @throws IOException if an I/O error occurs when opening the file
+   */
+  public void setExcludeNodes(File excludeNodes) throws IOException {

Review comment:
       File can not be passed since command would be run in a remote cluster.

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/balancer/ContainerBalancer.java
##########
@@ -731,6 +738,24 @@ boolean canSizeEnterTarget(DatanodeDetails target, long size) {
     return potentialTargets;
   }
 
+  /**
+   * Consults the configurations {@link ContainerBalancer#includeNodes} and
+   * {@link ContainerBalancer#excludeNodes} to check if the specified
+   * Datanode should be excluded from balancing.
+   * @param datanode DatanodeDetails to check
+   * @return true if Datanode should be excluded, else false
+   */
+  boolean shouldExcludeDatanode(DatanodeDetails datanode) {

Review comment:
       We will need to handle case where node is both included and excluded.




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