private void writeBrokenFile(Path logPath) throws IOException { FSDataOutputStream out = null; try { String broken = "{ broken { [[]} broken"; out = PluginStoreTestUtils.createLogFile(logPath, fs); out.write(broken.getBytes(Charset.forName("UTF-8"))); out.close(); out = null; } finally { if (out != null) { out.close(); } } }
private void writeDomainLeaveOpen(TimelineDomain domain, Path logPath) throws IOException { if (outStreamDomain == null) { outStreamDomain = PluginStoreTestUtils.createLogFile(logPath, fs); } // Write domain uses its own json generator to isolate from entity writers JsonGenerator jsonGeneratorLocal = new JsonFactory().createGenerator((OutputStream)outStreamDomain); jsonGeneratorLocal.setPrettyPrinter(new MinimalPrettyPrinter("\n")); objMapper.writeValue(jsonGeneratorLocal, domain); outStreamDomain.hflush(); }
private void writeEntitiesLeaveOpen(TimelineEntities entities, Path logPath) throws IOException { if (outStream == null) { outStream = PluginStoreTestUtils.createLogFile(logPath, fs); jsonGenerator = new JsonFactory().createGenerator( (OutputStream)outStream); jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n")); } for (TimelineEntity entity : entities.getEntities()) { objMapper.writeValue(jsonGenerator, entity); } outStream.hflush(); }
/** * Write timeline entities to a file system * @param entities * @param logPath * @param fs * @throws IOException */ static void writeEntities(TimelineEntities entities, Path logPath, FileSystem fs) throws IOException { FSDataOutputStream outStream = createLogFile(logPath, fs); JsonGenerator jsonGenerator = new JsonFactory().createGenerator((OutputStream)outStream); jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n")); ObjectMapper objMapper = createObjectMapper(); for (TimelineEntity entity : entities.getEntities()) { objMapper.writeValue(jsonGenerator, entity); } outStream.close(); }