YARN-7124. LogAggregationTFileController deletes/renames while file is open. 
Contributed by Jason Lowe.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1fcbe7cf
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1fcbe7cf
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1fcbe7cf

Branch: refs/heads/HDFS-7240
Commit: 1fcbe7cf5f2f7c609cd4158912f151848268ca9e
Parents: a50be1b
Author: Junping Du <[email protected]>
Authored: Mon Oct 16 13:57:03 2017 -0700
Committer: Junping Du <[email protected]>
Committed: Mon Oct 16 13:57:03 2017 -0700

----------------------------------------------------------------------
 .../filecontroller/tfile/LogAggregationTFileController.java | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/1fcbe7cf/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java
index 92e3a08..5064e26 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/tfile/LogAggregationTFileController.java
@@ -96,8 +96,10 @@ public class LogAggregationTFileController
 
   @Override
   public void closeWriter() {
-    this.writer.close();
-    this.writer = null;
+    if (this.writer != null) {
+      this.writer.close();
+      this.writer = null;
+    }
   }
 
   @Override
@@ -117,6 +119,9 @@ public class LogAggregationTFileController
       record.increcleanupOldLogTimes();
     }
 
+    // close the writer before the file is renamed or deleted
+    closeWriter();
+
     final Path renamedPath = record.getRollingMonitorInterval() <= 0
         ? record.getRemoteNodeLogFileForApp() : new Path(
             record.getRemoteNodeLogFileForApp().getParent(),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to