use of com.hortonworks.streamline.streams.common.event.EventInformationBuilder in project streamline by hortonworks.
the class TestRunEventLogger method writeEvent.
// Writing event to file should be mutually exclusive.
// We don't need to worry about performance since it's just for testing topology locally.
public synchronized void writeEvent(long timestamp, String componentName, String streamId, Set<String> targetComponents, StreamlineEvent event) {
try (FileWriter fw = new FileWriter(eventLogFilePath, true)) {
LOG.debug("writing event to file " + eventLogFilePath);
EventInformationBuilder informationBuilder = new EventInformationBuilder();
EventInformation eventInfo = informationBuilder.build(timestamp, componentName, streamId, targetComponents, event);
fw.write(objectMapper.writeValueAsString(eventInfo) + "\n");
fw.flush();
} catch (FileNotFoundException e) {
LOG.error("Can't open file for write: " + eventLogFilePath);
throw new RuntimeException(e);
} catch (IOException e) {
LOG.error("Fail to write event to output file " + eventLogFilePath + " : exception occurred.", e);
throw new RuntimeException(e);
}
}
Aggregations