taskdetailshistory.jsp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <%
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. %>
  20. <%@ page
  21. contentType="text/html; charset=UTF-8"
  22. import="javax.servlet.http.*"
  23. import="java.io.*"
  24. import="java.util.*"
  25. import="org.apache.hadoop.http.HtmlQuoting"
  26. import="org.apache.hadoop.mapred.*"
  27. import="org.apache.hadoop.fs.*"
  28. import="org.apache.hadoop.util.*"
  29. import="java.text.SimpleDateFormat"
  30. import="org.apache.hadoop.mapreduce.TaskType"
  31. import="org.apache.hadoop.mapreduce.Counters"
  32. import="org.apache.hadoop.mapreduce.TaskID"
  33. import="org.apache.hadoop.mapreduce.TaskAttemptID"
  34. import="org.apache.hadoop.mapreduce.jobhistory.*"
  35. %>
  36. <%! private static SimpleDateFormat dateFormat = new SimpleDateFormat("d/MM HH:mm:ss") ; %>
  37. <%! private static final long serialVersionUID = 1L;
  38. %>
  39. <%
  40. String logFile = request.getParameter("logFile");
  41. String tipid = request.getParameter("tipid");
  42. FileSystem fs = (FileSystem) application.getAttribute("fileSys");
  43. JobTracker jobTracker = (JobTracker) application.getAttribute("job.tracker");
  44. JobHistoryParser.JobInfo job = JSPUtil.checkAccessAndGetJobInfo(request,
  45. response, jobTracker, fs, new Path(logFile));
  46. if (job == null) {
  47. return;
  48. }
  49. JobHistoryParser.TaskInfo task = job.getAllTasks().get(TaskID.forName(tipid));
  50. TaskType type = task.getTaskType();
  51. %>
  52. <!DOCTYPE html>
  53. <html>
  54. <body>
  55. <h2><%=tipid %> attempts for <a href="jobdetailshistory.jsp?logFile=<%=logFile%>"> <%=job.getJobId() %> </a></h2>
  56. <center>
  57. <table border="2" cellpadding="5" cellspacing="2">
  58. <tr><td>Task Id</td><td>Start Time</td>
  59. <%
  60. if (TaskType.REDUCE.equals(type)) {
  61. %>
  62. <td>Shuffle Finished</td><td>Sort Finished</td>
  63. <%
  64. }
  65. %>
  66. <td>Finish Time</td><td>Host</td><td>Error</td><td>Task Logs</td>
  67. <td>Counters</td></tr>
  68. <%
  69. for (JobHistoryParser.TaskAttemptInfo attempt : task.getAllTaskAttempts().values()) {
  70. printTaskAttempt(attempt, type, out, logFile);
  71. }
  72. %>
  73. </table>
  74. </center>
  75. <%
  76. if (TaskType.MAP.equals(type)) {
  77. %>
  78. <h3>Input Split Locations</h3>
  79. <table border="2" cellpadding="5" cellspacing="2">
  80. <%
  81. for (String split : StringUtils.split(task.getSplitLocations()))
  82. {
  83. out.println("<tr><td>" + split + "</td></tr>");
  84. }
  85. %>
  86. </table>
  87. <%
  88. }
  89. %>
  90. <%!
  91. private void printTaskAttempt(JobHistoryParser.TaskAttemptInfo taskAttempt,
  92. TaskType type, JspWriter out, String logFile)
  93. throws IOException {
  94. out.print("<tr>");
  95. out.print("<td>" + taskAttempt.getAttemptId() + "</td>");
  96. out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat,
  97. taskAttempt.getStartTime(), 0 ) + "</td>");
  98. if (TaskType.REDUCE.equals(type)) {
  99. out.print("<td>" +
  100. StringUtils.getFormattedTimeWithDiff(dateFormat,
  101. taskAttempt.getShuffleFinishTime(),
  102. taskAttempt.getStartTime()) + "</td>");
  103. out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat,
  104. taskAttempt.getSortFinishTime(),
  105. taskAttempt.getShuffleFinishTime()) + "</td>");
  106. }
  107. out.print("<td>"+ StringUtils.getFormattedTimeWithDiff(dateFormat,
  108. taskAttempt.getFinishTime(),
  109. taskAttempt.getStartTime()) + "</td>");
  110. out.print("<td>" + taskAttempt.getHostname() + "</td>");
  111. out.print("<td>" + HtmlQuoting.quoteHtmlChars(taskAttempt.getError()) +
  112. "</td>");
  113. // Print task log urls
  114. out.print("<td>");
  115. String taskLogsUrl = HistoryViewer.getTaskLogsUrl(taskAttempt);
  116. if (taskLogsUrl != null) {
  117. String tailFourKBUrl = taskLogsUrl + "&start=-4097";
  118. String tailEightKBUrl = taskLogsUrl + "&start=-8193";
  119. String entireLogUrl = taskLogsUrl + "&all=true";
  120. out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>");
  121. out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>");
  122. out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>");
  123. } else {
  124. out.print("n/a");
  125. }
  126. out.print("</td>");
  127. Counters counters = taskAttempt.getCounters();
  128. if (counters != null) {
  129. TaskAttemptID attemptId = taskAttempt.getAttemptId();
  130. out.print("<td>"
  131. + "<a href=\"/taskstatshistory.jsp?attemptid=" + attemptId
  132. + "&logFile=" + logFile + "\">"
  133. + counters.countCounters() + "</a></td>");
  134. } else {
  135. out.print("<td></td>");
  136. }
  137. out.print("</tr>");
  138. }
  139. %>
  140. </body>
  141. </html>