From f304ccae3c2e0849b0b0b24c4bfe7a3a1ec2bb94 Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 2 Dec 2016 16:54:15 +0000 Subject: [PATCH] YARN-5915. ATS 1.5 FileSystemTimelineWriter causes flush() to be called after every event write. Contributed by Atul Sikaria --- .../yarn/client/api/impl/FileSystemTimelineWriter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/FileSystemTimelineWriter.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/FileSystemTimelineWriter.java index 54b491228d..fc3385bf20 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/FileSystemTimelineWriter.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/api/impl/FileSystemTimelineWriter.java @@ -63,6 +63,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.sun.jersey.api.client.Client; @@ -276,6 +277,7 @@ private ObjectMapper createObjectMapper() { mapper.setAnnotationIntrospector( new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false); return mapper; } @@ -356,6 +358,7 @@ public void close() { public void flush() throws IOException { if (stream != null) { + jsonGenerator.flush(); stream.hflush(); } } @@ -368,8 +371,6 @@ protected void prepareForWrite() throws IOException{ this.stream = createLogFileStream(fs, logPath); this.jsonGenerator = new JsonFactory().createGenerator(stream); this.jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n")); - this.jsonGenerator.configure( - JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false); this.lastModifiedTime = Time.monotonicNow(); }