PageRenderTime 28ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/webapps/job/jobdetailshistory.jsp

https://github.com/coderplay/hadoop-common
JavaServer Pages | 343 lines | 325 code | 18 blank | 0 comment | 47 complexity | ee740925a05b4a704757f22807563398 MD5 | raw file
  1. <%@ page
  2. contentType="text/html; charset=UTF-8"
  3. import="javax.servlet.http.*"
  4. import="java.io.*"
  5. import="java.util.*"
  6. import="org.apache.hadoop.fs.*"
  7. import="org.apache.hadoop.http.HtmlQuoting"
  8. import="org.apache.hadoop.mapred.*"
  9. import="org.apache.hadoop.util.*"
  10. import="java.text.*"
  11. import="org.apache.hadoop.mapred.JobHistory.*"
  12. import="java.security.PrivilegedExceptionAction"
  13. import="org.apache.hadoop.security.AccessControlException"
  14. import="org.apache.hadoop.mapreduce.JobACL"
  15. import="org.apache.hadoop.security.authorize.AccessControlList"
  16. %>
  17. <%! private static final long serialVersionUID = 1L;
  18. %>
  19. <%! static SimpleDateFormat dateFormat = new SimpleDateFormat("d-MMM-yyyy HH:mm:ss") ; %>
  20. <%
  21. String logFile = request.getParameter("logFile");
  22. String jobid = JSPUtil.getJobID(new Path(logFile).getName());
  23. FileSystem fs = (FileSystem) application.getAttribute("fileSys");
  24. JobTracker jobTracker = (JobTracker) application.getAttribute("job.tracker");
  25. JobHistory.JobInfo job = JSPUtil.checkAccessAndGetJobInfo(request,
  26. response, jobTracker, fs, new Path(logFile));
  27. if (job == null) {
  28. return;
  29. }
  30. String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile);
  31. %>
  32. <html>
  33. <head>
  34. <title>Hadoop Job <%=jobid%> on History Viewer</title>
  35. <link rel="stylesheet" type="text/css" href="/static/hadoop.css">
  36. </head>
  37. <body>
  38. <h2>Hadoop Job <%=jobid %> on <a href="jobhistory.jsp">History Viewer</a></h2>
  39. <b>User: </b> <%=HtmlQuoting.quoteHtmlChars(job.get(Keys.USER)) %><br/>
  40. <b>JobName: </b> <%=HtmlQuoting.quoteHtmlChars(job.get(Keys.JOBNAME)) %><br/>
  41. <b>JobConf: </b> <a href="jobconf_history.jsp?logFile=<%=encodedLogFileName%>">
  42. <%=job.get(Keys.JOBCONF) %></a><br/>
  43. <%
  44. Map<JobACL, AccessControlList> jobAcls = job.getJobACLs();
  45. JSPUtil.printJobACLs(jobTracker, jobAcls, out);
  46. %>
  47. <b>Submitted At: </b> <%=StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.SUBMIT_TIME), 0 ) %><br/>
  48. <b>Launched At: </b> <%=StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.LAUNCH_TIME), job.getLong(Keys.SUBMIT_TIME)) %><br/>
  49. <b>Finished At: </b> <%=StringUtils.getFormattedTimeWithDiff(dateFormat, job.getLong(Keys.FINISH_TIME), job.getLong(Keys.LAUNCH_TIME)) %><br/>
  50. <b>Status: </b> <%= ((job.get(Keys.JOB_STATUS) == "")?"Incomplete" :job.get(Keys.JOB_STATUS)) %><br/>
  51. <%
  52. Map<String, JobHistory.Task> tasks = job.getAllTasks();
  53. int totalMaps = 0 ;
  54. int totalReduces = 0;
  55. int totalCleanups = 0;
  56. int totalSetups = 0;
  57. int numFailedMaps = 0;
  58. int numKilledMaps = 0;
  59. int numFailedReduces = 0 ;
  60. int numKilledReduces = 0;
  61. int numFinishedCleanups = 0;
  62. int numFailedCleanups = 0;
  63. int numKilledCleanups = 0;
  64. int numFinishedSetups = 0;
  65. int numFailedSetups = 0;
  66. int numKilledSetups = 0;
  67. long mapStarted = 0 ;
  68. long mapFinished = 0 ;
  69. long reduceStarted = 0 ;
  70. long reduceFinished = 0;
  71. long cleanupStarted = 0;
  72. long cleanupFinished = 0;
  73. long setupStarted = 0;
  74. long setupFinished = 0;
  75. Map <String,String> allHosts = new TreeMap<String,String>();
  76. for (JobHistory.Task task : tasks.values()) {
  77. Map<String, TaskAttempt> attempts = task.getTaskAttempts();
  78. allHosts.put(task.get(Keys.HOSTNAME), "");
  79. for (TaskAttempt attempt : attempts.values()) {
  80. long startTime = attempt.getLong(Keys.START_TIME) ;
  81. long finishTime = attempt.getLong(Keys.FINISH_TIME) ;
  82. if (Values.MAP.name().equals(task.get(Keys.TASK_TYPE))){
  83. if (mapStarted==0 || mapStarted > startTime ) {
  84. mapStarted = startTime;
  85. }
  86. if (mapFinished < finishTime ) {
  87. mapFinished = finishTime ;
  88. }
  89. totalMaps++;
  90. if (Values.FAILED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  91. numFailedMaps++;
  92. } else if (Values.KILLED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  93. numKilledMaps++;
  94. }
  95. } else if (Values.REDUCE.name().equals(task.get(Keys.TASK_TYPE))) {
  96. if (reduceStarted==0||reduceStarted > startTime) {
  97. reduceStarted = startTime ;
  98. }
  99. if (reduceFinished < finishTime) {
  100. reduceFinished = finishTime;
  101. }
  102. totalReduces++;
  103. if (Values.FAILED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  104. numFailedReduces++;
  105. } else if (Values.KILLED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  106. numKilledReduces++;
  107. }
  108. } else if (Values.CLEANUP.name().equals(task.get(Keys.TASK_TYPE))) {
  109. if (cleanupStarted==0||cleanupStarted > startTime) {
  110. cleanupStarted = startTime ;
  111. }
  112. if (cleanupFinished < finishTime) {
  113. cleanupFinished = finishTime;
  114. }
  115. totalCleanups++;
  116. if (Values.SUCCESS.name().equals(attempt.get(Keys.TASK_STATUS))) {
  117. numFinishedCleanups++;
  118. } else if (Values.FAILED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  119. numFailedCleanups++;
  120. } else if (Values.KILLED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  121. numKilledCleanups++;
  122. }
  123. } else if (Values.SETUP.name().equals(task.get(Keys.TASK_TYPE))) {
  124. if (setupStarted==0||setupStarted > startTime) {
  125. setupStarted = startTime ;
  126. }
  127. if (setupFinished < finishTime) {
  128. setupFinished = finishTime;
  129. }
  130. totalSetups++;
  131. if (Values.SUCCESS.name().equals(attempt.get(Keys.TASK_STATUS))) {
  132. numFinishedSetups++;
  133. } else if (Values.FAILED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  134. numFailedSetups++;
  135. } else if (Values.KILLED.name().equals(attempt.get(Keys.TASK_STATUS))) {
  136. numKilledSetups++;
  137. }
  138. }
  139. }
  140. }
  141. %>
  142. <b><a href="analysejobhistory.jsp?logFile=<%=encodedLogFileName%>">Analyse This Job</a></b>
  143. <hr/>
  144. <center>
  145. <table border="2" cellpadding="5" cellspacing="2">
  146. <tr>
  147. <td>Kind</td><td>Total Tasks(successful+failed+killed)</td><td>Successful tasks</td><td>Failed tasks</td><td>Killed tasks</td><td>Start Time</td><td>Finish Time</td>
  148. </tr>
  149. <tr>
  150. <td>Setup</td>
  151. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.SETUP.name() %>&status=all">
  152. <%=totalSetups%></a></td>
  153. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.SETUP.name() %>&status=<%=Values.SUCCESS %>">
  154. <%=numFinishedSetups%></a></td>
  155. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.SETUP.name() %>&status=<%=Values.FAILED %>">
  156. <%=numFailedSetups%></a></td>
  157. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.SETUP.name() %>&status=<%=Values.KILLED %>">
  158. <%=numKilledSetups%></a></td>
  159. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, setupStarted, 0) %></td>
  160. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, setupFinished, setupStarted) %></td>
  161. </tr>
  162. <tr>
  163. <td>Map</td>
  164. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.MAP.name() %>&status=all">
  165. <%=totalMaps %></a></td>
  166. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.MAP.name() %>&status=<%=Values.SUCCESS %>">
  167. <%=job.getInt(Keys.FINISHED_MAPS) %></a></td>
  168. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.MAP.name() %>&status=<%=Values.FAILED %>">
  169. <%=numFailedMaps %></a></td>
  170. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.MAP.name() %>&status=<%=Values.KILLED %>">
  171. <%=numKilledMaps %></a></td>
  172. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, mapStarted, 0) %></td>
  173. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, mapFinished, mapStarted) %></td>
  174. </tr>
  175. <tr>
  176. <td>Reduce</td>
  177. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.REDUCE.name() %>&status=all">
  178. <%=totalReduces%></a></td>
  179. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.REDUCE.name() %>&status=<%=Values.SUCCESS %>">
  180. <%=job.getInt(Keys.FINISHED_REDUCES)%></a></td>
  181. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.REDUCE.name() %>&status=<%=Values.FAILED %>">
  182. <%=numFailedReduces%></a></td>
  183. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.REDUCE.name() %>&status=<%=Values.KILLED %>">
  184. <%=numKilledReduces%></a></td>
  185. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, reduceStarted, 0) %></td>
  186. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, reduceFinished, reduceStarted) %></td>
  187. </tr>
  188. <tr>
  189. <td>Cleanup</td>
  190. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.CLEANUP.name() %>&status=all">
  191. <%=totalCleanups%></a></td>
  192. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.CLEANUP.name() %>&status=<%=Values.SUCCESS %>">
  193. <%=numFinishedCleanups%></a></td>
  194. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.CLEANUP.name() %>&status=<%=Values.FAILED %>">
  195. <%=numFailedCleanups%></a></td>
  196. <td><a href="jobtaskshistory.jsp?logFile=<%=encodedLogFileName%>&taskType=<%=Values.CLEANUP.name() %>&status=<%=Values.KILLED %>">
  197. <%=numKilledCleanups%></a></td>
  198. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, cleanupStarted, 0) %></td>
  199. <td><%=StringUtils.getFormattedTimeWithDiff(dateFormat, cleanupFinished, cleanupStarted) %></td>
  200. </tr>
  201. </table>
  202. <br>
  203. <br>
  204. <table border=2 cellpadding="5" cellspacing="2">
  205. <tr>
  206. <th><br/></th>
  207. <th>Counter</th>
  208. <th>Map</th>
  209. <th>Reduce</th>
  210. <th>Total</th>
  211. </tr>
  212. <%
  213. Counters totalCounters =
  214. Counters.fromEscapedCompactString(job.get(Keys.COUNTERS));
  215. Counters mapCounters =
  216. Counters.fromEscapedCompactString(job.get(Keys.MAP_COUNTERS));
  217. Counters reduceCounters =
  218. Counters.fromEscapedCompactString(job.get(Keys.REDUCE_COUNTERS));
  219. if (totalCounters != null) {
  220. for (String groupName : totalCounters.getGroupNames()) {
  221. Counters.Group totalGroup = totalCounters.getGroup(groupName);
  222. Counters.Group mapGroup = mapCounters.getGroup(groupName);
  223. Counters.Group reduceGroup = reduceCounters.getGroup(groupName);
  224. Format decimal = new DecimalFormat();
  225. boolean isFirst = true;
  226. Iterator<Counters.Counter> ctrItr = totalGroup.iterator();
  227. while(ctrItr.hasNext()) {
  228. Counters.Counter counter = ctrItr.next();
  229. String name = counter.getDisplayName();
  230. String mapValue =
  231. decimal.format(mapGroup.getCounter(name));
  232. String reduceValue =
  233. decimal.format(reduceGroup.getCounter(name));
  234. String totalValue = decimal.format(counter.getCounter());
  235. %>
  236. <tr>
  237. <%
  238. if (isFirst) {
  239. isFirst = false;
  240. %>
  241. <td rowspan="<%=totalGroup.size()%>">
  242. <%=HtmlQuoting.quoteHtmlChars(totalGroup.getDisplayName())%></td>
  243. <%
  244. }
  245. %>
  246. <td><%=HtmlQuoting.quoteHtmlChars(counter.getDisplayName())%></td>
  247. <td align="right"><%=mapValue%></td>
  248. <td align="right"><%=reduceValue%></td>
  249. <td align="right"><%=totalValue%></td>
  250. </tr>
  251. <%
  252. }
  253. }
  254. }
  255. %>
  256. </table>
  257. <br>
  258. <br/>
  259. <%
  260. DefaultJobHistoryParser.FailedOnNodesFilter filter =
  261. new DefaultJobHistoryParser.FailedOnNodesFilter();
  262. JobHistory.parseHistoryFromFS(logFile, filter, fs);
  263. Map<String, Set<String>> badNodes = filter.getValues();
  264. if (badNodes.size() > 0) {
  265. %>
  266. <h3>Failed tasks attempts by nodes </h3>
  267. <table border="1">
  268. <tr><td>Hostname</td><td>Failed Tasks</td></tr>
  269. <%
  270. for (Map.Entry<String, Set<String>> entry : badNodes.entrySet()) {
  271. String node = entry.getKey();
  272. Set<String> failedTasks = entry.getValue();
  273. %>
  274. <tr>
  275. <td><%=node %></td>
  276. <td>
  277. <%
  278. for (String t : failedTasks) {
  279. %>
  280. <a href="taskdetailshistory.jsp?logFile=<%=encodedLogFileName%>&tipid=<%=t %>"><%=t %></a>,&nbsp;
  281. <%
  282. }
  283. %>
  284. </td>
  285. </tr>
  286. <%
  287. }
  288. }
  289. %>
  290. </table>
  291. <br/>
  292. <%
  293. DefaultJobHistoryParser.KilledOnNodesFilter killedFilter =
  294. new DefaultJobHistoryParser.KilledOnNodesFilter();
  295. JobHistory.parseHistoryFromFS(logFile, filter, fs);
  296. badNodes = killedFilter.getValues();
  297. if (badNodes.size() > 0) {
  298. %>
  299. <h3>Killed tasks attempts by nodes </h3>
  300. <table border="1">
  301. <tr><td>Hostname</td><td>Killed Tasks</td></tr>
  302. <%
  303. for (Map.Entry<String, Set<String>> entry : badNodes.entrySet()) {
  304. String node = entry.getKey();
  305. Set<String> killedTasks = entry.getValue();
  306. %>
  307. <tr>
  308. <td><%=node %></td>
  309. <td>
  310. <%
  311. for (String t : killedTasks) {
  312. %>
  313. <a href="taskdetailshistory.jsp?logFile=<%=encodedLogFileName%>&tipid=<%=t %>"><%=t %></a>,&nbsp;
  314. <%
  315. }
  316. %>
  317. </td>
  318. </tr>
  319. <%
  320. }
  321. }
  322. %>
  323. </table>
  324. </center>
  325. </body></html>