hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1621061 - in /hama/trunk/core/src/main: java/org/apache/hama/manager/LogView.java java/org/apache/hama/util/BSPServletUtil.java resources/webapp/bspmaster/bspjob.jsp resources/webapp/commons/tpl/tpl.logview.html
Date Thu, 28 Aug 2014 06:37:57 GMT
Author: edwardyoon
Date: Thu Aug 28 06:37:56 2014
New Revision: 1621061

URL: http://svn.apache.org/r1621061
Log:
HAMA-910: Web UI Improvement

Modified:
    hama/trunk/core/src/main/java/org/apache/hama/manager/LogView.java
    hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java
    hama/trunk/core/src/main/resources/webapp/bspmaster/bspjob.jsp
    hama/trunk/core/src/main/resources/webapp/commons/tpl/tpl.logview.html

Modified: hama/trunk/core/src/main/java/org/apache/hama/manager/LogView.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/manager/LogView.java?rev=1621061&r1=1621060&r2=1621061&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/manager/LogView.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/manager/LogView.java Thu Aug 28 06:37:56
2014
@@ -37,7 +37,9 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
@@ -45,8 +47,16 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hama.bsp.BSPJobID;
+import org.apache.hama.bsp.BSPMaster;
+import org.apache.hama.bsp.ClusterStatus;
+import org.apache.hama.bsp.GroomServerStatus;
+import org.apache.hama.bsp.JobStatus;
 import org.apache.hama.manager.util.UITemplate;
 
+/**
+ * Log viewer class for for BSP Server.
+ */
 public class LogView {
 
   /**
@@ -196,11 +206,11 @@ public class LogView {
 
       String logfilePath = logDirPath + "/" + fileName;
 
-      if (pageType.equals("download")) {
+      if (pageType.equals("download")) { // download log file
 
         LogView.downloadFile(response, logfilePath);
 
-      } else {
+      } else { // log viewer 
 
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
@@ -221,7 +231,7 @@ public class LogView {
         out.println(uit.convert(tplHead, vars));
         vars.clear();
 
-        if (pageType.equals("list")) { // list page
+        if (pageType.equals("list")) { // list 
 
           String[] listArea = new String[4];
           listArea[0] = uit.getArea(tplfile, "list0");
@@ -259,7 +269,7 @@ public class LogView {
           vars.clear();
           out.println(uit.convert(listArea[3], vars));
 
-        } else if (pageType.equals("detail")) { // detail page
+        } else if (pageType.equals("detail")) { // detail 
 
           String[] detailArea = new String[4];
           detailArea[0] = uit.getArea(tplfile, "detail0");
@@ -295,7 +305,7 @@ public class LogView {
 
           out.println(uit.convert(detailArea[2], vars));
 
-        } else if (pageType.equals("tail")) { // tail page
+        } else if (pageType.equals("tail")) { // tail 
           String tailLine = request.getParameter("tailLine");
           tailLine = (tailLine == null) ? "100" : tailLine;
 
@@ -353,14 +363,53 @@ public class LogView {
           vars.clear();
           out.println(uit.convert(tailArea[2], vars));
 
+        } else if (pageType.equals("tasklist")) { // job list
+          String jobId = request.getParameter("jobId");
+          String[] listArea = new String[3];
+          listArea[0] = uit.getArea(tplfile, "tasklist0");
+          listArea[1] = uit.getArea(tplfile, "tasklist1");
+          listArea[2] = uit.getArea(tplfile, "tasklist2");
+
+          ServletContext ctx = getServletContext();
+          BSPMaster tracker = (BSPMaster) ctx.getAttribute("bsp.master");
+          ClusterStatus status = tracker.getClusterStatus(true);
+          JobStatus jobStatus = tracker.getJobStatus(BSPJobID.forName(jobId));
+
+          vars.put("hamaLogDir", hamaLogDir);
+          vars.put("dirName", dirName);
+          vars.put("targetUri", targetUri);
+          vars.put("jobId", jobId);
+          vars.put("jobStatus", jobStatus.getState().toString());
+          vars.put("jobName", jobStatus.getName());
+
+          out.println(uit.convert(listArea[0], vars));
+          vars.clear();
+
+          for (Entry<String, GroomServerStatus> entry : status
+              .getActiveGroomServerStatus().entrySet()) {
+            vars.put("jobId", jobId);
+            vars.put("dirName", dirName);
+            vars.put("serverName", entry.getKey());
+            vars.put("hostName", entry.getValue().getGroomHostName());
+            vars.put("targetUri", targetUri);
+            vars.put("type", "dir");
+            out.println(uit.convert(listArea[1], vars));
+
+          }
+
+          vars.clear();
+          out.println(uit.convert(listArea[2], vars));
         }
 
-        vars.clear();
         out.println(tplTail);
       }
 
     }
 
+    /**
+     * Get Hama log Directory
+     * @return hama log directory
+     */
     private static String getLogHomeDir() {
       Map<String, String> env = System.getenv();
       String hamaHome = env.get("HAMA_HOME");

Modified: hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java?rev=1621061&r1=1621060&r2=1621061&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java (original)
+++ hama/trunk/core/src/main/java/org/apache/hama/util/BSPServletUtil.java Thu Aug 28 06:37:56
2014
@@ -78,7 +78,9 @@ public class BSPServletUtil extends Serv
         sb.append("</td><td>");
         sb.append(new Date(status.getStartTime()));
         sb.append("</td><td>");
-        sb.append("<a href=\"/logView?dir=tasklogs/");
+        sb.append("<a href=\"/logView?type=tasklist&jobId=");
+        sb.append(status.getJobID());            
+        sb.append("&dir=tasklogs/");
         sb.append(status.getJobID());
         sb.append("\">view</a>");
         sb.append("</td></tr>\n");

Modified: hama/trunk/core/src/main/resources/webapp/bspmaster/bspjob.jsp
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/resources/webapp/bspmaster/bspjob.jsp?rev=1621061&r1=1621060&r2=1621061&view=diff
==============================================================================
--- hama/trunk/core/src/main/resources/webapp/bspmaster/bspjob.jsp (original)
+++ hama/trunk/core/src/main/resources/webapp/bspmaster/bspjob.jsp Thu Aug 28 06:37:56 2014
@@ -60,7 +60,7 @@
       <td>
         <% if(status.getFinishTime() != 0L) {out.write(new Date(status.getFinishTime()).toString());}
%>
       </td>
-      <td><a href="/logView?dir=tasklogs/<%=idString%>">view</a></td>
     
+      <td><a href="/logView?dir=tasklogs/<%=idString%>&jobId=<%=idString%>&type=tasklist">view</a></td>
     
     </tr>
 
   </table>
@@ -110,9 +110,6 @@
   </div>
   <p/>
   <hr>
-    <h2>Job Logs</h2>
-    <a href="/logView?dir=tasklogs/<%=idString%>">Log</a> directory
-  <hr>
   <a href="bspmaster.jsp"><i>Back to BSPMaster</i></a>
 
   <%

Modified: hama/trunk/core/src/main/resources/webapp/commons/tpl/tpl.logview.html
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/resources/webapp/commons/tpl/tpl.logview.html?rev=1621061&r1=1621060&r2=1621061&view=diff
==============================================================================
--- hama/trunk/core/src/main/resources/webapp/commons/tpl/tpl.logview.html (original)
+++ hama/trunk/core/src/main/resources/webapp/commons/tpl/tpl.logview.html Thu Aug 28 06:37:56
2014
@@ -162,13 +162,55 @@ ${logLine}
 </div>  
 <!--{area,end,logtail2}-->
 
+<!--{area,begin,tasklist0}-->
+<h2>${jobName}</h2>
+<div class="block-detail">
+<ul>
+    <li><span>Job ID : </span>${jobId}</li>
+    <li><span>Status : </span>${jobStatus}</li>
+</ul>
+</div>
+
+<hr>
+<div class="block-list-log">
+<table class="full-width">
+<thead>
+  <tr>
+    <th>Job ID</th>
+    <th>Server Name</th>
+    <th>Hostname</th>
+    <th>Directory</th>
+    <th>Type</th>    
+    <th>Etc</th>
+  </tr>
+</thead>  
+<tbody>
+<!--{area,end,tasklist0}-->
+
+<!--{area,begin,tasklist1}-->
+  <tr>
+    <td><a href="/bspjob.jsp?jobid=${jobId}">${jobId}</a></td>  
 
+    <td><a href="http://${serverName}/">${serverName}</a></td>
+    <td>${hostName}</td>    
+    <td><a href="http://${serverName}/logView?dir=${dirName}/${fileName}">/${dirName}</a></td>
+    <td>${type}</td>    
+    <td>
+      <a href="http://${serverName}/logView?dir=${dirName}/${fileName}" class="link-container"><span
class="link-title">view</span></a>
+    </td>
+  </tr>
+<!--{area,end,tasklist1}-->
+
+<!--{area,begin,tasklist2}-->
+</tbody>
+</table>
+</div>
+<!--{area,end,tasklist2}-->
 
 <!--{area,begin,tail}-->
 <hr />
 <div id="footer" class="contents">
-<a href='http://hama.apache.org/'>Apache Hama</a>
+  <a href='http://hama.apache.org/'>Apache Hama</a>
 </div>
-</body></html>
 </body>
 </html>
 <!--{area,end,tail}-->
\ No newline at end of file



Mime
View raw message