瀏覽代碼

HADOOP-661. Make each job's configuration visible through the web ui. Contributed by Arun.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@474928 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 年之前
父節點
當前提交
4a5e950730

+ 3 - 0
CHANGES.txt

@@ -60,6 +60,9 @@ Trunk (unreleased changes)
     sort pass over the data and should consequently significantly
     sort pass over the data and should consequently significantly
     decrease overall processing time.  (Devaraj Das via cutting)
     decrease overall processing time.  (Devaraj Das via cutting)
 
 
+19. HADOOP-661.  Make each job's configuration visible through the web
+    ui.  (Arun C Murthy via cutting)
+
 
 
 Release 0.8.0 - 2006-11-03
 Release 0.8.0 - 2006-11-03
 
 

+ 57 - 0
src/java/org/apache/hadoop/util/XMLUtils.java

@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+
+package org.apache.hadoop.util;
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.*;
+import java.io.*;
+
+/**
+ * General xml utilities.
+ *   
+ * @author Arun C Murthy
+ */
+public class XMLUtils {
+  /**
+   * Transform input xml given a stylesheet.
+   * 
+   * @param styleSheet the style-sheet
+   * @param xml input xml data
+   * @param out output
+   * @throws TransformerConfigurationException
+   * @throws TransformerException
+   */
+  public static void transform(
+          InputStream styleSheet, InputStream xml, Writer out
+          ) 
+  throws TransformerConfigurationException, TransformerException {
+    // Instantiate a TransformerFactory
+    TransformerFactory tFactory = TransformerFactory.newInstance();
+
+    // Use the TransformerFactory to process the  
+    // stylesheet and generate a Transformer
+    Transformer transformer = tFactory.newTransformer(
+                                  new StreamSource(styleSheet)
+                                );
+
+    // Use the Transformer to transform an XML Source 
+    // and send the output to a Result object.
+    transformer.transform(new StreamSource(xml), new StreamResult(out));
+  }
+}

+ 65 - 0
src/webapps/job/jobconf.jsp

@@ -0,0 +1,65 @@
+<%@ page
+  contentType="text/html; charset=UTF-8"
+  import="javax.servlet.*"
+  import="javax.servlet.http.*"
+  import="java.io.*"
+  import="java.net.URL"
+  import="org.apache.hadoop.mapred.*"
+  import="org.apache.hadoop.util.*"
+%>
+
+
+<%
+  String jobId = request.getParameter("jobid");
+  if (jobId == null) {
+    out.println("<h2>Missing 'jobid' for fetching job configuration!</h2>");
+ 	return;
+  }
+%>
+  
+<html>
+
+<title>Job Configuration: JobId - <%= jobId %></title>
+
+<body>
+<h2>Job Configuration: JobId - <%= jobId %></h2><br>
+
+<%
+  JobTracker tracker = JobTracker.getTracker();
+  
+  JobInProgress job = (JobInProgress)tracker.getJob(jobId);
+  if (job == null) {
+    out.print("<h4>Job '" + jobId + "' not found!</h4><br>\n");
+    return;
+  }
+  
+  JobStatus status = job.getStatus();
+  int runState = status.getRunState();
+  if (runState != JobStatus.RUNNING) {
+    out.print("<h4>Job '" + jobId + "' not running!</h4><br>\n");
+    return;
+  }
+  
+  try {
+    JobConf jobConf = job.getJobConf();
+    ByteArrayOutputStream jobConfXML = new ByteArrayOutputStream();
+    jobConf.write(jobConfXML);
+    String baseUrl = request.getScheme() + "://" + request.getServerName() + ":"
+                     + request.getServerPort();
+    URL jobConfXSL = new URL(baseUrl + "/static/jobconf.xsl");
+    XMLUtils.transform(jobConfXSL.openStream(),
+	    new ByteArrayInputStream(jobConfXML.toByteArray()), 
+	    out
+	  );
+  } catch (Exception e) {
+    out.println("Failed to retreive job configuration for job '" + jobId + "!");
+    out.println(e);
+  }
+%>
+
+<br>
+<hr>
+<a href="http://lucene.apache.org/hadoop">Hadoop</a>, 2006.<br>
+
+</body>
+</html>

+ 7 - 2
src/webapps/job/jobdetails.jsp

@@ -59,11 +59,16 @@
     }
     }
     JobProfile profile = job.getProfile();
     JobProfile profile = job.getProfile();
     JobStatus status = job.getStatus();
     JobStatus status = job.getStatus();
+    int runState = status.getRunState();
     out.print("<b>User:</b> " + profile.getUser() + "<br>\n");
     out.print("<b>User:</b> " + profile.getUser() + "<br>\n");
     out.print("<b>Job Name:</b> " + profile.getJobName() + "<br>\n");
     out.print("<b>Job Name:</b> " + profile.getJobName() + "<br>\n");
-    out.print("<b>Job File:</b> " + profile.getJobFile() + "<br>\n");
+    if (runState == JobStatus.RUNNING) {
+      out.print("<b>Job File:</b> <a href=\"/jobconf.jsp?jobid=" + jobId + "\">" + 
+          profile.getJobFile() + "</a><br>\n");
+    } else {
+      out.print("<b>Job File:</b> " + profile.getJobFile() + "<br>\n");
+    }
     out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
     out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
-    int runState = status.getRunState();
     if (runState == JobStatus.RUNNING) {
     if (runState == JobStatus.RUNNING) {
       out.print("<b>Status:</b> Running<br>\n");
       out.print("<b>Status:</b> Running<br>\n");
     } else {
     } else {

+ 18 - 0
src/webapps/static/jobconf.xsl

@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+<xsl:output method="html"/>
+<xsl:template match="configuration">
+<table border="1" align="center" >
+<tr>
+ <th>name</th>
+ <th>value</th>
+</tr>
+<xsl:for-each select="property">
+<tr>
+  <td width="35%"><b><xsl:value-of select="name"/></b></td>
+  <td width="65%"><xsl:value-of select="value"/></td>
+</tr>
+</xsl:for-each>
+</table>
+</xsl:template>
+</xsl:stylesheet>