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 | |
---|
13 | public final class jobfailures_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
14 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
15 | |
---|
16 | |
---|
17 | private void printFailedAttempts(JspWriter out, |
---|
18 | JobTracker tracker, |
---|
19 | JobID jobId, |
---|
20 | TaskInProgress tip, |
---|
21 | TaskStatus.State failState) throws IOException { |
---|
22 | TaskStatus[] statuses = tip.getTaskStatuses(); |
---|
23 | TaskID tipId = tip.getTIPId(); |
---|
24 | for(int i=0; i < statuses.length; ++i) { |
---|
25 | TaskStatus.State taskState = statuses[i].getRunState(); |
---|
26 | if ((failState == null && (taskState == TaskStatus.State.FAILED || |
---|
27 | taskState == TaskStatus.State.KILLED)) || taskState == failState) { |
---|
28 | String taskTrackerName = statuses[i].getTaskTracker(); |
---|
29 | TaskTrackerStatus taskTracker = tracker.getTaskTracker(taskTrackerName); |
---|
30 | out.print("<tr><td>" + statuses[i].getTaskID() + |
---|
31 | "</td><td><a href=\"taskdetails.jsp?jobid="+ jobId + |
---|
32 | "&tipid=" + tipId + "\">" + tipId + |
---|
33 | "</a></td>"); |
---|
34 | if (taskTracker == null) { |
---|
35 | out.print("<td>" + taskTrackerName + "</td>"); |
---|
36 | } else { |
---|
37 | out.print("<td><a href=\"http://" + taskTracker.getHost() + ":" + |
---|
38 | taskTracker.getHttpPort() + "\">" + taskTracker.getHost() + |
---|
39 | "</a></td>"); |
---|
40 | } |
---|
41 | out.print("<td>" + taskState + "</td>"); |
---|
42 | out.print("<td><pre>"); |
---|
43 | String[] failures = |
---|
44 | tracker.getTaskDiagnostics(statuses[i].getTaskID()); |
---|
45 | if (failures == null) { |
---|
46 | out.print(" "); |
---|
47 | } else { |
---|
48 | for(int j = 0 ; j < failures.length ; j++){ |
---|
49 | out.print(failures[j]); |
---|
50 | if (j < (failures.length - 1)) { |
---|
51 | out.print("\n-------\n"); |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | out.print("</pre></td>"); |
---|
56 | |
---|
57 | out.print("<td>"); |
---|
58 | String taskLogUrl = null; |
---|
59 | if (taskTracker != null) { |
---|
60 | taskLogUrl = TaskLogServlet.getTaskLogUrl(taskTracker.getHost(), |
---|
61 | String.valueOf(taskTracker.getHttpPort()), |
---|
62 | statuses[i].getTaskID().toString()); |
---|
63 | } |
---|
64 | if (taskLogUrl != null) { |
---|
65 | String tailFourKBUrl = taskLogUrl + "&start=-4097"; |
---|
66 | String tailEightKBUrl = taskLogUrl + "&start=-8193"; |
---|
67 | String entireLogUrl = taskLogUrl; |
---|
68 | out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>"); |
---|
69 | out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>"); |
---|
70 | out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>"); |
---|
71 | } else { |
---|
72 | out.print("n/a"); // task tracker was lost |
---|
73 | } |
---|
74 | out.print("</td>"); |
---|
75 | |
---|
76 | out.print("</tr>\n"); |
---|
77 | } |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | private void printFailures(JspWriter out, |
---|
82 | JobTracker tracker, |
---|
83 | JobID jobId, |
---|
84 | String kind, |
---|
85 | String cause) throws IOException { |
---|
86 | JobInProgress job = (JobInProgress) tracker.getJob(jobId); |
---|
87 | if (job == null) { |
---|
88 | out.print("<b>Job " + jobId + " not found.</b><br>\n"); |
---|
89 | return; |
---|
90 | } |
---|
91 | |
---|
92 | boolean includeMap = false; |
---|
93 | boolean includeReduce = false; |
---|
94 | if (kind == null) { |
---|
95 | includeMap = true; |
---|
96 | includeReduce = true; |
---|
97 | } else if ("map".equals(kind)) { |
---|
98 | includeMap = true; |
---|
99 | } else if ("reduce".equals(kind)) { |
---|
100 | includeReduce = true; |
---|
101 | } else if ("all".equals(kind)) { |
---|
102 | includeMap = true; |
---|
103 | includeReduce = true; |
---|
104 | } else { |
---|
105 | out.print("<b>Kind " + kind + " not supported.</b><br>\n"); |
---|
106 | return; |
---|
107 | } |
---|
108 | |
---|
109 | TaskStatus.State state = null; |
---|
110 | try { |
---|
111 | if (cause != null) { |
---|
112 | state = TaskStatus.State.valueOf(cause.toUpperCase()); |
---|
113 | if (state != TaskStatus.State.FAILED && state != TaskStatus.State.KILLED) { |
---|
114 | out.print("<b>Cause '" + cause + |
---|
115 | "' is not an 'unsuccessful' state.</b><br>\n"); |
---|
116 | return; |
---|
117 | } |
---|
118 | } |
---|
119 | } catch (IllegalArgumentException e) { |
---|
120 | out.print("<b>Cause '" + cause + "' not supported.</b><br>\n"); |
---|
121 | return; |
---|
122 | } |
---|
123 | |
---|
124 | out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">"); |
---|
125 | out.print("<tr><th>Attempt</th><th>Task</th><th>Machine</th><th>State</th>" + |
---|
126 | "<th>Error</th><th>Logs</th></tr>\n"); |
---|
127 | if (includeMap) { |
---|
128 | TaskInProgress[] tips = job.getMapTasks(); |
---|
129 | for(int i=0; i < tips.length; ++i) { |
---|
130 | printFailedAttempts(out, tracker, jobId, tips[i], state); |
---|
131 | } |
---|
132 | } |
---|
133 | if (includeReduce) { |
---|
134 | TaskInProgress[] tips = job.getReduceTasks(); |
---|
135 | for(int i=0; i < tips.length; ++i) { |
---|
136 | printFailedAttempts(out, tracker, jobId, tips[i], state); |
---|
137 | } |
---|
138 | } |
---|
139 | out.print("</table>\n"); |
---|
140 | } |
---|
141 | |
---|
142 | private static java.util.List _jspx_dependants; |
---|
143 | |
---|
144 | public Object getDependants() { |
---|
145 | return _jspx_dependants; |
---|
146 | } |
---|
147 | |
---|
148 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
149 | throws java.io.IOException, ServletException { |
---|
150 | |
---|
151 | JspFactory _jspxFactory = null; |
---|
152 | PageContext pageContext = null; |
---|
153 | HttpSession session = null; |
---|
154 | ServletContext application = null; |
---|
155 | ServletConfig config = null; |
---|
156 | JspWriter out = null; |
---|
157 | Object page = this; |
---|
158 | JspWriter _jspx_out = null; |
---|
159 | PageContext _jspx_page_context = null; |
---|
160 | |
---|
161 | |
---|
162 | try { |
---|
163 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
164 | response.setContentType("text/html; charset=UTF-8"); |
---|
165 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
166 | null, true, 8192, true); |
---|
167 | _jspx_page_context = pageContext; |
---|
168 | application = pageContext.getServletContext(); |
---|
169 | config = pageContext.getServletConfig(); |
---|
170 | session = pageContext.getSession(); |
---|
171 | out = pageContext.getOut(); |
---|
172 | _jspx_out = out; |
---|
173 | |
---|
174 | out.write('\n'); |
---|
175 | out.write('\n'); |
---|
176 | |
---|
177 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
178 | String trackerName = |
---|
179 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
180 | |
---|
181 | out.write('\n'); |
---|
182 | out.write('\n'); |
---|
183 | out.write('\n'); |
---|
184 | |
---|
185 | String jobId = request.getParameter("jobid"); |
---|
186 | if (jobId == null) { |
---|
187 | out.println("<h2>Missing 'jobid'!</h2>"); |
---|
188 | return; |
---|
189 | } |
---|
190 | JobID jobIdObj = JobID.forName(jobId); |
---|
191 | String kind = request.getParameter("kind"); |
---|
192 | String cause = request.getParameter("cause"); |
---|
193 | |
---|
194 | out.write("\n\n<html>\n<title>Hadoop "); |
---|
195 | out.print(jobId); |
---|
196 | out.write(" failures on "); |
---|
197 | out.print(trackerName); |
---|
198 | out.write("</title>\n<body>\n<h1>Hadoop <a href=\"jobdetails.jsp?jobid="); |
---|
199 | out.print(jobId); |
---|
200 | out.write('"'); |
---|
201 | out.write('>'); |
---|
202 | out.print(jobId); |
---|
203 | out.write("</a>\nfailures on <a href=\"jobtracker.jsp\">"); |
---|
204 | out.print(trackerName); |
---|
205 | out.write("</a></h1>\n\n"); |
---|
206 | |
---|
207 | printFailures(out, tracker, jobIdObj, kind, cause); |
---|
208 | |
---|
209 | out.write("\n\n<hr>\n<a href=\"jobtracker.jsp\">Go back to JobTracker</a><br>\n"); |
---|
210 | |
---|
211 | out.println(ServletUtil.htmlFooter()); |
---|
212 | |
---|
213 | out.write('\n'); |
---|
214 | } catch (Throwable t) { |
---|
215 | if (!(t instanceof SkipPageException)){ |
---|
216 | out = _jspx_out; |
---|
217 | if (out != null && out.getBufferSize() != 0) |
---|
218 | out.clearBuffer(); |
---|
219 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
220 | } |
---|
221 | } finally { |
---|
222 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
223 | } |
---|
224 | } |
---|
225 | } |
---|