xianjingfeng commented on code in PR #1897:
URL: 
https://github.com/apache/incubator-uniffle/pull/1897#discussion_r1681969150


##########
coordinator/src/main/java/org/apache/uniffle/coordinator/SimpleClusterManager.java:
##########
@@ -222,6 +226,35 @@ private void parseExcludeNodesFile(DataInputStream 
fsDataInputStream) throws IOE
         "Updated exclude nodes and {} nodes were marked as exclude nodes", 
excludeNodes.size());
   }
 
+  private boolean putInExcludeNodesFile(List<String> excludeNodes) throws 
IOException {
+    StringBuilder appendExecludeNodes = new StringBuilder();
+    String currentDate = DateFormatUtils.format(new Date(), DATE_PATTERN);
+    appendExecludeNodes
+        .append("# Header ")
+        .append(currentDate)
+        .append(":blacklist node added from the page.")
+        .append("\n");
+    for (String excludeNode : excludeNodes) {
+      appendExecludeNodes.append(excludeNode).append("\n");
+    }
+    appendExecludeNodes
+        .append("# End ")
+        .append(currentDate)
+        .append(":blacklist node added from the page.")
+        .append("\n");
+    Path hadoopPath = new Path(excludeNodesPath);
+    if (hadoopFileSystem != null) {
+      FileStatus fileStatus = hadoopFileSystem.getFileStatus(hadoopPath);
+      if (fileStatus != null && fileStatus.isFile()) {
+        try (FSDataOutputStream os = hadoopFileSystem.append(hadoopPath)) {
+          
os.write(appendExecludeNodes.toString().getBytes(StandardCharsets.UTF_8));

Review Comment:
   > > It's better to write to a temporary file first, and then rename it.
   > 
   > Now is the way to append content, temporary files must be read out first, 
this is really good?
   
   Do you mean the feature just supports add servers to backlist and does not 
support remove them from backlist?



##########
coordinator/src/main/java/org/apache/uniffle/coordinator/SimpleClusterManager.java:
##########
@@ -222,6 +226,35 @@ private void parseExcludeNodesFile(DataInputStream 
fsDataInputStream) throws IOE
         "Updated exclude nodes and {} nodes were marked as exclude nodes", 
excludeNodes.size());
   }
 
+  private boolean putInExcludeNodesFile(List<String> excludeNodes) throws 
IOException {
+    StringBuilder appendExecludeNodes = new StringBuilder();
+    String currentDate = DateFormatUtils.format(new Date(), DATE_PATTERN);
+    appendExecludeNodes
+        .append("# Header ")
+        .append(currentDate)
+        .append(":blacklist node added from the page.")
+        .append("\n");
+    for (String excludeNode : excludeNodes) {
+      appendExecludeNodes.append(excludeNode).append("\n");
+    }
+    appendExecludeNodes
+        .append("# End ")
+        .append(currentDate)
+        .append(":blacklist node added from the page.")
+        .append("\n");
+    Path hadoopPath = new Path(excludeNodesPath);
+    if (hadoopFileSystem != null) {
+      FileStatus fileStatus = hadoopFileSystem.getFileStatus(hadoopPath);
+      if (fileStatus != null && fileStatus.isFile()) {
+        try (FSDataOutputStream os = hadoopFileSystem.append(hadoopPath)) {
+          
os.write(appendExecludeNodes.toString().getBytes(StandardCharsets.UTF_8));

Review Comment:
   > > It's better to write to a temporary file first, and then rename it.
   > 
   > Now is the way to append content, temporary files must be read out first, 
this is really good?
   
   Do you mean this feature just supports add servers to backlist and does not 
support remove them from backlist?



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