summaryrefslogtreecommitdiffstats
path: root/container-core
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-08-05 12:28:17 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-08-05 12:28:17 +0200
commit18fdf7c0c7c56c3fcff19582d1a9ae3240bcd107 (patch)
treeba58dae10c81dbab77eefee4c81d0d15c4391238 /container-core
parent2e82ff0ff2e24811d96c42126d81526da7ea3779 (diff)
Flush output from log handler more often
Diffstat (limited to 'container-core')
-rw-r--r--container-core/src/main/java/com/yahoo/container/handler/LogReader.java44
1 files changed, 20 insertions, 24 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java
index 8e4b9aea9b8..3532dac09f5 100644
--- a/container-core/src/main/java/com/yahoo/container/handler/LogReader.java
+++ b/container-core/src/main/java/com/yahoo/container/handler/LogReader.java
@@ -62,34 +62,30 @@ class LogReader {
double fromSeconds = from.getEpochSecond() + from.getNano() / 1e9;
double toSeconds = to.getEpochSecond() + to.getNano() / 1e9;
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
- try {
- for (List<Path> logs : getMatchingFiles(from, to)) {
- List<LogLineIterator> logLineIterators = new ArrayList<>();
- try {
- // Logs in each sub-list contain entries covering the same time interval, so do a merge sort while reading
- for (Path log : logs)
- logLineIterators.add(new LogLineIterator(log, fromSeconds, toSeconds, hostname));
-
- Iterator<LineWithTimestamp> lines = Iterators.mergeSorted(logLineIterators,
- Comparator.comparingDouble(LineWithTimestamp::timestamp));
- while (lines.hasNext()) {
- writer.write(lines.next().line());
- writer.newLine();
- }
- }
- catch (IOException e) {
- throw new UncheckedIOException(e);
+ for (List<Path> logs : getMatchingFiles(from, to)) {
+ List<LogLineIterator> logLineIterators = new ArrayList<>();
+ try {
+ // Logs in each sub-list contain entries covering the same time interval, so do a merge sort while reading
+ for (Path log : logs)
+ logLineIterators.add(new LogLineIterator(log, fromSeconds, toSeconds, hostname));
+
+ Iterator<LineWithTimestamp> lines = Iterators.mergeSorted(logLineIterators,
+ Comparator.comparingDouble(LineWithTimestamp::timestamp));
+ while (lines.hasNext()) {
+ writer.write(lines.next().line());
+ writer.newLine();
}
- finally {
- for (LogLineIterator ll : logLineIterators) {
- try { ll.close(); } catch (IOException ignored) { }
- }
+ }
+ catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ finally {
+ for (LogLineIterator ll : logLineIterators) {
+ try { ll.close(); } catch (IOException ignored) { }
}
+ Exceptions.uncheck(writer::flush);
}
}
- finally {
- Exceptions.uncheck(writer::flush);
- }
}
private static class LogLineIterator implements Iterator<LineWithTimestamp>, AutoCloseable {