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



##########
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:
       Do we not need these setters then? `setExcludeNodes` that accepts a 
string seems enough




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

Reply via email to