diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java index 6cb2062..243945e 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/LogAggregationIndexedFileController.java @@ -392,7 +392,8 @@ public void postWrite(LogAggregationFileControllerContext record) this.fsDataOStream.writeInt(length); byte[] separator = this.uuid.getBytes(Charset.forName("UTF-8")); this.fsDataOStream.write(separator); - if (logAggregationSuccessfullyInThisCyCle) { + if (logAggregationSuccessfullyInThisCyCle && + record.isLogAggregationInRolling()) { deleteFileWithRetries(fc, ugi, remoteLogCheckSumFile); } } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexFileController.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexFileController.java index 5f61710..f77ad96 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexFileController.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/logaggregation/filecontroller/ifile/TestLogAggregationIndexFileController.java @@ -164,9 +164,7 @@ public void testLogAggregationIndexFileFormat() throws Exception { fileFormat.initializeWriter(context); fileFormat.write(key1, value); - LogAggregationFileControllerContext record = mock( - LogAggregationFileControllerContext.class); - fileFormat.postWrite(record); + fileFormat.postWrite(context); fileFormat.closeWriter(); ContainerLogsRequest logRequest = new ContainerLogsRequest(); @@ -267,7 +265,7 @@ public void testLogAggregationIndexFileFormat() throws Exception { // first write and second write fileFormat.initializeWriter(context); fileFormat.write(key1, value2); - fileFormat.postWrite(record); + fileFormat.postWrite(context); fileFormat.closeWriter(); fileFormat.readAggregatedLogsMeta( logRequest);