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("

Missing 'jobid' for fetching job configuration!

"); + return; + } +%> + + + +Job Configuration: JobId - <%= jobId %> + + +

Job Configuration: JobId - <%= jobId %>


+ +<% + JobTracker tracker = JobTracker.getTracker(); + + JobInProgress job = (JobInProgress)tracker.getJob(jobId); + if (job == null) { + out.print("

Job '" + jobId + "' not found!


\n"); + return; + } + + JobStatus status = job.getStatus(); + int runState = status.getRunState(); + if (runState != JobStatus.RUNNING) { + out.print("

Job '" + jobId + "' not running!


\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); + } +%> + +
+
+Hadoop, 2006.
+ + + \ 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("User: " + profile.getUser() + "
\n"); out.print("Job Name: " + profile.getJobName() + "
\n"); - out.print("Job File: " + profile.getJobFile() + "
\n"); + if (runState == JobStatus.RUNNING) { + out.print("Job File: " + + profile.getJobFile() + "
\n"); + } else { + out.print("Job File: " + profile.getJobFile() + "
\n"); + } out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); - int runState = status.getRunState(); if (runState == JobStatus.RUNNING) { out.print("Status: Running
\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 @@ + + + + + + + + + + + + + + + +
namevalue
+
+