1 | <%@ page |
---|
2 | contentType="text/html; charset=UTF-8" |
---|
3 | import="javax.servlet.*" |
---|
4 | import="javax.servlet.http.*" |
---|
5 | import="java.io.*" |
---|
6 | import="java.util.*" |
---|
7 | import="org.apache.hadoop.mapred.*" |
---|
8 | import="org.apache.hadoop.util.*" |
---|
9 | %> |
---|
10 | |
---|
11 | <% |
---|
12 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
13 | String trackerName = |
---|
14 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
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 | |
---|
143 | <% |
---|
144 | String jobId = request.getParameter("jobid"); |
---|
145 | if (jobId == null) { |
---|
146 | out.println("<h2>Missing 'jobid'!</h2>"); |
---|
147 | return; |
---|
148 | } |
---|
149 | JobID jobIdObj = JobID.forName(jobId); |
---|
150 | String kind = request.getParameter("kind"); |
---|
151 | String cause = request.getParameter("cause"); |
---|
152 | %> |
---|
153 | |
---|
154 | <html> |
---|
155 | <title>Hadoop <%=jobId%> failures on <%=trackerName%></title> |
---|
156 | <body> |
---|
157 | <h1>Hadoop <a href="jobdetails.jsp?jobid=<%=jobId%>"><%=jobId%></a> |
---|
158 | failures on <a href="jobtracker.jsp"><%=trackerName%></a></h1> |
---|
159 | |
---|
160 | <% |
---|
161 | printFailures(out, tracker, jobIdObj, kind, cause); |
---|
162 | %> |
---|
163 | |
---|
164 | <hr> |
---|
165 | <a href="jobtracker.jsp">Go back to JobTracker</a><br> |
---|
166 | <% |
---|
167 | out.println(ServletUtil.htmlFooter()); |
---|
168 | %> |
---|