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.text.*" |
---|
7 | import="java.util.*" |
---|
8 | import="java.text.DecimalFormat" |
---|
9 | import="org.apache.hadoop.mapred.*" |
---|
10 | import="org.apache.hadoop.util.*" |
---|
11 | %> |
---|
12 | |
---|
13 | <% |
---|
14 | JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); |
---|
15 | String trackerName = |
---|
16 | StringUtils.simpleHostname(tracker.getJobTrackerMachine()); |
---|
17 | %> |
---|
18 | <%! |
---|
19 | private static final String PRIVATE_ACTIONS_KEY |
---|
20 | = "webinterface.private.actions"; |
---|
21 | |
---|
22 | private void printTaskSummary(JspWriter out, |
---|
23 | String jobId, |
---|
24 | String kind, |
---|
25 | double completePercent, |
---|
26 | TaskInProgress[] tasks |
---|
27 | ) throws IOException { |
---|
28 | int totalTasks = tasks.length; |
---|
29 | int runningTasks = 0; |
---|
30 | int finishedTasks = 0; |
---|
31 | int killedTasks = 0; |
---|
32 | int failedTaskAttempts = 0; |
---|
33 | int killedTaskAttempts = 0; |
---|
34 | for(int i=0; i < totalTasks; ++i) { |
---|
35 | TaskInProgress task = tasks[i]; |
---|
36 | if (task.isComplete()) { |
---|
37 | finishedTasks += 1; |
---|
38 | } else if (task.isRunning()) { |
---|
39 | runningTasks += 1; |
---|
40 | } else if (task.wasKilled()) { |
---|
41 | killedTasks += 1; |
---|
42 | } |
---|
43 | failedTaskAttempts += task.numTaskFailures(); |
---|
44 | killedTaskAttempts += task.numKilledTasks(); |
---|
45 | } |
---|
46 | int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; |
---|
47 | out.print("<tr><th><a href=\"jobtasks.jsp?jobid=" + jobId + |
---|
48 | "&type="+ kind + "&pagenum=1\">" + kind + |
---|
49 | "</a></th><td align=\"right\">" + |
---|
50 | StringUtils.formatPercent(completePercent, 2) + |
---|
51 | ServletUtil.percentageGraph((int)(completePercent * 100), 80) + |
---|
52 | "</td><td align=\"right\">" + |
---|
53 | totalTasks + |
---|
54 | "</td><td align=\"right\">" + |
---|
55 | ((pendingTasks > 0) |
---|
56 | ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
57 | "&pagenum=1" + "&state=pending\">" + pendingTasks + "</a>" |
---|
58 | : "0") + |
---|
59 | "</td><td align=\"right\">" + |
---|
60 | ((runningTasks > 0) |
---|
61 | ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
62 | "&pagenum=1" + "&state=running\">" + runningTasks + "</a>" |
---|
63 | : "0") + |
---|
64 | "</td><td align=\"right\">" + |
---|
65 | ((finishedTasks > 0) |
---|
66 | ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
67 | "&pagenum=1" + "&state=completed\">" + finishedTasks + "</a>" |
---|
68 | : "0") + |
---|
69 | "</td><td align=\"right\">" + |
---|
70 | ((killedTasks > 0) |
---|
71 | ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
72 | "&pagenum=1" + "&state=killed\">" + killedTasks + "</a>" |
---|
73 | : "0") + |
---|
74 | "</td><td align=\"right\">" + |
---|
75 | ((failedTaskAttempts > 0) ? |
---|
76 | ("<a href=\"jobfailures.jsp?jobid=" + jobId + |
---|
77 | "&kind=" + kind + "&cause=failed\">" + failedTaskAttempts + |
---|
78 | "</a>") : |
---|
79 | "0" |
---|
80 | ) + |
---|
81 | " / " + |
---|
82 | ((killedTaskAttempts > 0) ? |
---|
83 | ("<a href=\"jobfailures.jsp?jobid=" + jobId + |
---|
84 | "&kind=" + kind + "&cause=killed\">" + killedTaskAttempts + |
---|
85 | "</a>") : |
---|
86 | "0" |
---|
87 | ) + |
---|
88 | "</td></tr>\n"); |
---|
89 | } |
---|
90 | |
---|
91 | private void printJobLevelTaskSummary(JspWriter out, |
---|
92 | String jobId, |
---|
93 | String kind, |
---|
94 | TaskInProgress[] tasks |
---|
95 | ) throws IOException { |
---|
96 | int totalTasks = tasks.length; |
---|
97 | int runningTasks = 0; |
---|
98 | int finishedTasks = 0; |
---|
99 | int killedTasks = 0; |
---|
100 | for(int i=0; i < totalTasks; ++i) { |
---|
101 | TaskInProgress task = tasks[i]; |
---|
102 | if (task.isComplete()) { |
---|
103 | finishedTasks += 1; |
---|
104 | } else if (task.isRunning()) { |
---|
105 | runningTasks += 1; |
---|
106 | } else if (task.isFailed()) { |
---|
107 | killedTasks += 1; |
---|
108 | } |
---|
109 | } |
---|
110 | int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; |
---|
111 | out.print(((runningTasks > 0) |
---|
112 | ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
113 | "&pagenum=1" + "&state=running\">" + " Running" + |
---|
114 | "</a>" |
---|
115 | : ((pendingTasks > 0) ? " Pending" : |
---|
116 | ((finishedTasks > 0) |
---|
117 | ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
118 | "&pagenum=1" + "&state=completed\">" + " Successful" |
---|
119 | + "</a>" |
---|
120 | : ((killedTasks > 0) |
---|
121 | ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + |
---|
122 | "&pagenum=1" + "&state=killed\">" + " Failed" |
---|
123 | + "</a>" : "None"))))); |
---|
124 | } |
---|
125 | |
---|
126 | private void printConfirm(JspWriter out, String jobId) throws IOException{ |
---|
127 | String url = "jobdetails.jsp?jobid=" + jobId; |
---|
128 | out.print("<html><head><META http-equiv=\"refresh\" content=\"15;URL=" |
---|
129 | + url+"\"></head>" |
---|
130 | + "<body><h3> Are you sure you want to kill " + jobId |
---|
131 | + " ?<h3><br><table border=\"0\"><tr><td width=\"100\">" |
---|
132 | + "<form action=\"" + url + "\" method=\"post\">" |
---|
133 | + "<input type=\"hidden\" name=\"action\" value=\"kill\" />" |
---|
134 | + "<input type=\"submit\" name=\"kill\" value=\"Kill\" />" |
---|
135 | + "</form>" |
---|
136 | + "</td><td width=\"100\"><form method=\"post\" action=\"" + url |
---|
137 | + "\"><input type=\"submit\" value=\"Cancel\" name=\"Cancel\"" |
---|
138 | + "/></form></td></tr></table></body></html>"); |
---|
139 | } |
---|
140 | |
---|
141 | %> |
---|
142 | <% |
---|
143 | String jobId = request.getParameter("jobid"); |
---|
144 | String refreshParam = request.getParameter("refresh"); |
---|
145 | if (jobId == null) { |
---|
146 | out.println("<h2>Missing 'jobid'!</h2>"); |
---|
147 | return; |
---|
148 | } |
---|
149 | |
---|
150 | int refresh = 60; // refresh every 60 seconds by default |
---|
151 | if (refreshParam != null) { |
---|
152 | try { |
---|
153 | refresh = Integer.parseInt(refreshParam); |
---|
154 | } |
---|
155 | catch (NumberFormatException ignored) { |
---|
156 | } |
---|
157 | } |
---|
158 | JobID jobIdObj = JobID.forName(jobId); |
---|
159 | JobInProgress job = (JobInProgress) tracker.getJob(jobIdObj); |
---|
160 | |
---|
161 | String action = request.getParameter("action"); |
---|
162 | if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) && |
---|
163 | "changeprio".equalsIgnoreCase(action) |
---|
164 | && request.getMethod().equalsIgnoreCase("POST")) { |
---|
165 | tracker.setJobPriority(jobIdObj, |
---|
166 | JobPriority.valueOf(request.getParameter("prio"))); |
---|
167 | } |
---|
168 | |
---|
169 | if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { |
---|
170 | action = request.getParameter("action"); |
---|
171 | if(action!=null && action.equalsIgnoreCase("confirm")) { |
---|
172 | printConfirm(out, jobId); |
---|
173 | return; |
---|
174 | } |
---|
175 | else if(action != null && action.equalsIgnoreCase("kill") && |
---|
176 | request.getMethod().equalsIgnoreCase("POST")) { |
---|
177 | tracker.killJob(jobIdObj); |
---|
178 | } |
---|
179 | } |
---|
180 | %> |
---|
181 | |
---|
182 | <%@page import="org.apache.hadoop.mapred.TaskGraphServlet"%> |
---|
183 | <html> |
---|
184 | <head> |
---|
185 | <% |
---|
186 | if (refresh != 0) { |
---|
187 | %> |
---|
188 | <meta http-equiv="refresh" content="<%=refresh%>"> |
---|
189 | <% |
---|
190 | } |
---|
191 | %> |
---|
192 | <title>Hadoop <%=jobId%> on <%=trackerName%></title> |
---|
193 | <link rel="stylesheet" type="text/css" href="/static/hadoop.css"> |
---|
194 | </head> |
---|
195 | <body> |
---|
196 | <h1>Hadoop <%=jobId%> on <a href="jobtracker.jsp"><%=trackerName%></a></h1> |
---|
197 | |
---|
198 | <% |
---|
199 | if (job == null) { |
---|
200 | out.print("<b>Job " + jobId + " not found.</b><br>\n"); |
---|
201 | return; |
---|
202 | } |
---|
203 | JobProfile profile = job.getProfile(); |
---|
204 | JobStatus status = job.getStatus(); |
---|
205 | int runState = status.getRunState(); |
---|
206 | int flakyTaskTrackers = job.getNoOfBlackListedTrackers(); |
---|
207 | out.print("<b>User:</b> " + profile.getUser() + "<br>\n"); |
---|
208 | out.print("<b>Job Name:</b> " + profile.getJobName() + "<br>\n"); |
---|
209 | out.print("<b>Job File:</b> <a href=\"jobconf.jsp?jobid=" + jobId + "\">" |
---|
210 | + profile.getJobFile() + "</a><br>\n"); |
---|
211 | out.print("<b>Job Setup:</b>"); |
---|
212 | printJobLevelTaskSummary(out, jobId, "setup", job.getSetupTasks()); |
---|
213 | out.print("<br>\n"); |
---|
214 | if (runState == JobStatus.RUNNING) { |
---|
215 | out.print("<b>Status:</b> Running<br>\n"); |
---|
216 | out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n"); |
---|
217 | out.print("<b>Running for:</b> " + StringUtils.formatTimeDiff( |
---|
218 | System.currentTimeMillis(), job.getStartTime()) + "<br>\n"); |
---|
219 | } else { |
---|
220 | if (runState == JobStatus.SUCCEEDED) { |
---|
221 | out.print("<b>Status:</b> Succeeded<br>\n"); |
---|
222 | out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n"); |
---|
223 | out.print("<b>Finished at:</b> " + new Date(job.getFinishTime()) + |
---|
224 | "<br>\n"); |
---|
225 | out.print("<b>Finished in:</b> " + StringUtils.formatTimeDiff( |
---|
226 | job.getFinishTime(), job.getStartTime()) + "<br>\n"); |
---|
227 | } else if (runState == JobStatus.FAILED) { |
---|
228 | out.print("<b>Status:</b> Failed<br>\n"); |
---|
229 | out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n"); |
---|
230 | out.print("<b>Failed at:</b> " + new Date(job.getFinishTime()) + |
---|
231 | "<br>\n"); |
---|
232 | out.print("<b>Failed in:</b> " + StringUtils.formatTimeDiff( |
---|
233 | job.getFinishTime(), job.getStartTime()) + "<br>\n"); |
---|
234 | } else if (runState == JobStatus.KILLED) { |
---|
235 | out.print("<b>Status:</b> Killed<br>\n"); |
---|
236 | out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n"); |
---|
237 | out.print("<b>Killed at:</b> " + new Date(job.getFinishTime()) + |
---|
238 | "<br>\n"); |
---|
239 | out.print("<b>Killed in:</b> " + StringUtils.formatTimeDiff( |
---|
240 | job.getFinishTime(), job.getStartTime()) + "<br>\n"); |
---|
241 | } |
---|
242 | } |
---|
243 | out.print("<b>Job Cleanup:</b>"); |
---|
244 | printJobLevelTaskSummary(out, jobId, "cleanup", job.getCleanupTasks()); |
---|
245 | out.print("<br>\n"); |
---|
246 | if (flakyTaskTrackers > 0) { |
---|
247 | out.print("<b>Black-listed TaskTrackers:</b> " + |
---|
248 | "<a href=\"jobblacklistedtrackers.jsp?jobid=" + jobId + "\">" + |
---|
249 | flakyTaskTrackers + "</a><br>\n"); |
---|
250 | } |
---|
251 | if (job.getSchedulingInfo() != null) { |
---|
252 | out.print("<b>Job Scheduling information: </b>" + |
---|
253 | job.getSchedulingInfo().toString() +"\n"); |
---|
254 | } |
---|
255 | out.print("<hr>\n"); |
---|
256 | out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">"); |
---|
257 | out.print("<tr><th>Kind</th><th>% Complete</th><th>Num Tasks</th>" + |
---|
258 | "<th>Pending</th><th>Running</th><th>Complete</th>" + |
---|
259 | "<th>Killed</th>" + |
---|
260 | "<th><a href=\"jobfailures.jsp?jobid=" + jobId + |
---|
261 | "\">Failed/Killed<br>Task Attempts</a></th></tr>\n"); |
---|
262 | printTaskSummary(out, jobId, "map", status.mapProgress(), |
---|
263 | job.getMapTasks()); |
---|
264 | printTaskSummary(out, jobId, "reduce", status.reduceProgress(), |
---|
265 | job.getReduceTasks()); |
---|
266 | out.print("</table>\n"); |
---|
267 | |
---|
268 | %> |
---|
269 | <p/> |
---|
270 | <table border=2 cellpadding="5" cellspacing="2"> |
---|
271 | <tr> |
---|
272 | <th><br/></th> |
---|
273 | <th>Counter</th> |
---|
274 | <th>Map</th> |
---|
275 | <th>Reduce</th> |
---|
276 | <th>Total</th> |
---|
277 | </tr> |
---|
278 | <% |
---|
279 | Counters mapCounters = job.getMapCounters(); |
---|
280 | Counters reduceCounters = job.getReduceCounters(); |
---|
281 | Counters totalCounters = job.getCounters(); |
---|
282 | |
---|
283 | for (String groupName : totalCounters.getGroupNames()) { |
---|
284 | Counters.Group totalGroup = totalCounters.getGroup(groupName); |
---|
285 | Counters.Group mapGroup = mapCounters.getGroup(groupName); |
---|
286 | Counters.Group reduceGroup = reduceCounters.getGroup(groupName); |
---|
287 | |
---|
288 | Format decimal = new DecimalFormat(); |
---|
289 | |
---|
290 | boolean isFirst = true; |
---|
291 | for (Counters.Counter counter : totalGroup) { |
---|
292 | String name = counter.getDisplayName(); |
---|
293 | String mapValue = decimal.format(mapGroup.getCounter(name)); |
---|
294 | String reduceValue = decimal.format(reduceGroup.getCounter(name)); |
---|
295 | String totalValue = decimal.format(counter.getCounter()); |
---|
296 | %> |
---|
297 | <tr> |
---|
298 | <% |
---|
299 | if (isFirst) { |
---|
300 | isFirst = false; |
---|
301 | %> |
---|
302 | <td rowspan="<%=totalGroup.size()%>"><%=totalGroup.getDisplayName()%></td> |
---|
303 | <% |
---|
304 | } |
---|
305 | %> |
---|
306 | <td><%=name%></td> |
---|
307 | <td align="right"><%=mapValue%></td> |
---|
308 | <td align="right"><%=reduceValue%></td> |
---|
309 | <td align="right"><%=totalValue%></td> |
---|
310 | </tr> |
---|
311 | <% |
---|
312 | } |
---|
313 | } |
---|
314 | %> |
---|
315 | </table> |
---|
316 | |
---|
317 | <hr>Map Completion Graph - |
---|
318 | <% |
---|
319 | if("off".equals(request.getParameter("map.graph"))) { |
---|
320 | session.setAttribute("map.graph", "off"); |
---|
321 | } else if("on".equals(request.getParameter("map.graph"))){ |
---|
322 | session.setAttribute("map.graph", "on"); |
---|
323 | } |
---|
324 | if("off".equals(request.getParameter("reduce.graph"))) { |
---|
325 | session.setAttribute("reduce.graph", "off"); |
---|
326 | } else if("on".equals(request.getParameter("reduce.graph"))){ |
---|
327 | session.setAttribute("reduce.graph", "on"); |
---|
328 | } |
---|
329 | |
---|
330 | if("off".equals(session.getAttribute("map.graph"))) { %> |
---|
331 | <a href="/jobdetails.jsp?jobid=<%=jobId%>&refresh=<%=refresh%>&map.graph=on" > open </a> |
---|
332 | <%} else { %> |
---|
333 | <a href="/jobdetails.jsp?jobid=<%=jobId%>&refresh=<%=refresh%>&map.graph=off" > close </a> |
---|
334 | <br><embed src="/taskgraph?type=map&jobid=<%=jobId%>" |
---|
335 | width="<%=TaskGraphServlet.width + 2 * TaskGraphServlet.xmargin%>" |
---|
336 | height="<%=TaskGraphServlet.height + 3 * TaskGraphServlet.ymargin%>" |
---|
337 | style="width:100%" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" /> |
---|
338 | <%}%> |
---|
339 | |
---|
340 | <%if(job.getReduceTasks().length > 0) { %> |
---|
341 | <hr>Reduce Completion Graph - |
---|
342 | <%if("off".equals(session.getAttribute("reduce.graph"))) { %> |
---|
343 | <a href="/jobdetails.jsp?jobid=<%=jobId%>&refresh=<%=refresh%>&reduce.graph=on" > open </a> |
---|
344 | <%} else { %> |
---|
345 | <a href="/jobdetails.jsp?jobid=<%=jobId%>&refresh=<%=refresh%>&reduce.graph=off" > close </a> |
---|
346 | |
---|
347 | <br><embed src="/taskgraph?type=reduce&jobid=<%=jobId%>" |
---|
348 | width="<%=TaskGraphServlet.width + 2 * TaskGraphServlet.xmargin%>" |
---|
349 | height="<%=TaskGraphServlet.height + 3 * TaskGraphServlet.ymargin%>" |
---|
350 | style="width:100%" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" /> |
---|
351 | <%} }%> |
---|
352 | |
---|
353 | <hr> |
---|
354 | <% if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { %> |
---|
355 | <table border="0"> <tr> <td> |
---|
356 | Change priority from <%=job.getPriority()%> to: |
---|
357 | <form action="jobdetails.jsp" method="post"> |
---|
358 | <input type="hidden" name="action" value="changeprio"/> |
---|
359 | <input type="hidden" name="jobid" value="<%=jobId%>"/> |
---|
360 | </td><td> <select name="prio"> |
---|
361 | <% |
---|
362 | JobPriority jobPrio = job.getPriority(); |
---|
363 | for (JobPriority prio : JobPriority.values()) { |
---|
364 | if(jobPrio != prio) { |
---|
365 | %> <option value=<%=prio%>><%=prio%></option> <% |
---|
366 | } |
---|
367 | } |
---|
368 | %> |
---|
369 | </select> </td><td><input type="submit" value="Submit"> </form></td></tr> </table> |
---|
370 | <% } %> |
---|
371 | |
---|
372 | <table border="0"> <tr> |
---|
373 | |
---|
374 | <% if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) |
---|
375 | && runState == JobStatus.RUNNING) { %> |
---|
376 | <br/><a href="jobdetails.jsp?action=confirm&jobid=<%=jobId%>"> Kill this job </a> |
---|
377 | <% } %> |
---|
378 | |
---|
379 | <hr> |
---|
380 | |
---|
381 | <hr> |
---|
382 | <a href="jobtracker.jsp">Go back to JobTracker</a><br> |
---|
383 | <% |
---|
384 | out.println(ServletUtil.htmlFooter()); |
---|
385 | %> |
---|