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

(cherry picked from commit 1fcbe7cf5f2f7c609cd4158912f151848268ca9e)


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

Branch: refs/heads/resource-types
Commit: 26da4045aa1ddb78b9a6f81c2535e5ed9098a824
Parents: 2fdffbd
Author: Junping Du <junping...@apache.org>
Authored: Mon Oct 16 13:57:03 2017 -0700
Committer: Junping Du <junping...@apache.org>
Committed: Mon Oct 16 13:57:41 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/hadoop/blob/26da4045/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: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to