taskdetails.jsp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.lang.String"
  7. import="java.util.*"
  8. import="org.apache.hadoop.mapred.*"
  9. import="org.apache.hadoop.util.*"
  10. import="java.text.SimpleDateFormat"
  11. import="org.apache.hadoop.util.*"
  12. %>
  13. <%!static SimpleDateFormat dateFormat = new SimpleDateFormat(
  14. "d-MMM-yyyy HH:mm:ss");
  15. private static final String PRIVATE_ACTIONS_KEY = "webinterface.private.actions";%>
  16. <%!private void printConfirm(JspWriter out, String jobid, String tipid,
  17. String taskid, String action) throws IOException {
  18. String url = "taskdetails.jsp?jobid=" + jobid + "&tipid=" + tipid
  19. + "&taskid=" + taskid;
  20. out.print("<html><head><META http-equiv=\"refresh\" content=\"15;URL="
  21. + url + "\"></head>" + "<body><h3> Are you sure you want to kill/fail "
  22. + taskid + " ?<h3><br><table border=\"0\"><tr><td width=\"100\">"
  23. + "<form action=\"" + url + "\" method=\"post\">"
  24. + "<input type=\"hidden\" name=\"action\" value=\"" + action + "\" />"
  25. + "<input type=\"submit\" name=\"Kill/Fail\" value=\"Kill/Fail\" />"
  26. + "</form>"
  27. + "</td><td width=\"100\"><form method=\"post\" action=\"" + url
  28. + "\"><input type=\"submit\" value=\"Cancel\" name=\"Cancel\""
  29. + "/></form></td></tr></table></body></html>");
  30. }%>
  31. <%
  32. JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
  33. String jobid = request.getParameter("jobid");
  34. String tipid = request.getParameter("tipid");
  35. String taskid = request.getParameter("taskid");
  36. JobID jobidObj = JobID.forName(jobid);
  37. TaskID tipidObj = TaskID.forName(tipid);
  38. TaskAttemptID taskidObj = TaskAttemptID.forName(taskid);
  39. JobInProgress job = (JobInProgress) tracker.getJob(jobidObj);
  40. boolean privateActions = JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY,
  41. false);
  42. if (privateActions) {
  43. String action = request.getParameter("action");
  44. if (action != null) {
  45. if (action.equalsIgnoreCase("confirm")) {
  46. String subAction = request.getParameter("subaction");
  47. if (subAction == null)
  48. subAction = "fail-task";
  49. printConfirm(out, jobid, tipid, taskid, subAction);
  50. return;
  51. }
  52. else if (action.equalsIgnoreCase("kill-task")
  53. && request.getMethod().equalsIgnoreCase("POST")) {
  54. tracker.killTask(taskidObj, false);
  55. //redirect again so that refreshing the page will not attempt to rekill the task
  56. response.sendRedirect("/taskdetails.jsp?" + "&subaction=kill-task"
  57. + "&jobid=" + jobid + "&tipid=" + tipid);
  58. }
  59. else if (action.equalsIgnoreCase("fail-task")
  60. && request.getMethod().equalsIgnoreCase("POST")) {
  61. tracker.killTask(taskidObj, true);
  62. response.sendRedirect("/taskdetails.jsp?" + "&subaction=fail-task"
  63. + "&jobid=" + jobid + "&tipid=" + tipid);
  64. }
  65. }
  66. }
  67. TaskInProgress tip = null;
  68. if (job != null && tipidObj != null) {
  69. tip = job.getTaskInProgress(tipidObj);
  70. }
  71. TaskStatus[] ts = null;
  72. if (tip != null) {
  73. ts = tip.getTaskStatuses();
  74. }
  75. boolean isCleanupOrSetup = false;
  76. if ( tip != null) {
  77. isCleanupOrSetup = tip.isJobCleanupTask();
  78. if (!isCleanupOrSetup) {
  79. isCleanupOrSetup = tip.isJobSetupTask();
  80. }
  81. }
  82. %>
  83. <html>
  84. <head>
  85. <link rel="stylesheet" type="text/css" href="/static/hadoop.css">
  86. <title>Hadoop Task Details</title>
  87. </head>
  88. <body>
  89. <h1>Job <a href="/jobdetails.jsp?jobid=<%=jobid%>"><%=jobid%></a></h1>
  90. <hr>
  91. <h2>All Task Attempts</h2>
  92. <center>
  93. <%
  94. if (ts == null || ts.length == 0) {
  95. %>
  96. <h3>No Task Attempts found</h3>
  97. <%
  98. } else {
  99. %>
  100. <table border=2 cellpadding="5" cellspacing="2">
  101. <tr><td align="center">Task Attempts</td><td>Machine</td><td>Status</td><td>Progress</td><td>Start Time</td>
  102. <%
  103. if (!ts[0].getIsMap() && !isCleanupOrSetup) {
  104. %>
  105. <td>Shuffle Finished</td><td>Sort Finished</td>
  106. <%
  107. }
  108. %>
  109. <td>Finish Time</td><td>Errors</td><td>Task Logs</td><td>Counters</td><td>Actions</td></tr>
  110. <%
  111. for (int i = 0; i < ts.length; i++) {
  112. TaskStatus status = ts[i];
  113. String taskTrackerName = status.getTaskTracker();
  114. TaskTrackerStatus taskTracker = tracker.getTaskTracker(taskTrackerName);
  115. out.print("<tr><td>" + status.getTaskID() + "</td>");
  116. String taskAttemptTracker = null;
  117. String cleanupTrackerName = null;
  118. TaskTrackerStatus cleanupTracker = null;
  119. String cleanupAttemptTracker = null;
  120. boolean hasCleanupAttempt = false;
  121. if (tip != null && tip.isCleanupAttempt(status.getTaskID())) {
  122. cleanupTrackerName = tip.machineWhereCleanupRan(status.getTaskID());
  123. cleanupTracker = tracker.getTaskTracker(cleanupTrackerName);
  124. if (cleanupTracker != null) {
  125. cleanupAttemptTracker = "http://" + cleanupTracker.getHost() + ":"
  126. + cleanupTracker.getHttpPort();
  127. }
  128. hasCleanupAttempt = true;
  129. }
  130. out.print("<td>");
  131. if (hasCleanupAttempt) {
  132. out.print("Task attempt: ");
  133. }
  134. if (taskTracker == null) {
  135. out.print(taskTrackerName);
  136. } else {
  137. taskAttemptTracker = "http://" + taskTracker.getHost() + ":"
  138. + taskTracker.getHttpPort();
  139. out.print("<a href=\"" + taskAttemptTracker + "\">"
  140. + tracker.getNode(taskTracker.getHost()) + "</a>");
  141. }
  142. if (hasCleanupAttempt) {
  143. out.print("<br/>Cleanup Attempt: ");
  144. if (cleanupAttemptTracker == null ) {
  145. out.print(cleanupTrackerName);
  146. } else {
  147. out.print("<a href=\"" + cleanupAttemptTracker + "\">"
  148. + tracker.getNode(cleanupTracker.getHost()) + "</a>");
  149. }
  150. }
  151. out.print("</td>");
  152. out.print("<td>" + status.getRunState() + "</td>");
  153. out.print("<td>" + StringUtils.formatPercent(status.getProgress(), 2)
  154. + ServletUtil.percentageGraph(status.getProgress() * 100f, 80) + "</td>");
  155. out.print("<td>"
  156. + StringUtils.getFormattedTimeWithDiff(dateFormat, status
  157. .getStartTime(), 0) + "</td>");
  158. if (!ts[i].getIsMap() && !isCleanupOrSetup) {
  159. out.print("<td>"
  160. + StringUtils.getFormattedTimeWithDiff(dateFormat, status
  161. .getShuffleFinishTime(), status.getStartTime()) + "</td>");
  162. out.println("<td>"
  163. + StringUtils.getFormattedTimeWithDiff(dateFormat, status
  164. .getSortFinishTime(), status.getShuffleFinishTime())
  165. + "</td>");
  166. }
  167. out.println("<td>"
  168. + StringUtils.getFormattedTimeWithDiff(dateFormat, status
  169. .getFinishTime(), status.getStartTime()) + "</td>");
  170. out.print("<td><pre>");
  171. String [] failures = tracker.getTaskDiagnostics(status.getTaskID());
  172. if (failures == null) {
  173. out.print("&nbsp;");
  174. } else {
  175. for(int j = 0 ; j < failures.length ; j++){
  176. out.print(failures[j]);
  177. if (j < (failures.length - 1)) {
  178. out.print("\n-------\n");
  179. }
  180. }
  181. }
  182. out.print("</pre></td>");
  183. out.print("<td>");
  184. String taskLogUrl = null;
  185. if (taskTracker != null ) {
  186. taskLogUrl = TaskLogServlet.getTaskLogUrl(taskTracker.getHost(),
  187. String.valueOf(taskTracker.getHttpPort()),
  188. status.getTaskID().toString());
  189. }
  190. if (hasCleanupAttempt) {
  191. out.print("Task attempt: <br/>");
  192. }
  193. if (taskLogUrl == null) {
  194. out.print("n/a");
  195. } else {
  196. String tailFourKBUrl = taskLogUrl + "&start=-4097";
  197. String tailEightKBUrl = taskLogUrl + "&start=-8193";
  198. String entireLogUrl = taskLogUrl + "&all=true";
  199. out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>");
  200. out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>");
  201. out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>");
  202. }
  203. if (hasCleanupAttempt) {
  204. out.print("Cleanup attempt: <br/>");
  205. taskLogUrl = null;
  206. if (cleanupTracker != null ) {
  207. taskLogUrl = TaskLogServlet.getTaskLogUrl(cleanupTracker.getHost(),
  208. String.valueOf(cleanupTracker.getHttpPort()),
  209. status.getTaskID().toString());
  210. }
  211. if (taskLogUrl == null) {
  212. out.print("n/a");
  213. } else {
  214. String tailFourKBUrl = taskLogUrl + "&start=-4097&cleanup=true";
  215. String tailEightKBUrl = taskLogUrl + "&start=-8193&cleanup=true";
  216. String entireLogUrl = taskLogUrl + "&all=true&cleanup=true";
  217. out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>");
  218. out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>");
  219. out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>");
  220. }
  221. }
  222. out.print("</td><td>" + "<a href=\"/taskstats.jsp?jobid=" + jobid
  223. + "&tipid=" + tipid + "&taskid=" + status.getTaskID() + "\">"
  224. + ((status.getCounters() != null) ? status.getCounters().size() : 0) + "</a></td>");
  225. out.print("<td>");
  226. if (privateActions
  227. && status.getRunState() == TaskStatus.State.RUNNING) {
  228. out.print("<a href=\"/taskdetails.jsp?action=confirm"
  229. + "&subaction=kill-task" + "&jobid=" + jobid + "&tipid="
  230. + tipid + "&taskid=" + status.getTaskID() + "\" > Kill </a>");
  231. out.print("<br><a href=\"/taskdetails.jsp?action=confirm"
  232. + "&subaction=fail-task" + "&jobid=" + jobid + "&tipid="
  233. + tipid + "&taskid=" + status.getTaskID() + "\" > Fail </a>");
  234. }
  235. else
  236. out.print("<pre>&nbsp;</pre>");
  237. out.println("</td></tr>");
  238. }
  239. %>
  240. </table>
  241. </center>
  242. <%
  243. if (ts[0].getIsMap() && !isCleanupOrSetup) {
  244. %>
  245. <h3>Input Split Locations</h3>
  246. <table border=2 cellpadding="5" cellspacing="2">
  247. <%
  248. for (String split: StringUtils.split(tracker.getTip(
  249. tipidObj).getSplitNodes())) {
  250. out.println("<tr><td>" + split + "</td></tr>");
  251. }
  252. %>
  253. </table>
  254. <%
  255. }
  256. }
  257. %>
  258. <hr>
  259. <a href="jobdetails.jsp?jobid=<%=jobid%>">Go back to the job</a><br>
  260. <a href="jobtracker.jsp">Go back to JobTracker</a><br>
  261. <%
  262. out.println(ServletUtil.htmlFooter());
  263. %>