in appender/hdfs/src/main/java/org/apache/karaf/decanter/appender/hdfs/HdfsAppender.java [64:97]
public void handleEvent(Event event) {
try {
if (EventFilter.match(event, config)) {
FileSystem fileSystem = FileSystem.get(configuration);
if (config.get("hdfs.path") == null) {
throw new IllegalArgumentException("hdfs.path is not set");
}
Path path = new Path((String) config.get("hdfs.path"));
FSDataOutputStream outputStream;
if (config.get("hdfs.mode") == null) {
outputStream = fileSystem.create(path, true);
} else {
if (((String) config.get("hdfs.mode")).equalsIgnoreCase("append")) {
outputStream = fileSystem.append(path);
} else if (((String) config.get("hdfs.mode")).equalsIgnoreCase("overwrite")) {
outputStream = fileSystem.create(path, true);
} else {
outputStream = fileSystem.create(path, false);
}
}
try {
String marshalled = marshaller.marshal(event);
outputStream.writeChars(marshalled);
} catch (Exception e) {
// nothing to do
}
outputStream.flush();
outputStream.close();
fileSystem.close();
}
} catch (Exception e) {
LOGGER.warn("Can't write on HDFS", e);
}
}