[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 jobtracker_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
| 15 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | private static DecimalFormat percentFormat = new DecimalFormat("##0.00"); |
---|
| 19 | |
---|
| 20 | public void generateSummaryTable(JspWriter out, ClusterStatus status, |
---|
| 21 | JobTracker tracker) throws IOException { |
---|
| 22 | String tasksPerNode = status.getTaskTrackers() > 0 ? |
---|
| 23 | percentFormat.format(((double)(status.getMaxMapTasks() + |
---|
| 24 | status.getMaxReduceTasks())) / status.getTaskTrackers()): |
---|
| 25 | "-"; |
---|
| 26 | out.print("<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">\n"+ |
---|
| 27 | "<tr><th>Maps</th><th>Reduces</th>" + |
---|
| 28 | "<th>Total Submissions</th>" + |
---|
| 29 | "<th>Nodes</th><th>Map Task Capacity</th>" + |
---|
| 30 | "<th>Reduce Task Capacity</th><th>Avg. Tasks/Node</th>" + |
---|
| 31 | "<th>Blacklisted Nodes</th></tr>\n"); |
---|
| 32 | out.print("<tr><td>" + status.getMapTasks() + "</td><td>" + |
---|
| 33 | status.getReduceTasks() + "</td><td>" + |
---|
| 34 | tracker.getTotalSubmissions() + |
---|
| 35 | "</td><td><a href=\"machines.jsp?type=active\">" + |
---|
| 36 | status.getTaskTrackers() + |
---|
| 37 | "</a></td><td>" + status.getMaxMapTasks() + |
---|
| 38 | "</td><td>" + status.getMaxReduceTasks() + |
---|
| 39 | "</td><td>" + tasksPerNode + |
---|
| 40 | "</td><td><a href=\"machines.jsp?type=blacklisted\">" + |
---|
| 41 | status.getBlacklistedTrackers() + "</a>" + |
---|
| 42 | "</td></tr></table>\n"); |
---|
| 43 | |
---|
| 44 | out.print("<br>"); |
---|
| 45 | if (tracker.hasRestarted()) { |
---|
| 46 | out.print("<span class=\"small\"><i>"); |
---|
| 47 | if (tracker.hasRecovered()) { |
---|
| 48 | out.print("The JobTracker got restarted and recovered back in " ); |
---|
| 49 | out.print(StringUtils.formatTime(tracker.getRecoveryDuration())); |
---|
| 50 | } else { |
---|
| 51 | out.print("The JobTracker got restarted and is still recovering"); |
---|
| 52 | } |
---|
| 53 | out.print("</i></span>"); |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | private static java.util.List _jspx_dependants; |
---|
| 57 | |
---|
| 58 | public Object getDependants() { |
---|
| 59 | return _jspx_dependants; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
| 63 | throws java.io.IOException, ServletException { |
---|
| 64 | |
---|
| 65 | JspFactory _jspxFactory = null; |
---|
| 66 | PageContext pageContext = null; |
---|
| 67 | HttpSession session = null; |
---|
| 68 | ServletContext application = null; |
---|
| 69 | ServletConfig config = null; |
---|
| 70 | JspWriter out = null; |
---|
| 71 | Object page = this; |
---|
| 72 | JspWriter _jspx_out = null; |
---|
| 73 | PageContext _jspx_page_context = null; |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | try { |
---|
| 77 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
| 78 | response.setContentType("text/html; charset=UTF-8"); |
---|
| 79 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
| 80 | null, true, 8192, true); |
---|
| 81 | _jspx_page_context = pageContext; |
---|
| 82 | application = pageContext.getServletContext(); |
---|
| 83 | config = pageContext.getServletConfig(); |
---|
| 84 | session = pageContext.getSession(); |
---|
| 85 | out = pageContext.getOut(); |
---|
| 86 | _jspx_out = out; |
---|
| 87 | |
---|
| 88 | out.write('\n'); |
---|
| 89 | |
---|
| 90 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
| 91 | ClusterStatus status = tracker.getClusterStatus(); |
---|
| 92 | String trackerName = |
---|
| 93 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
| 94 | JobQueueInfo[] queues = tracker.getQueues(); |
---|
| 95 | Vector<JobInProgress> runningJobs = tracker.runningJobs(); |
---|
| 96 | Vector<JobInProgress> completedJobs = tracker.completedJobs(); |
---|
| 97 | Vector<JobInProgress> failedJobs = tracker.failedJobs(); |
---|
| 98 | |
---|
| 99 | out.write('\n'); |
---|
| 100 | out.write("\n\n\n<html>\n<head>\n<title>"); |
---|
| 101 | out.print( trackerName ); |
---|
| 102 | out.write(" Hadoop Map/Reduce Administration</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n<script type=\"text/javascript\" src=\"/static/jobtracker.js\"></script>\n</head>\n<body>\n\n"); |
---|
| 103 | JSPUtil.processButtons(request, response, tracker); |
---|
| 104 | out.write("\n\n<h1>"); |
---|
| 105 | out.print( trackerName ); |
---|
| 106 | out.write(" Hadoop Map/Reduce Administration</h1>\n\n<div id=\"quicklinks\">\n <a href=\"#quicklinks\" onclick=\"toggle('quicklinks-list'); return false;\">Quick Links</a>\n <ul id=\"quicklinks-list\">\n <li><a href=\"#scheduling_info\">Scheduling Info</a></li>\n <li><a href=\"#running_jobs\">Running Jobs</a></li>\n <li><a href=\"#completed_jobs\">Completed Jobs</a></li>\n <li><a href=\"#failed_jobs\">Failed Jobs</a></li>\n <li><a href=\"#local_logs\">Local Logs</a></li>\n </ul>\n</div>\n\n<b>State:</b> "); |
---|
| 107 | out.print( status.getJobTrackerState() ); |
---|
| 108 | out.write("<br>\n<b>Started:</b> "); |
---|
| 109 | out.print( new Date(tracker.getStartTime())); |
---|
| 110 | out.write("<br>\n<b>Version:</b> "); |
---|
| 111 | out.print( VersionInfo.getVersion()); |
---|
| 112 | out.write(",\n r"); |
---|
| 113 | out.print( VersionInfo.getRevision()); |
---|
| 114 | out.write("<br>\n<b>Compiled:</b> "); |
---|
| 115 | out.print( VersionInfo.getDate()); |
---|
| 116 | out.write(" by \n "); |
---|
| 117 | out.print( VersionInfo.getUser()); |
---|
| 118 | out.write("<br>\n<b>Identifier:</b> "); |
---|
| 119 | out.print( tracker.getTrackerIdentifier()); |
---|
| 120 | out.write("<br> \n \n<hr>\n<h2>Cluster Summary (Heap Size is "); |
---|
| 121 | out.print( StringUtils.byteDesc(status.getUsedMemory()) ); |
---|
| 122 | out.write('/'); |
---|
| 123 | out.print( StringUtils.byteDesc(status.getMaxMemory()) ); |
---|
| 124 | out.write(")</h2>\n"); |
---|
| 125 | |
---|
| 126 | generateSummaryTable(out, status, tracker); |
---|
| 127 | |
---|
| 128 | out.write("\n<hr>\n<h2 id=\"scheduling_info\">Scheduling Information</h2>\n<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n<thead style=\"font-weight: bold\">\n<tr>\n<td> Queue Name </td>\n<td> Scheduling Information</td>\n</tr>\n</thead>\n<tbody>\n"); |
---|
| 129 | |
---|
| 130 | for(JobQueueInfo queue: queues) { |
---|
| 131 | String queueName = queue.getQueueName(); |
---|
| 132 | String schedulingInformation = queue.getSchedulingInfo(); |
---|
| 133 | if(schedulingInformation == null || schedulingInformation.trim().equals("")) { |
---|
| 134 | schedulingInformation = "NA"; |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | out.write("\n<tr>\n<td><a href=\"jobqueue_details.jsp?queueName="); |
---|
| 138 | out.print(queueName); |
---|
| 139 | out.write('"'); |
---|
| 140 | out.write('>'); |
---|
| 141 | out.print(queueName); |
---|
| 142 | out.write("</a></td>\n<td>"); |
---|
| 143 | out.print(schedulingInformation.replaceAll("\n","<br/>") ); |
---|
| 144 | out.write("\n</td>\n</tr>\n"); |
---|
| 145 | |
---|
| 146 | } |
---|
| 147 | |
---|
| 148 | out.write("\n</tbody>\n</table>\n<hr/>\n<b>Filter (Jobid, Priority, User, Name)</b> <input type=\"text\" id=\"filter\" onkeyup=\"applyfilter()\"> <br>\n<span class=\"small\">Example: 'user:smith 3200' will filter by 'smith' only in the user field and '3200' in all fields</span>\n<hr>\n\n<h2 id=\"running_jobs\">Running Jobs</h2>\n"); |
---|
| 149 | out.print(JSPUtil.generateJobTable("Running", runningJobs, 30, 0)); |
---|
| 150 | out.write("\n<hr>\n\n<h2 id=\"completed_jobs\">Completed Jobs</h2>\n"); |
---|
| 151 | out.print(JSPUtil.generateJobTable("Completed", completedJobs, 0, runningJobs.size())); |
---|
| 152 | out.write("\n<hr>\n\n<h2 id=\"failed_jobs\">Failed Jobs</h2>\n"); |
---|
| 153 | out.print(JSPUtil.generateJobTable("Failed", failedJobs, 0, |
---|
| 154 | (runningJobs.size()+completedJobs.size()))); |
---|
| 155 | out.write("\n<hr>\n\n<h2 id=\"local_logs\">Local Logs</h2>\n<a href=\"logs/\">Log</a> directory, <a href=\"jobhistory.jsp\">\nJob Tracker History</a>\n\n"); |
---|
| 156 | |
---|
| 157 | out.println(ServletUtil.htmlFooter()); |
---|
| 158 | |
---|
| 159 | out.write('\n'); |
---|
| 160 | } catch (Throwable t) { |
---|
| 161 | if (!(t instanceof SkipPageException)){ |
---|
| 162 | out = _jspx_out; |
---|
| 163 | if (out != null && out.getBufferSize() != 0) |
---|
| 164 | out.clearBuffer(); |
---|
| 165 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
| 166 | } |
---|
| 167 | } finally { |
---|
| 168 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | } |
---|