YARN-5915. ATS 1.5 FileSystemTimelineWriter causes flush() to be called after every event write. Contributed by Atul Sikaria

This commit is contained in:
Jason Lowe 2016-12-02 16:54:15 +00:00
parent c87b3a448a
commit f304ccae3c

View File

@ -63,6 +63,7 @@
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector; import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.Client;
@ -276,6 +277,7 @@ private ObjectMapper createObjectMapper() {
mapper.setAnnotationIntrospector( mapper.setAnnotationIntrospector(
new JaxbAnnotationIntrospector(TypeFactory.defaultInstance())); new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(SerializationFeature.FLUSH_AFTER_WRITE_VALUE, false);
return mapper; return mapper;
} }
@ -356,6 +358,7 @@ public void close() {
public void flush() throws IOException { public void flush() throws IOException {
if (stream != null) { if (stream != null) {
jsonGenerator.flush();
stream.hflush(); stream.hflush();
} }
} }
@ -368,8 +371,6 @@ protected void prepareForWrite() throws IOException{
this.stream = createLogFileStream(fs, logPath); this.stream = createLogFileStream(fs, logPath);
this.jsonGenerator = new JsonFactory().createGenerator(stream); this.jsonGenerator = new JsonFactory().createGenerator(stream);
this.jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n")); this.jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
this.jsonGenerator.configure(
JsonGenerator.Feature.FLUSH_PASSED_TO_STREAM, false);
this.lastModifiedTime = Time.monotonicNow(); this.lastModifiedTime = Time.monotonicNow();
} }