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.http.*; |
---|
7 | import java.io.*; |
---|
8 | import java.util.*; |
---|
9 | import org.apache.hadoop.mapred.*; |
---|
10 | import org.apache.hadoop.util.*; |
---|
11 | import java.text.SimpleDateFormat; |
---|
12 | import org.apache.hadoop.mapred.JobHistory.*; |
---|
13 | |
---|
14 | public final class analysejobhistory_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
15 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
16 | |
---|
17 | private static SimpleDateFormat dateFormat |
---|
18 | = new SimpleDateFormat("d/MM HH:mm:ss") ; |
---|
19 | |
---|
20 | private static java.util.List _jspx_dependants; |
---|
21 | |
---|
22 | public Object getDependants() { |
---|
23 | return _jspx_dependants; |
---|
24 | } |
---|
25 | |
---|
26 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
27 | throws java.io.IOException, ServletException { |
---|
28 | |
---|
29 | JspFactory _jspxFactory = null; |
---|
30 | PageContext pageContext = null; |
---|
31 | HttpSession session = null; |
---|
32 | ServletContext application = null; |
---|
33 | ServletConfig config = null; |
---|
34 | JspWriter out = null; |
---|
35 | Object page = this; |
---|
36 | JspWriter _jspx_out = null; |
---|
37 | PageContext _jspx_page_context = null; |
---|
38 | |
---|
39 | |
---|
40 | try { |
---|
41 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
42 | response.setContentType("text/html; charset=UTF-8"); |
---|
43 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
44 | null, true, 8192, true); |
---|
45 | _jspx_page_context = pageContext; |
---|
46 | application = pageContext.getServletContext(); |
---|
47 | config = pageContext.getServletConfig(); |
---|
48 | session = pageContext.getSession(); |
---|
49 | out = pageContext.getOut(); |
---|
50 | _jspx_out = out; |
---|
51 | |
---|
52 | out.write('\n'); |
---|
53 | org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "loadhistory.jsp" + (("loadhistory.jsp").indexOf('?')>0? '&': '?') + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("jobid", request.getCharacterEncoding())+ "=" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(String.valueOf(request.getParameter("jobid") ), request.getCharacterEncoding()) + "&" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("logFile", request.getCharacterEncoding())+ "=" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode(String.valueOf(request.getParameter("logFile") ), request.getCharacterEncoding()), out, false); |
---|
54 | out.write('\n'); |
---|
55 | out.write("\n<html><body>\n"); |
---|
56 | |
---|
57 | String jobid = request.getParameter("jobid"); |
---|
58 | String logFile = request.getParameter("logFile"); |
---|
59 | String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile); |
---|
60 | String numTasks = request.getParameter("numTasks"); |
---|
61 | int showTasks = 10 ; |
---|
62 | if (numTasks != null) { |
---|
63 | showTasks = Integer.parseInt(numTasks); |
---|
64 | } |
---|
65 | JobInfo job = (JobInfo)request.getSession().getAttribute("job"); |
---|
66 | |
---|
67 | out.write("\n<h2>Hadoop Job <a href=\"jobdetailshistory.jsp?jobid="); |
---|
68 | out.print(jobid); |
---|
69 | out.write("&&logFile="); |
---|
70 | out.print(encodedLogFileName); |
---|
71 | out.write('"'); |
---|
72 | out.write('>'); |
---|
73 | out.print(jobid ); |
---|
74 | out.write(" </a></h2>\n<b>User : </b> "); |
---|
75 | out.print(job.get(Keys.USER) ); |
---|
76 | out.write("<br/> \n<b>JobName : </b> "); |
---|
77 | out.print(job.get(Keys.JOBNAME) ); |
---|
78 | out.write("<br/> \n<b>JobConf : </b> "); |
---|
79 | out.print(job.get(Keys.JOBCONF) ); |
---|
80 | out.write("<br/> \n<b>Submitted At : </b> "); |
---|
81 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.SUBMIT_TIME), 0 ) ); |
---|
82 | out.write("<br/> \n<b>Launched At : </b> "); |
---|
83 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.LAUNCH_TIME), job.getLong(Keys.SUBMIT_TIME)) ); |
---|
84 | out.write("<br/>\n<b>Finished At : </b> "); |
---|
85 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.FINISH_TIME), job.getLong(Keys.LAUNCH_TIME)) ); |
---|
86 | out.write("<br/>\n<b>Status : </b> "); |
---|
87 | out.print( ((job.get(Keys.JOB_STATUS) == null)?"Incomplete" :job.get(Keys.JOB_STATUS)) ); |
---|
88 | out.write("<br/> \n<hr/>\n<center>\n"); |
---|
89 | |
---|
90 | if (!Values.SUCCESS.name().equals(job.get(Keys.JOB_STATUS))) { |
---|
91 | out.print("<h3>No Analysis available as job did not finish</h3>"); |
---|
92 | return; |
---|
93 | } |
---|
94 | Map<String, JobHistory.Task> tasks = job.getAllTasks(); |
---|
95 | int finishedMaps = job.getInt(Keys.FINISHED_MAPS) ; |
---|
96 | int finishedReduces = job.getInt(Keys.FINISHED_REDUCES) ; |
---|
97 | JobHistory.Task [] mapTasks = new JobHistory.Task[finishedMaps]; |
---|
98 | JobHistory.Task [] reduceTasks = new JobHistory.Task[finishedReduces]; |
---|
99 | int mapIndex = 0 , reduceIndex=0; |
---|
100 | long avgMapTime = 0; |
---|
101 | long avgReduceTime = 0; |
---|
102 | long avgShuffleTime = 0; |
---|
103 | |
---|
104 | for (JobHistory.Task task : tasks.values()) { |
---|
105 | Map<String, TaskAttempt> attempts = task.getTaskAttempts(); |
---|
106 | for (JobHistory.TaskAttempt attempt : attempts.values()) { |
---|
107 | if (attempt.get(Keys.TASK_STATUS).equals(Values.SUCCESS.name())) { |
---|
108 | long avgFinishTime = (attempt.getLong(Keys.FINISH_TIME) - |
---|
109 | attempt.getLong(Keys.START_TIME)); |
---|
110 | if (Values.MAP.name().equals(task.get(Keys.TASK_TYPE))) { |
---|
111 | mapTasks[mapIndex++] = attempt ; |
---|
112 | avgMapTime += avgFinishTime; |
---|
113 | } else if (Values.REDUCE.name().equals(task.get(Keys.TASK_TYPE))) { |
---|
114 | reduceTasks[reduceIndex++] = attempt; |
---|
115 | avgShuffleTime += (attempt.getLong(Keys.SHUFFLE_FINISHED) - |
---|
116 | attempt.getLong(Keys.START_TIME)); |
---|
117 | avgReduceTime += (attempt.getLong(Keys.FINISH_TIME) - |
---|
118 | attempt.getLong(Keys.SHUFFLE_FINISHED)); |
---|
119 | } |
---|
120 | break; |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | if (finishedMaps > 0) { |
---|
126 | avgMapTime /= finishedMaps; |
---|
127 | } |
---|
128 | if (finishedReduces > 0) { |
---|
129 | avgReduceTime /= finishedReduces; |
---|
130 | avgShuffleTime /= finishedReduces; |
---|
131 | } |
---|
132 | Comparator<JobHistory.Task> cMap = new Comparator<JobHistory.Task>(){ |
---|
133 | public int compare(JobHistory.Task t1, JobHistory.Task t2){ |
---|
134 | long l1 = t1.getLong(Keys.FINISH_TIME) - t1.getLong(Keys.START_TIME); |
---|
135 | long l2 = t2.getLong(Keys.FINISH_TIME) - t2.getLong(Keys.START_TIME); |
---|
136 | return (l2<l1 ? -1 : (l2==l1 ? 0 : 1)); |
---|
137 | } |
---|
138 | }; |
---|
139 | Comparator<JobHistory.Task> cShuffle = new Comparator<JobHistory.Task>(){ |
---|
140 | public int compare(JobHistory.Task t1, JobHistory.Task t2){ |
---|
141 | long l1 = t1.getLong(Keys.SHUFFLE_FINISHED) - |
---|
142 | t1.getLong(Keys.START_TIME); |
---|
143 | long l2 = t2.getLong(Keys.SHUFFLE_FINISHED) - |
---|
144 | t2.getLong(Keys.START_TIME); |
---|
145 | return (l2<l1 ? -1 : (l2==l1 ? 0 : 1)); |
---|
146 | } |
---|
147 | }; |
---|
148 | Arrays.sort(mapTasks, cMap); |
---|
149 | JobHistory.Task minMap = mapTasks[mapTasks.length-1] ; |
---|
150 | |
---|
151 | out.write("\n\n<h3>Time taken by best performing Map task \n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
152 | out.print(jobid); |
---|
153 | out.write("&logFile="); |
---|
154 | out.print(encodedLogFileName); |
---|
155 | out.write("&taskid="); |
---|
156 | out.print(minMap.get(Keys.TASKID)); |
---|
157 | out.write('"'); |
---|
158 | out.write('>'); |
---|
159 | out.write('\n'); |
---|
160 | out.print(minMap.get(Keys.TASKID) ); |
---|
161 | out.write("</a> : "); |
---|
162 | out.print(StringUtils.formatTimeDiff(minMap.getLong(Keys.FINISH_TIME), minMap.getLong(Keys.START_TIME) ) ); |
---|
163 | out.write("</h3>\n<h3>Average time taken by Map tasks: \n"); |
---|
164 | out.print(StringUtils.formatTimeDiff(avgMapTime, 0) ); |
---|
165 | out.write("</h3>\n<h3>Worse performing map tasks</h3>\n<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n<tr><td>Task Id</td><td>Time taken</td></tr>\n"); |
---|
166 | |
---|
167 | for (int i=0;i<showTasks && i<mapTasks.length; i++) { |
---|
168 | |
---|
169 | out.write("\n <tr>\n <td><a href=\"taskdetailshistory.jsp?jobid="); |
---|
170 | out.print(jobid); |
---|
171 | out.write("&logFile="); |
---|
172 | out.print(encodedLogFileName); |
---|
173 | out.write("&taskid="); |
---|
174 | out.print(mapTasks[i].get(Keys.TASKID)); |
---|
175 | out.write("\">\n "); |
---|
176 | out.print(mapTasks[i].get(Keys.TASKID) ); |
---|
177 | out.write("</a></td>\n <td>"); |
---|
178 | out.print(StringUtils.formatTimeDiff(mapTasks[i].getLong(Keys.FINISH_TIME), mapTasks[i].getLong(Keys.START_TIME)) ); |
---|
179 | out.write("</td>\n </tr>\n"); |
---|
180 | |
---|
181 | } |
---|
182 | |
---|
183 | out.write("\n</table>\n"); |
---|
184 | |
---|
185 | Comparator<JobHistory.Task> cFinishMapRed = |
---|
186 | new Comparator<JobHistory.Task>() { |
---|
187 | public int compare(JobHistory.Task t1, JobHistory.Task t2){ |
---|
188 | long l1 = t1.getLong(Keys.FINISH_TIME); |
---|
189 | long l2 = t2.getLong(Keys.FINISH_TIME); |
---|
190 | return (l2<l1 ? -1 : (l2==l1 ? 0 : 1)); |
---|
191 | } |
---|
192 | }; |
---|
193 | Arrays.sort(mapTasks, cFinishMapRed); |
---|
194 | JobHistory.Task lastMap = mapTasks[0] ; |
---|
195 | |
---|
196 | out.write("\n\n<h3>The last Map task \n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
197 | out.print(jobid); |
---|
198 | out.write("&logFile="); |
---|
199 | out.print(encodedLogFileName); |
---|
200 | out.write("\n&taskid="); |
---|
201 | out.print(lastMap.get(Keys.TASKID)); |
---|
202 | out.write('"'); |
---|
203 | out.write('>'); |
---|
204 | out.print(lastMap.get(Keys.TASKID) ); |
---|
205 | out.write("</a> \nfinished at (relative to the Job launch time): \n"); |
---|
206 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, |
---|
207 | lastMap.getLong(Keys.FINISH_TIME), |
---|
208 | job.getLong(Keys.LAUNCH_TIME) ) ); |
---|
209 | out.write("</h3>\n<hr/>\n\n"); |
---|
210 | |
---|
211 | if (reduceTasks.length <= 0) return; |
---|
212 | Arrays.sort(reduceTasks, cShuffle); |
---|
213 | JobHistory.Task minShuffle = reduceTasks[reduceTasks.length-1] ; |
---|
214 | |
---|
215 | out.write("\n<h3>Time taken by best performing shuffle\n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
216 | out.print(jobid); |
---|
217 | out.write("&logFile="); |
---|
218 | out.print(encodedLogFileName); |
---|
219 | out.write("\n&taskid="); |
---|
220 | out.print(minShuffle.get(Keys.TASKID)); |
---|
221 | out.write('"'); |
---|
222 | out.write('>'); |
---|
223 | out.print(minShuffle.get(Keys.TASKID)); |
---|
224 | out.write("</a> : \n"); |
---|
225 | out.print(StringUtils.formatTimeDiff(minShuffle.getLong(Keys.SHUFFLE_FINISHED), |
---|
226 | minShuffle.getLong(Keys.START_TIME) ) ); |
---|
227 | out.write("</h3>\n<h3>Average time taken by Shuffle: \n"); |
---|
228 | out.print(StringUtils.formatTimeDiff(avgShuffleTime, 0) ); |
---|
229 | out.write("</h3>\n<h3>Worse performing Shuffle(s)</h3>\n<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n<tr><td>Task Id</td><td>Time taken</td></tr>\n"); |
---|
230 | |
---|
231 | for (int i=0;i<showTasks && i<reduceTasks.length; i++) { |
---|
232 | |
---|
233 | out.write("\n <tr>\n <td><a href=\"taskdetailshistory.jsp?jobid="); |
---|
234 | out.print(jobid); |
---|
235 | out.write("&logFile=\n"); |
---|
236 | out.print(encodedLogFileName); |
---|
237 | out.write("&taskid="); |
---|
238 | out.print(reduceTasks[i].get(Keys.TASKID)); |
---|
239 | out.write('"'); |
---|
240 | out.write('>'); |
---|
241 | out.write('\n'); |
---|
242 | out.print(reduceTasks[i].get(Keys.TASKID) ); |
---|
243 | out.write("</a></td>\n <td>"); |
---|
244 | out.print( |
---|
245 | StringUtils.formatTimeDiff( |
---|
246 | reduceTasks[i].getLong(Keys.SHUFFLE_FINISHED), |
---|
247 | reduceTasks[i].getLong(Keys.START_TIME)) ); |
---|
248 | out.write("\n </td>\n </tr>\n"); |
---|
249 | |
---|
250 | } |
---|
251 | |
---|
252 | out.write("\n</table>\n"); |
---|
253 | |
---|
254 | Comparator<JobHistory.Task> cFinishShuffle = |
---|
255 | new Comparator<JobHistory.Task>() { |
---|
256 | public int compare(JobHistory.Task t1, JobHistory.Task t2){ |
---|
257 | long l1 = t1.getLong(Keys.SHUFFLE_FINISHED); |
---|
258 | long l2 = t2.getLong(Keys.SHUFFLE_FINISHED); |
---|
259 | return (l2<l1 ? -1 : (l2==l1 ? 0 : 1)); |
---|
260 | } |
---|
261 | }; |
---|
262 | Arrays.sort(reduceTasks, cFinishShuffle); |
---|
263 | JobHistory.Task lastShuffle = reduceTasks[0] ; |
---|
264 | |
---|
265 | out.write("\n\n<h3>The last Shuffle \n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
266 | out.print(jobid); |
---|
267 | out.write("&logFile="); |
---|
268 | out.print(encodedLogFileName); |
---|
269 | out.write("\n&taskid="); |
---|
270 | out.print(lastShuffle.get(Keys.TASKID)); |
---|
271 | out.write('"'); |
---|
272 | out.write('>'); |
---|
273 | out.print(lastShuffle.get(Keys.TASKID)); |
---|
274 | out.write("\n</a> finished at (relative to the Job launch time): \n"); |
---|
275 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, |
---|
276 | lastShuffle.getLong(Keys.SHUFFLE_FINISHED), |
---|
277 | job.getLong(Keys.LAUNCH_TIME) ) ); |
---|
278 | out.write("</h3>\n\n"); |
---|
279 | |
---|
280 | Comparator<JobHistory.Task> cReduce = new Comparator<JobHistory.Task>(){ |
---|
281 | public int compare(JobHistory.Task t1, JobHistory.Task t2){ |
---|
282 | long l1 = t1.getLong(Keys.FINISH_TIME) - |
---|
283 | t1.getLong(Keys.SHUFFLE_FINISHED); |
---|
284 | long l2 = t2.getLong(Keys.FINISH_TIME) - |
---|
285 | t2.getLong(Keys.SHUFFLE_FINISHED); |
---|
286 | return (l2<l1 ? -1 : (l2==l1 ? 0 : 1)); |
---|
287 | } |
---|
288 | }; |
---|
289 | Arrays.sort(reduceTasks, cReduce); |
---|
290 | JobHistory.Task minReduce = reduceTasks[reduceTasks.length-1] ; |
---|
291 | |
---|
292 | out.write("\n<hr/>\n<h3>Time taken by best performing Reduce task : \n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
293 | out.print(jobid); |
---|
294 | out.write("&logFile="); |
---|
295 | out.print(encodedLogFileName); |
---|
296 | out.write("&taskid="); |
---|
297 | out.print(minReduce.get(Keys.TASKID)); |
---|
298 | out.write('"'); |
---|
299 | out.write('>'); |
---|
300 | out.write('\n'); |
---|
301 | out.print(minReduce.get(Keys.TASKID) ); |
---|
302 | out.write("</a> : \n"); |
---|
303 | out.print(StringUtils.formatTimeDiff(minReduce.getLong(Keys.FINISH_TIME), |
---|
304 | minReduce.getLong(Keys.SHUFFLE_FINISHED) ) ); |
---|
305 | out.write("</h3>\n\n<h3>Average time taken by Reduce tasks: \n"); |
---|
306 | out.print(StringUtils.formatTimeDiff(avgReduceTime, 0) ); |
---|
307 | out.write("</h3>\n<h3>Worse performing reduce tasks</h3>\n<table border=\"2\" cellpadding=\"5\" cellspacing=\"2\">\n<tr><td>Task Id</td><td>Time taken</td></tr>\n"); |
---|
308 | |
---|
309 | for (int i=0;i<showTasks && i<reduceTasks.length; i++) { |
---|
310 | |
---|
311 | out.write("\n <tr>\n <td><a href=\"taskdetailshistory.jsp?jobid="); |
---|
312 | out.print(jobid); |
---|
313 | out.write("&logFile="); |
---|
314 | out.print(encodedLogFileName); |
---|
315 | out.write("&taskid="); |
---|
316 | out.print(reduceTasks[i].get(Keys.TASKID)); |
---|
317 | out.write("\">\n "); |
---|
318 | out.print(reduceTasks[i].get(Keys.TASKID) ); |
---|
319 | out.write("</a></td>\n <td>"); |
---|
320 | out.print(StringUtils.formatTimeDiff( |
---|
321 | reduceTasks[i].getLong(Keys.FINISH_TIME), |
---|
322 | reduceTasks[i].getLong(Keys.SHUFFLE_FINISHED)) ); |
---|
323 | out.write("</td>\n </tr>\n"); |
---|
324 | |
---|
325 | } |
---|
326 | |
---|
327 | out.write("\n</table>\n"); |
---|
328 | |
---|
329 | Arrays.sort(reduceTasks, cFinishMapRed); |
---|
330 | JobHistory.Task lastReduce = reduceTasks[0] ; |
---|
331 | |
---|
332 | out.write("\n\n<h3>The last Reduce task \n<a href=\"taskdetailshistory.jsp?jobid="); |
---|
333 | out.print(jobid); |
---|
334 | out.write("&logFile="); |
---|
335 | out.print(encodedLogFileName); |
---|
336 | out.write("\n&taskid="); |
---|
337 | out.print(lastReduce.get(Keys.TASKID)); |
---|
338 | out.write('"'); |
---|
339 | out.write('>'); |
---|
340 | out.print(lastReduce.get(Keys.TASKID)); |
---|
341 | out.write("\n</a> finished at (relative to the Job launch time): \n"); |
---|
342 | out.print(StringUtils.getFormattedTimeWithDiff(dateFormat, |
---|
343 | lastReduce.getLong(Keys.FINISH_TIME), |
---|
344 | job.getLong(Keys.LAUNCH_TIME) ) ); |
---|
345 | out.write("</h3>\n</center>\n</body></html>\n"); |
---|
346 | } catch (Throwable t) { |
---|
347 | if (!(t instanceof SkipPageException)){ |
---|
348 | out = _jspx_out; |
---|
349 | if (out != null && out.getBufferSize() != 0) |
---|
350 | out.clearBuffer(); |
---|
351 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
352 | } |
---|
353 | } finally { |
---|
354 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
355 | } |
---|
356 | } |
---|
357 | } |
---|