diff options
author | Ola Aunrønning <ola.aunroe@gmail.com> | 2018-09-20 14:34:44 +0200 |
---|---|---|
committer | Ola Aunrønning <ola.aunroe@gmail.com> | 2018-09-20 14:56:56 +0200 |
commit | 2fa4d31e2ef1bf749efce2df9ed5a7d4dcede8a2 (patch) | |
tree | 74607406579e0b68375ee8739aea6968d3251553 /container-core/src/main/java/com/yahoo/container/handler | |
parent | c1d8a9f6bf3941f1388fb06fea2edd5eeeddbe6e (diff) |
Added test for LogHandler
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/handler')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/LogHandler.java | 9 | ||||
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/handler/LogReader.java | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/handler/LogHandler.java b/container-core/src/main/java/com/yahoo/container/handler/LogHandler.java index c6a50c65dd4..d1f84aefeaa 100644 --- a/container-core/src/main/java/com/yahoo/container/handler/LogHandler.java +++ b/container-core/src/main/java/com/yahoo/container/handler/LogHandler.java @@ -17,10 +17,16 @@ import java.util.concurrent.Executor; public class LogHandler extends ThreadedHttpRequestHandler { private static final String LOG_DIRECTORY = "/home/y/logs/vespa/logarchive/"; + private final LogReader logReader; @Inject public LogHandler(Executor executor) { + this(executor, new LogReader()); + } + + protected LogHandler(Executor executor, LogReader logReader) { super(executor); + this.logReader = logReader; } @Override @@ -30,9 +36,8 @@ public class LogHandler extends ThreadedHttpRequestHandler { HashMap<String, String> apiParams = getParameters(request); long earliestLogThreshold = getEarliestThreshold(apiParams); long latestLogThreshold = getLatestThreshold(apiParams); - LogReader logReader= new LogReader(earliestLogThreshold, latestLogThreshold); try { - JSONObject logJson = logReader.readLogs(LOG_DIRECTORY); + JSONObject logJson = logReader.readLogs(LOG_DIRECTORY, earliestLogThreshold, latestLogThreshold); responseJSON.put("logs", logJson); } catch (IOException | JSONException e) { return new HttpResponse(404) { 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 5d78e37ec9e..ae43d850258 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 @@ -14,12 +14,9 @@ public class LogReader { long earliestLogThreshold; long latestLogThreshold; - public LogReader(long earliestLogThreshold, long latestLogThreshold) { + protected JSONObject readLogs(String logDirectory, long earliestLogThreshold, long latestLogThreshold) throws IOException, JSONException { this.earliestLogThreshold = earliestLogThreshold; this.latestLogThreshold = latestLogThreshold; - } - - protected JSONObject readLogs(String logDirectory) throws IOException, JSONException { JSONObject json = new JSONObject(); File root = new File(logDirectory); traverse_folder(root, json, ""); |