You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2006/11/14 20:26:16 UTC
svn commit: r474928 - in /lucene/hadoop/trunk: CHANGES.txt
src/java/org/apache/hadoop/util/XMLUtils.java src/webapps/job/jobconf.jsp
src/webapps/job/jobdetails.jsp src/webapps/static/jobconf.xsl
Author: cutting
Date: Tue Nov 14 11:26:15 2006
New Revision: 474928
URL: http://svn.apache.org/viewvc?view=rev&rev=474928
Log:
HADOOP-661. Make each job's configuration visible through the web ui. Contributed by Arun.
Added:
lucene/hadoop/trunk/src/java/org/apache/hadoop/util/XMLUtils.java
lucene/hadoop/trunk/src/webapps/job/jobconf.jsp
lucene/hadoop/trunk/src/webapps/static/jobconf.xsl
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/webapps/job/jobdetails.jsp
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=474928&r1=474927&r2=474928
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Nov 14 11:26:15 2006
@@ -60,6 +60,9 @@
sort pass over the data and should consequently significantly
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
Added: lucene/hadoop/trunk/src/java/org/apache/hadoop/util/XMLUtils.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/util/XMLUtils.java?view=auto&rev=474928
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/util/XMLUtils.java (added)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/util/XMLUtils.java Tue Nov 14 11:26:15 2006
@@ -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));
+ }
+}
Added: lucene/hadoop/trunk/src/webapps/job/jobconf.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/job/jobconf.jsp?view=auto&rev=474928
==============================================================================
--- lucene/hadoop/trunk/src/webapps/job/jobconf.jsp (added)
+++ lucene/hadoop/trunk/src/webapps/job/jobconf.jsp Tue Nov 14 11:26:15 2006
@@ -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>
\ No newline at end of file
Modified: lucene/hadoop/trunk/src/webapps/job/jobdetails.jsp
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/job/jobdetails.jsp?view=diff&rev=474928&r1=474927&r2=474928
==============================================================================
--- lucene/hadoop/trunk/src/webapps/job/jobdetails.jsp (original)
+++ lucene/hadoop/trunk/src/webapps/job/jobdetails.jsp Tue Nov 14 11:26:15 2006
@@ -59,11 +59,16 @@
}
JobProfile profile = job.getProfile();
JobStatus status = job.getStatus();
+ int runState = status.getRunState();
out.print("<b>User:</b> " + profile.getUser() + "<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");
- int runState = status.getRunState();
if (runState == JobStatus.RUNNING) {
out.print("<b>Status:</b> Running<br>\n");
} else {
Added: lucene/hadoop/trunk/src/webapps/static/jobconf.xsl
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/static/jobconf.xsl?view=auto&rev=474928
==============================================================================
--- lucene/hadoop/trunk/src/webapps/static/jobconf.xsl (added)
+++ lucene/hadoop/trunk/src/webapps/static/jobconf.xsl Tue Nov 14 11:26:15 2006
@@ -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>