[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 java.text.DecimalFormat; |
---|
| 11 | import org.apache.hadoop.mapred.*; |
---|
| 12 | import org.apache.hadoop.util.*; |
---|
| 13 | |
---|
| 14 | public final class machines_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
| 15 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | public void generateTaskTrackerTable(JspWriter out, |
---|
| 19 | String type, |
---|
| 20 | JobTracker tracker) throws IOException { |
---|
| 21 | Collection c; |
---|
| 22 | if (("blacklisted").equals(type)) { |
---|
| 23 | c = tracker.blacklistedTaskTrackers(); |
---|
| 24 | } else if (("active").equals(type)) { |
---|
| 25 | c = tracker.activeTaskTrackers(); |
---|
| 26 | } else { |
---|
| 27 | c = tracker.taskTrackers(); |
---|
| 28 | } |
---|
| 29 | if (c.size() == 0) { |
---|
| 30 | out.print("There are currently no known " + type + " Task Trackers."); |
---|
| 31 | } else { |
---|
| 32 | out.print("<center>\n"); |
---|
| 33 | out.print("<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n"); |
---|
| 34 | out.print("<tr><td align=\"center\" colspan=\"6\"><b>Task Trackers</b></td></tr>\n"); |
---|
| 35 | out.print("<tr><td><b>Name</b></td><td><b>Host</b></td>" + |
---|
| 36 | "<td><b># running tasks</b></td>" + |
---|
| 37 | "<td><b>Max Map Tasks</b></td>" + |
---|
| 38 | "<td><b>Max Reduce Tasks</b></td>" + |
---|
| 39 | "<td><b>Failures</b></td>" + |
---|
| 40 | "<td><b>Seconds since heartbeat</b></td></tr>\n"); |
---|
| 41 | int maxFailures = 0; |
---|
| 42 | String failureKing = null; |
---|
| 43 | for (Iterator it = c.iterator(); it.hasNext(); ) { |
---|
| 44 | TaskTrackerStatus tt = (TaskTrackerStatus) it.next(); |
---|
| 45 | long sinceHeartbeat = System.currentTimeMillis() - tt.getLastSeen(); |
---|
| 46 | if (sinceHeartbeat > 0) { |
---|
| 47 | sinceHeartbeat = sinceHeartbeat / 1000; |
---|
| 48 | } |
---|
| 49 | int numCurTasks = 0; |
---|
| 50 | for (Iterator it2 = tt.getTaskReports().iterator(); it2.hasNext(); ) { |
---|
| 51 | it2.next(); |
---|
| 52 | numCurTasks++; |
---|
| 53 | } |
---|
| 54 | int numFailures = tt.getFailures(); |
---|
| 55 | if (numFailures > maxFailures) { |
---|
| 56 | maxFailures = numFailures; |
---|
| 57 | failureKing = tt.getTrackerName(); |
---|
| 58 | } |
---|
| 59 | out.print("<tr><td><a href=\"http://"); |
---|
| 60 | out.print(tt.getHost() + ":" + tt.getHttpPort() + "/\">"); |
---|
| 61 | out.print(tt.getTrackerName() + "</a></td><td>"); |
---|
| 62 | out.print(tt.getHost() + "</td><td>" + numCurTasks + |
---|
| 63 | "</td><td>" + tt.getMaxMapTasks() + |
---|
| 64 | "</td><td>" + tt.getMaxReduceTasks() + |
---|
| 65 | "</td><td>" + numFailures + |
---|
| 66 | "</td><td>" + sinceHeartbeat + "</td></tr>\n"); |
---|
| 67 | } |
---|
| 68 | out.print("</table>\n"); |
---|
| 69 | out.print("</center>\n"); |
---|
| 70 | if (maxFailures > 0) { |
---|
| 71 | out.print("Highest Failures: " + failureKing + " with " + maxFailures + |
---|
| 72 | " failures<br>\n"); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | private static java.util.List _jspx_dependants; |
---|
| 79 | |
---|
| 80 | public Object getDependants() { |
---|
| 81 | return _jspx_dependants; |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
| 85 | throws java.io.IOException, ServletException { |
---|
| 86 | |
---|
| 87 | JspFactory _jspxFactory = null; |
---|
| 88 | PageContext pageContext = null; |
---|
| 89 | HttpSession session = null; |
---|
| 90 | ServletContext application = null; |
---|
| 91 | ServletConfig config = null; |
---|
| 92 | JspWriter out = null; |
---|
| 93 | Object page = this; |
---|
| 94 | JspWriter _jspx_out = null; |
---|
| 95 | PageContext _jspx_page_context = null; |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | try { |
---|
| 99 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
| 100 | response.setContentType("text/html; charset=UTF-8"); |
---|
| 101 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
| 102 | null, true, 8192, true); |
---|
| 103 | _jspx_page_context = pageContext; |
---|
| 104 | application = pageContext.getServletContext(); |
---|
| 105 | config = pageContext.getServletConfig(); |
---|
| 106 | session = pageContext.getSession(); |
---|
| 107 | out = pageContext.getOut(); |
---|
| 108 | _jspx_out = out; |
---|
| 109 | |
---|
| 110 | out.write('\n'); |
---|
| 111 | |
---|
| 112 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
| 113 | String trackerName = |
---|
| 114 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
| 115 | String type = request.getParameter("type"); |
---|
| 116 | |
---|
| 117 | out.write('\n'); |
---|
| 118 | out.write("\n\n<html>\n\n<title>"); |
---|
| 119 | out.print(trackerName); |
---|
| 120 | out.write(" Hadoop Machine List</title>\n\n<body>\n<h1><a href=\"jobtracker.jsp\">"); |
---|
| 121 | out.print(trackerName); |
---|
| 122 | out.write("</a> Hadoop Machine List</h1>\n\n<h2>Task Trackers</h2>\n"); |
---|
| 123 | |
---|
| 124 | generateTaskTrackerTable(out, type, tracker); |
---|
| 125 | |
---|
| 126 | out.write('\n'); |
---|
| 127 | out.write('\n'); |
---|
| 128 | |
---|
| 129 | out.println(ServletUtil.htmlFooter()); |
---|
| 130 | |
---|
| 131 | out.write('\n'); |
---|
| 132 | } catch (Throwable t) { |
---|
| 133 | if (!(t instanceof SkipPageException)){ |
---|
| 134 | out = _jspx_out; |
---|
| 135 | if (out != null && out.getBufferSize() != 0) |
---|
| 136 | out.clearBuffer(); |
---|
| 137 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
| 138 | } |
---|
| 139 | } finally { |
---|
| 140 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | } |
---|