org.apache.hadoop.mapred.jobtasks_jsp Maven / Gradle / Ivy
The newest version!
package org.apache.hadoop.mapred;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.hadoop.http.HtmlQuoting;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.mapred.JSPUtil.JobWithViewAccessCheck;
import org.apache.hadoop.util.*;
import java.lang.Integer;
import java.text.SimpleDateFormat;
public final class jobtasks_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final long serialVersionUID = 1L;
static SimpleDateFormat dateFormat = new SimpleDateFormat("d-MMM-yyyy HH:mm:ss") ;
private static java.util.List _jspx_dependants;
public Object getDependants() {
return _jspx_dependants;
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
JspFactory _jspxFactory = null;
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
_jspxFactory = JspFactory.getDefaultFactory();
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
/*
* 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.
*/
out.write('\n');
out.write('\n');
out.write('\n');
out.write('\n');
JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
String trackerName =
StringUtils.simpleHostname(tracker.getJobTrackerMachine());
String jobid = request.getParameter("jobid");
if (jobid == null) {
out.println("Missing 'jobid'!
");
return;
}
JobID jobidObj = JobID.forName(jobid);
JobWithViewAccessCheck myJob = JSPUtil.checkAccessAndGetJob(tracker, jobidObj,
request, response);
if (!myJob.isViewJobAllowed()) {
return; // user is not authorized to view this job
}
JobInProgress job = myJob.getJob();
String type = request.getParameter("type");
String pagenum = request.getParameter("pagenum");
String state = request.getParameter("state");
state = (state!=null) ? state : "all";
int pnum = Integer.parseInt(pagenum);
int next_page = pnum+1;
int numperpage = 2000;
TaskReport[] reports = null;
int start_index = (pnum - 1) * numperpage;
int end_index = start_index + numperpage;
int report_len = 0;
if ("map".equals(type)) {
reports = (job != null) ? tracker.getMapTaskReports(jobidObj) : null;
} else if ("reduce".equals(type)) {
reports = (job != null) ? tracker.getReduceTaskReports(jobidObj) : null;
} else if ("cleanup".equals(type)) {
reports = (job != null) ? tracker.getCleanupTaskReports(jobidObj) : null;
} else if ("setup".equals(type)) {
reports = (job != null) ? tracker.getSetupTaskReports(jobidObj) : null;
}
out.write("\n\n\n \n Hadoop ");
out.print(type);
out.write(" task list for ");
out.print(jobid);
out.write(" on ");
out.print(trackerName);
out.write(" \n \n \n\nHadoop ");
out.print(type);
out.write(" task list for \n');
out.print(jobid);
out.write(" on \n");
out.print(trackerName);
out.write("
\n");
// redirect to history page if it cannot be found in memory
if (job == null) {
JobID jobIdObj = JobID.forName(jobid);
String historyFile = tracker.getJobHistory().getHistoryFilePath(jobIdObj);
if (historyFile == null) {
out.println("Job " + jobid + " not known!
");
return;
}
String historyUrl = "/jobtaskshistory.jsp?logFile=" + historyFile +
"&status=" + state + "&taskType=" + type;
response.sendRedirect(response.encodeRedirectURL(historyUrl));
return;
}
// Filtering the reports if some filter is specified
if (!"all".equals(state)) {
List filteredReports = new ArrayList();
for (int i = 0; i < reports.length; ++i) {
if (("completed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.COMPLETE)
|| ("running".equals(state) && reports[i].getCurrentStatus() == TIPStatus.RUNNING)
|| ("killed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.KILLED)
|| ("pending".equals(state) && reports[i].getCurrentStatus() == TIPStatus.PENDING)) {
filteredReports.add(reports[i]);
}
}
// using filtered reports instead of all the reports
reports = filteredReports.toArray(new TaskReport[0]);
filteredReports = null;
}
report_len = reports.length;
if (report_len <= start_index) {
out.print("No such tasks");
} else {
out.print("
");
out.print("" + Character.toUpperCase(state.charAt(0))
+ state.substring(1).toLowerCase() + " Tasks
");
out.print("");
out.print("");
out.print("Task Complete Status " +
"Start Time Finish Time Errors Counters ");
if (end_index > report_len){
end_index = report_len;
}
for (int i = start_index ; i < end_index; i++) {
TaskReport report = reports[i];
out.print("" + report.getTaskID() + " ");
out.print("" + StringUtils.formatPercent(report.getProgress(),2) +
ServletUtil.percentageGraph(report.getProgress() * 100f, 80) + " ");
out.print("" + HtmlQuoting.quoteHtmlChars(report.getState()) + "
");
out.println("" + StringUtils.getFormattedTimeWithDiff(dateFormat, report.getStartTime(),0) + "
");
out.println("" + StringUtils.getFormattedTimeWithDiff(dateFormat,
report.getFinishTime(), report.getStartTime()) + "
");
String[] diagnostics = report.getDiagnostics();
out.print("");
for (int j = 0; j < diagnostics.length ; j++) {
out.println(HtmlQuoting.quoteHtmlChars(diagnostics[j]));
}
out.println("
");
out.println("" +
"" + report.getCounters().size() +
" ");
}
out.print("
");
out.print(" ");
}
if (end_index < report_len) {
out.print("" +
"" + "Next" + "");
}
if (start_index != 0) {
out.print("" +
"" + "Prev" + "");
}
out.write("\n\n
\nGo back to JobTracker
\n");
out.println(ServletUtil.htmlFooter());
out.write('\n');
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
out.clearBuffer();
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
}
}
}