[120] | 1 | package org.apache.hadoop.mapred; |
---|
| 2 | |
---|
| 3 | import javax.servlet.*; |
---|
| 4 | import javax.servlet.http.*; |
---|
| 5 | import javax.servlet.jsp.*; |
---|
| 6 | import javax.servlet.*; |
---|
| 7 | import javax.servlet.http.*; |
---|
| 8 | import java.io.*; |
---|
| 9 | import java.util.*; |
---|
| 10 | import org.apache.hadoop.mapred.*; |
---|
| 11 | import org.apache.hadoop.util.*; |
---|
| 12 | import java.lang.Integer; |
---|
| 13 | import java.text.SimpleDateFormat; |
---|
| 14 | |
---|
| 15 | public final class jobtasks_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
| 16 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
| 17 | |
---|
| 18 | static SimpleDateFormat dateFormat = new SimpleDateFormat("d-MMM-yyyy HH:mm:ss") ; |
---|
| 19 | private static java.util.List _jspx_dependants; |
---|
| 20 | |
---|
| 21 | public Object getDependants() { |
---|
| 22 | return _jspx_dependants; |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
| 26 | throws java.io.IOException, ServletException { |
---|
| 27 | |
---|
| 28 | JspFactory _jspxFactory = null; |
---|
| 29 | PageContext pageContext = null; |
---|
| 30 | HttpSession session = null; |
---|
| 31 | ServletContext application = null; |
---|
| 32 | ServletConfig config = null; |
---|
| 33 | JspWriter out = null; |
---|
| 34 | Object page = this; |
---|
| 35 | JspWriter _jspx_out = null; |
---|
| 36 | PageContext _jspx_page_context = null; |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | try { |
---|
| 40 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
| 41 | response.setContentType("text/html; charset=UTF-8"); |
---|
| 42 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
| 43 | null, true, 8192, true); |
---|
| 44 | _jspx_page_context = pageContext; |
---|
| 45 | application = pageContext.getServletContext(); |
---|
| 46 | config = pageContext.getServletConfig(); |
---|
| 47 | session = pageContext.getSession(); |
---|
| 48 | out = pageContext.getOut(); |
---|
| 49 | _jspx_out = out; |
---|
| 50 | |
---|
| 51 | out.write('\n'); |
---|
| 52 | out.write('\n'); |
---|
| 53 | |
---|
| 54 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
| 55 | String trackerName = |
---|
| 56 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
| 57 | String jobid = request.getParameter("jobid"); |
---|
| 58 | if (jobid == null) { |
---|
| 59 | out.println("<h2>Missing 'jobid'!</h2>"); |
---|
| 60 | return; |
---|
| 61 | } |
---|
| 62 | String type = request.getParameter("type"); |
---|
| 63 | String pagenum = request.getParameter("pagenum"); |
---|
| 64 | String state = request.getParameter("state"); |
---|
| 65 | state = (state!=null) ? state : "all"; |
---|
| 66 | int pnum = Integer.parseInt(pagenum); |
---|
| 67 | int next_page = pnum+1; |
---|
| 68 | int numperpage = 2000; |
---|
| 69 | JobID jobidObj = JobID.forName(jobid); |
---|
| 70 | JobInProgress job = (JobInProgress) tracker.getJob(jobidObj); |
---|
| 71 | JobProfile profile = (job != null) ? (job.getProfile()) : null; |
---|
| 72 | JobStatus status = (job != null) ? (job.getStatus()) : null; |
---|
| 73 | TaskReport[] reports = null; |
---|
| 74 | int start_index = (pnum - 1) * numperpage; |
---|
| 75 | int end_index = start_index + numperpage; |
---|
| 76 | int report_len = 0; |
---|
| 77 | if ("map".equals(type)) { |
---|
| 78 | reports = (job != null) ? tracker.getMapTaskReports(jobidObj) : null; |
---|
| 79 | } else if ("reduce".equals(type)) { |
---|
| 80 | reports = (job != null) ? tracker.getReduceTaskReports(jobidObj) : null; |
---|
| 81 | } else if ("cleanup".equals(type)) { |
---|
| 82 | reports = (job != null) ? tracker.getCleanupTaskReports(jobidObj) : null; |
---|
| 83 | } else if ("setup".equals(type)) { |
---|
| 84 | reports = (job != null) ? tracker.getSetupTaskReports(jobidObj) : null; |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | out.write("\n\n<html>\n <head>\n <title>Hadoop "); |
---|
| 88 | out.print(type); |
---|
| 89 | out.write(" task list for "); |
---|
| 90 | out.print(jobid); |
---|
| 91 | out.write(" on "); |
---|
| 92 | out.print(trackerName); |
---|
| 93 | out.write("</title>\n <link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n </head>\n<body>\n<h1>Hadoop "); |
---|
| 94 | out.print(type); |
---|
| 95 | out.write(" task list for \n<a href=\"jobdetails.jsp?jobid="); |
---|
| 96 | out.print(jobid); |
---|
| 97 | out.write('"'); |
---|
| 98 | out.write('>'); |
---|
| 99 | out.print(jobid); |
---|
| 100 | out.write("</a> on \n<a href=\"jobtracker.jsp\">"); |
---|
| 101 | out.print(trackerName); |
---|
| 102 | out.write("</a></h1>\n"); |
---|
| 103 | |
---|
| 104 | if (job == null) { |
---|
| 105 | out.print("<b>Job " + jobid + " not found.</b><br>\n"); |
---|
| 106 | return; |
---|
| 107 | } |
---|
| 108 | // Filtering the reports if some filter is specified |
---|
| 109 | if (!"all".equals(state)) { |
---|
| 110 | List<TaskReport> filteredReports = new ArrayList<TaskReport>(); |
---|
| 111 | for (int i = 0; i < reports.length; ++i) { |
---|
| 112 | if (("completed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.COMPLETE) |
---|
| 113 | || ("running".equals(state) && reports[i].getCurrentStatus() == TIPStatus.RUNNING) |
---|
| 114 | || ("killed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.KILLED) |
---|
| 115 | || ("pending".equals(state) && reports[i].getCurrentStatus() == TIPStatus.PENDING)) { |
---|
| 116 | filteredReports.add(reports[i]); |
---|
| 117 | } |
---|
| 118 | } |
---|
| 119 | // using filtered reports instead of all the reports |
---|
| 120 | reports = filteredReports.toArray(new TaskReport[0]); |
---|
| 121 | filteredReports = null; |
---|
| 122 | } |
---|
| 123 | report_len = reports.length; |
---|
| 124 | |
---|
| 125 | if (report_len <= start_index) { |
---|
| 126 | out.print("<b>No such tasks</b>"); |
---|
| 127 | } else { |
---|
| 128 | out.print("<hr>"); |
---|
| 129 | out.print("<h2>" + Character.toUpperCase(state.charAt(0)) |
---|
| 130 | + state.substring(1).toLowerCase() + " Tasks</h2>"); |
---|
| 131 | out.print("<center>"); |
---|
| 132 | out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">"); |
---|
| 133 | out.print("<tr><td align=\"center\">Task</td><td>Complete</td><td>Status</td>" + |
---|
| 134 | "<td>Start Time</td><td>Finish Time</td><td>Errors</td><td>Counters</td></tr>"); |
---|
| 135 | if (end_index > report_len){ |
---|
| 136 | end_index = report_len; |
---|
| 137 | } |
---|
| 138 | for (int i = start_index ; i < end_index; i++) { |
---|
| 139 | TaskReport report = reports[i]; |
---|
| 140 | out.print("<tr><td><a href=\"taskdetails.jsp?jobid=" + jobid + |
---|
| 141 | "&tipid=" + report.getTaskID() + "\">" + |
---|
| 142 | report.getTaskID() + "</a></td>"); |
---|
| 143 | out.print("<td>" + StringUtils.formatPercent(report.getProgress(),2) + |
---|
| 144 | ServletUtil.percentageGraph(report.getProgress() * 100f, 80) + "</td>"); |
---|
| 145 | out.print("<td>" + report.getState() + "<br/></td>"); |
---|
| 146 | out.println("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, report.getStartTime(),0) + "<br/></td>"); |
---|
| 147 | out.println("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, |
---|
| 148 | report.getFinishTime(), report.getStartTime()) + "<br/></td>"); |
---|
| 149 | String[] diagnostics = report.getDiagnostics(); |
---|
| 150 | out.print("<td><pre>"); |
---|
| 151 | for (int j = 0; j < diagnostics.length ; j++) { |
---|
| 152 | out.println(diagnostics[j]); |
---|
| 153 | } |
---|
| 154 | out.println("</pre><br/></td>"); |
---|
| 155 | out.println("<td>" + |
---|
| 156 | "<a href=\"taskstats.jsp?jobid=" + jobid + |
---|
| 157 | "&tipid=" + report.getTaskID() + |
---|
| 158 | "\">" + report.getCounters().size() + |
---|
| 159 | "</a></td></tr>"); |
---|
| 160 | } |
---|
| 161 | out.print("</table>"); |
---|
| 162 | out.print("</center>"); |
---|
| 163 | } |
---|
| 164 | if (end_index < report_len) { |
---|
| 165 | out.print("<div style=\"text-align:right\">" + |
---|
| 166 | "<a href=\"jobtasks.jsp?jobid="+ jobid + "&type=" + type + |
---|
| 167 | "&pagenum=" + next_page + "&state=" + state + |
---|
| 168 | "\">" + "Next" + "</a></div>"); |
---|
| 169 | } |
---|
| 170 | if (start_index != 0) { |
---|
| 171 | out.print("<div style=\"text-align:right\">" + |
---|
| 172 | "<a href=\"jobtasks.jsp?jobid="+ jobid + "&type=" + type + |
---|
| 173 | "&pagenum=" + (pnum -1) + "&state=" + state + "\">" + "Prev" + "</a></div>"); |
---|
| 174 | } |
---|
| 175 | |
---|
| 176 | out.write("\n\n<hr>\n<a href=\"jobtracker.jsp\">Go back to JobTracker</a><br>\n"); |
---|
| 177 | |
---|
| 178 | out.println(ServletUtil.htmlFooter()); |
---|
| 179 | |
---|
| 180 | out.write('\n'); |
---|
| 181 | } catch (Throwable t) { |
---|
| 182 | if (!(t instanceof SkipPageException)){ |
---|
| 183 | out = _jspx_out; |
---|
| 184 | if (out != null && out.getBufferSize() != 0) |
---|
| 185 | out.clearBuffer(); |
---|
| 186 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
| 187 | } |
---|
| 188 | } finally { |
---|
| 189 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | } |
---|