incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject git commit: Updating status pages to allow for downloading the log files.
Date Sun, 08 Mar 2015 19:58:44 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master 2ca85fa2b -> 047b62bc9


Updating status pages to allow for downloading the log files.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/047b62bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/047b62bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/047b62bc

Branch: refs/heads/master
Commit: 047b62bc9a31bfc91897912ab6d7968512e9590d
Parents: 2ca85fa
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Sun Mar 8 15:58:39 2015 -0400
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Sun Mar 8 15:58:39 2015 -0400

----------------------------------------------------------------------
 .../org/apache/blur/gui/HttpJettyServer.java    |  8 +--
 .../java/org/apache/blur/gui/LogServlet.java    | 42 -------------
 .../java/org/apache/blur/gui/LogsServlet.java   | 64 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/047b62bc/blur-status/src/main/java/org/apache/blur/gui/HttpJettyServer.java
----------------------------------------------------------------------
diff --git a/blur-status/src/main/java/org/apache/blur/gui/HttpJettyServer.java b/blur-status/src/main/java/org/apache/blur/gui/HttpJettyServer.java
index 8b8e4c4..6c7c384 100644
--- a/blur-status/src/main/java/org/apache/blur/gui/HttpJettyServer.java
+++ b/blur-status/src/main/java/org/apache/blur/gui/HttpJettyServer.java
@@ -49,8 +49,6 @@ public class HttpJettyServer {
   public HttpJettyServer(Class<?> c, int port) throws IOException {
     server = new Server(port);
     String logDir = System.getProperty("blur.logs.dir");
-    String logFile = System.getProperty("blur.log.file");
-    String blurLogFile = logDir + "/" + logFile;
     LOG.info("System props:" + System.getProperties().toString());
 
     context = new WebAppContext();
@@ -59,11 +57,9 @@ public class HttpJettyServer {
     context.setContextPath("/");
     context.setParentLoaderPriority(true);
     context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
-    context.addServlet(new ServletHolder(new LogServlet(blurLogFile)), "/logs");
-
+    context.addServlet(new ServletHolder(new LogsServlet(logDir)), "/logs");
+    context.addServlet(new ServletHolder(new LogServlet(logDir)), "/log");
     LOG.info("Http server thinks its at: " + warPath);
-    LOG.info("Http server log file being exposed: " + logDir == null ? "STDOUT" : blurLogFile);
-
     server.setHandler(context);
 
     try {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/047b62bc/blur-status/src/main/java/org/apache/blur/gui/LogServlet.java
----------------------------------------------------------------------
diff --git a/blur-status/src/main/java/org/apache/blur/gui/LogServlet.java b/blur-status/src/main/java/org/apache/blur/gui/LogServlet.java
deleted file mode 100644
index ff6ba5c..0000000
--- a/blur-status/src/main/java/org/apache/blur/gui/LogServlet.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.apache.blur.gui;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-@SuppressWarnings("serial")
-public class LogServlet extends HttpServlet {
-
-  private final String _filePath;
-
-  public LogServlet(String filePath) {
-    _filePath = filePath;
-  }
-
-  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
-    response.setContentType("text/html");
-    PrintWriter out = response.getWriter();
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/047b62bc/blur-status/src/main/java/org/apache/blur/gui/LogsServlet.java
----------------------------------------------------------------------
diff --git a/blur-status/src/main/java/org/apache/blur/gui/LogsServlet.java b/blur-status/src/main/java/org/apache/blur/gui/LogsServlet.java
new file mode 100644
index 0000000..8e7faf8
--- /dev/null
+++ b/blur-status/src/main/java/org/apache/blur/gui/LogsServlet.java
@@ -0,0 +1,64 @@
+package org.apache.blur.gui;
+
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.io.File;
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+@SuppressWarnings("serial")
+public class LogsServlet extends HttpServlet {
+
+  private final String _dir;
+
+  public LogsServlet(String dir) {
+    _dir = dir;
+  }
+
+  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
+    try {
+      processGet(request, response);
+    } catch (JSONException e) {
+      throw new IOException(e);
+    }
+  }
+
+  private void processGet(HttpServletRequest request, HttpServletResponse response) throws
JSONException, IOException {
+    response.setContentType("text/html");
+    listFiles(response);
+  }
+
+  private void listFiles(HttpServletResponse response) throws JSONException, IOException
{
+    JSONObject jsonObject = new JSONObject();
+    File[] files = new File(_dir).listFiles();
+    JSONArray array = new JSONArray();
+    for (File file : files) {
+      array.put(file.getName());
+    }
+    jsonObject.put("files", array);
+    jsonObject.write(response.getWriter());
+  }
+
+}


Mime
View raw message