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.text.*; import java.util.*; import java.text.DecimalFormat; import org.apache.hadoop.mapred.*; import org.apache.hadoop.util.*; import org.apache.hadoop.mapred.TaskGraphServlet; public final class jobdetails_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final String PRIVATE_ACTIONS_KEY = "webinterface.private.actions"; private void printTaskSummary(JspWriter out, String jobId, String kind, double completePercent, TaskInProgress[] tasks ) throws IOException { int totalTasks = tasks.length; int runningTasks = 0; int finishedTasks = 0; int killedTasks = 0; int failedTaskAttempts = 0; int killedTaskAttempts = 0; for(int i=0; i < totalTasks; ++i) { TaskInProgress task = tasks[i]; if (task.isComplete()) { finishedTasks += 1; } else if (task.isRunning()) { runningTasks += 1; } else if (task.wasKilled()) { killedTasks += 1; } failedTaskAttempts += task.numTaskFailures(); killedTaskAttempts += task.numKilledTasks(); } int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; out.print("" + kind + "" + StringUtils.formatPercent(completePercent, 2) + ServletUtil.percentageGraph((int)(completePercent * 100), 80) + "" + totalTasks + "" + ((pendingTasks > 0) ? "" + pendingTasks + "" : "0") + "" + ((runningTasks > 0) ? "" + runningTasks + "" : "0") + "" + ((finishedTasks > 0) ?"" + finishedTasks + "" : "0") + "" + ((killedTasks > 0) ?"" + killedTasks + "" : "0") + "" + ((failedTaskAttempts > 0) ? ("" + failedTaskAttempts + "") : "0" ) + " / " + ((killedTaskAttempts > 0) ? ("" + killedTaskAttempts + "") : "0" ) + "\n"); } private void printJobLevelTaskSummary(JspWriter out, String jobId, String kind, TaskInProgress[] tasks ) throws IOException { int totalTasks = tasks.length; int runningTasks = 0; int finishedTasks = 0; int killedTasks = 0; for(int i=0; i < totalTasks; ++i) { TaskInProgress task = tasks[i]; if (task.isComplete()) { finishedTasks += 1; } else if (task.isRunning()) { runningTasks += 1; } else if (task.isFailed()) { killedTasks += 1; } } int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; out.print(((runningTasks > 0) ? "" + " Running" + "" : ((pendingTasks > 0) ? " Pending" : ((finishedTasks > 0) ?"" + " Successful" + "" : ((killedTasks > 0) ?"" + " Failed" + "" : "None"))))); } private void printConfirm(JspWriter out, String jobId) throws IOException{ String url = "jobdetails.jsp?jobid=" + jobId; out.print("" + "

Are you sure you want to kill " + jobId + " ?


" + "
" + "" + "" + "
" + "
"); } 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; out.write('\n'); out.write('\n'); JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); String trackerName = StringUtils.simpleHostname(tracker.getJobTrackerMachine()); out.write('\n'); out.write(" \n"); String jobId = request.getParameter("jobid"); String refreshParam = request.getParameter("refresh"); if (jobId == null) { out.println("

Missing 'jobid'!

"); return; } int refresh = 60; // refresh every 60 seconds by default if (refreshParam != null) { try { refresh = Integer.parseInt(refreshParam); } catch (NumberFormatException ignored) { } } JobID jobIdObj = JobID.forName(jobId); JobInProgress job = (JobInProgress) tracker.getJob(jobIdObj); String action = request.getParameter("action"); if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) && "changeprio".equalsIgnoreCase(action) && request.getMethod().equalsIgnoreCase("POST")) { tracker.setJobPriority(jobIdObj, JobPriority.valueOf(request.getParameter("prio"))); } if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { action = request.getParameter("action"); if(action!=null && action.equalsIgnoreCase("confirm")) { printConfirm(out, jobId); return; } else if(action != null && action.equalsIgnoreCase("kill") && request.getMethod().equalsIgnoreCase("POST")) { tracker.killJob(jobIdObj); } } out.write("\n\n\n\n\n "); if (refresh != 0) { out.write("\n \n "); } out.write("\nHadoop "); out.print(jobId); out.write(" on "); out.print(trackerName); out.write("\n\n\n\n

Hadoop "); out.print(jobId); out.write(" on "); out.print(trackerName); out.write("

\n\n"); if (job == null) { out.print("Job " + jobId + " not found.
\n"); return; } JobProfile profile = job.getProfile(); JobStatus status = job.getStatus(); int runState = status.getRunState(); int flakyTaskTrackers = job.getNoOfBlackListedTrackers(); out.print("User: " + profile.getUser() + "
\n"); out.print("Job Name: " + profile.getJobName() + "
\n"); out.print("Job File: " + profile.getJobFile() + "
\n"); out.print("Job Setup:"); printJobLevelTaskSummary(out, jobId, "setup", job.getSetupTasks()); out.print("
\n"); if (runState == JobStatus.RUNNING) { out.print("Status: Running
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Running for: " + StringUtils.formatTimeDiff( System.currentTimeMillis(), job.getStartTime()) + "
\n"); } else { if (runState == JobStatus.SUCCEEDED) { out.print("Status: Succeeded
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Finished at: " + new Date(job.getFinishTime()) + "
\n"); out.print("Finished in: " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } else if (runState == JobStatus.FAILED) { out.print("Status: Failed
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Failed at: " + new Date(job.getFinishTime()) + "
\n"); out.print("Failed in: " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } else if (runState == JobStatus.KILLED) { out.print("Status: Killed
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Killed at: " + new Date(job.getFinishTime()) + "
\n"); out.print("Killed in: " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } } out.print("Job Cleanup:"); printJobLevelTaskSummary(out, jobId, "cleanup", job.getCleanupTasks()); out.print("
\n"); if (flakyTaskTrackers > 0) { out.print("Black-listed TaskTrackers: " + "" + flakyTaskTrackers + "
\n"); } if (job.getSchedulingInfo() != null) { out.print("Job Scheduling information: " + job.getSchedulingInfo().toString() +"\n"); } out.print("
\n"); out.print(""); out.print("" + "" + "" + "\n"); printTaskSummary(out, jobId, "map", status.mapProgress(), job.getMapTasks()); printTaskSummary(out, jobId, "reduce", status.reduceProgress(), job.getReduceTasks()); out.print("
Kind% CompleteNum TasksPendingRunningCompleteKilledFailed/Killed
Task Attempts
\n"); out.write("\n

\n \n \n \n \n \n \n \n \n "); Counters mapCounters = job.getMapCounters(); Counters reduceCounters = job.getReduceCounters(); Counters totalCounters = job.getCounters(); for (String groupName : totalCounters.getGroupNames()) { Counters.Group totalGroup = totalCounters.getGroup(groupName); Counters.Group mapGroup = mapCounters.getGroup(groupName); Counters.Group reduceGroup = reduceCounters.getGroup(groupName); Format decimal = new DecimalFormat(); boolean isFirst = true; for (Counters.Counter counter : totalGroup) { String name = counter.getDisplayName(); String mapValue = decimal.format(mapGroup.getCounter(name)); String reduceValue = decimal.format(reduceGroup.getCounter(name)); String totalValue = decimal.format(counter.getCounter()); out.write("\n \n "); if (isFirst) { isFirst = false; out.write("\n \n "); } out.write("\n \n \n \n \n \n "); } } out.write("\n

CounterMapReduceTotal
'); out.print(totalGroup.getDisplayName()); out.write(""); out.print(name); out.write(""); out.print(mapValue); out.write(""); out.print(reduceValue); out.write(""); out.print(totalValue); out.write("
\n\n


Map Completion Graph - \n"); if("off".equals(request.getParameter("map.graph"))) { session.setAttribute("map.graph", "off"); } else if("on".equals(request.getParameter("map.graph"))){ session.setAttribute("map.graph", "on"); } if("off".equals(request.getParameter("reduce.graph"))) { session.setAttribute("reduce.graph", "off"); } else if("on".equals(request.getParameter("reduce.graph"))){ session.setAttribute("reduce.graph", "on"); } if("off".equals(session.getAttribute("map.graph"))) { out.write("\n open \n"); } else { out.write(" \n close \n
\n"); } out.write('\n'); out.write('\n'); if(job.getReduceTasks().length > 0) { out.write("\n
Reduce Completion Graph -\n"); if("off".equals(session.getAttribute("reduce.graph"))) { out.write("\n open \n"); } else { out.write(" \n close \n \n
\n"); } } out.write("\n\n
\n"); if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { out.write("\n
\n Change priority from "); out.print(job.getPriority()); out.write(" to:\n
\n \n \n
\n"); } out.write("\n\n\n \n"); if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) && runState == JobStatus.RUNNING) { out.write("\n\t
Kill this job \n"); } out.write("\n\n
\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); } } }