diff options
author | Ola Aunrønning <olaa@oath.com> | 2019-02-27 13:15:36 +0100 |
---|---|---|
committer | Ola Aunrønning <olaa@oath.com> | 2019-02-27 13:15:36 +0100 |
commit | faa41485359fdd7170ad695a5990eff11cc07458 (patch) | |
tree | 73b708cfbb3b1ceba25920d25897bf4c944b8bd5 /container-core/src/main/java/com/yahoo/container/handler | |
parent | f87646cafcd43d6a20b41591ca62845a07a25ba2 (diff) |
Add some leniency to latestLogThreshold
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/handler')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/LogReader.java | 6 |
1 files changed, 3 insertions, 3 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 76ea4579244..c6ae20973fb 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 @@ -4,11 +4,11 @@ package com.yahoo.container.handler; import org.json.JSONException; import org.json.JSONObject; +import java.time.Duration; import java.util.Base64; import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.attribute.BasicFileAttributes; public class LogReader { @@ -17,7 +17,7 @@ public class LogReader { protected JSONObject readLogs(String logDirectory, long earliestLogThreshold, long latestLogThreshold) throws IOException, JSONException { this.earliestLogThreshold = earliestLogThreshold; - this.latestLogThreshold = latestLogThreshold; + this.latestLogThreshold = latestLogThreshold + Duration.ofMinutes(5).toMillis(); // Add some time to allow retrieving logs currently being modified JSONObject json = new JSONObject(); File root = new File(logDirectory); traverse_folder(root, json, ""); @@ -27,7 +27,7 @@ public class LogReader { private void traverse_folder(File root, JSONObject json, String filename) throws IOException, JSONException { File[] files = root.listFiles(); for(File child : files) { - long logTime = Files.readAttributes(child.toPath(), BasicFileAttributes.class).creationTime().toMillis(); + long logTime = Files.getLastModifiedTime(child.toPath()).toMillis(); if(child.isFile() && earliestLogThreshold < logTime && logTime < latestLogThreshold) { json.put(filename + child.getName(), Base64.getEncoder().encodeToString(Files.readAllBytes(child.toPath()))); } |