drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amansi...@apache.org
Subject [3/7] drill git commit: DRILL-4701: Fix log name and missing lines in logs on Web UI
Date Thu, 23 Jun 2016 18:10:43 GMT
DRILL-4701: Fix log name and missing lines in logs on Web UI


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/7a8bb16c
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/7a8bb16c
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/7a8bb16c

Branch: refs/heads/1.7.0
Commit: 7a8bb16c14da605f947c9956cdbbab6aac01e1e8
Parents: 1ddd0ce
Author: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
Authored: Wed Jun 1 11:16:31 2016 +0000
Committer: Aman Sinha <asinha@maprtech.com>
Committed: Wed Jun 22 15:15:39 2016 -0700

----------------------------------------------------------------------
 .../apache/drill/exec/server/rest/LogsResources.java | 15 ++++++++-------
 exec/java-exec/src/main/resources/rest/logs/log.ftl  |  6 +++---
 2 files changed, 11 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/7a8bb16c/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogsResources.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogsResources.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogsResources.java
index 8a89d41..16d213a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogsResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogsResources.java
@@ -21,6 +21,7 @@ package org.apache.drill.exec.server.rest;
 
 import com.fasterxml.jackson.annotation.JsonCreator;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Sets;
 import org.apache.drill.common.exceptions.DrillRuntimeException;
 import org.apache.drill.exec.ExecConstants;
@@ -48,7 +49,6 @@ import java.io.FileReader;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Comparator;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Set;
@@ -111,19 +111,20 @@ public class LogsResources {
     final int maxLines = work.getContext().getOptionManager().getOption(ExecConstants.WEB_LOGS_MAX_LINES).num_val.intValue();
 
     try (BufferedReader br = new BufferedReader(new FileReader(file))) {
-      Map<String, String> cache = new LinkedHashMap<String, String>(maxLines,
.75f, true) {
+      Map<Integer, String> cache = new LinkedHashMap<Integer, String>(maxLines,
.75f, true) {
         @Override
-        protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
+        protected boolean removeEldestEntry(Map.Entry<Integer, String> eldest) {
           return size() > maxLines;
         }
       };
 
       String line;
+      int i = 0;
       while ((line = br.readLine()) != null) {
-        cache.put(line, null);
+        cache.put(i++, line);
       }
 
-      return new LogContent(file.getName(), cache.keySet(), maxLines);
+      return new LogContent(file.getName(), cache.values(), maxLines);
     }
   }
 
@@ -133,12 +134,12 @@ public class LogsResources {
   public Response getFullLog(@PathParam("name") final String name) {
     File file = getFileByName(getLogFolder(), name);
     Response.ResponseBuilder response = Response.ok(file);
-    response.header("Content-Disposition", String.format("attachment;filename\"%s\"", name));
+    response.header("Content-Disposition", String.format("attachment;filename=\"%s\"", name));
     return response.build();
   }
 
   private File getLogFolder() {
-    return new File(System.getenv("DRILL_LOG_DIR"));
+    return new File(Preconditions.checkNotNull(System.getenv("DRILL_LOG_DIR"), "DRILL_LOG_DIR
variable is not set"));
   }
 
   private File getFileByName(File folder, final String name) {

http://git-wip-us.apache.org/repos/asf/drill/blob/7a8bb16c/exec/java-exec/src/main/resources/rest/logs/log.ftl
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/resources/rest/logs/log.ftl b/exec/java-exec/src/main/resources/rest/logs/log.ftl
index b09b57a..f5386bd 100644
--- a/exec/java-exec/src/main/resources/rest/logs/log.ftl
+++ b/exec/java-exec/src/main/resources/rest/logs/log.ftl
@@ -24,9 +24,9 @@
     <#if (model.getLines()?size > 0)>
     <pre>
         <#list model.getLines() as line>
-${line}
-            </#list>
-        </pre>
+${line?html}
+        </#list>
+     </pre>
     <#else>
     <div id="message" class="alert alert-info">
         <strong>Log is empty.</strong>


Mime
View raw message