taskdetailshistory.jsp
上传用户:quxuerui
上传日期:2018-01-08
资源大小:41811k
文件大小:4k
源码类别:

网格计算

开发平台:

Java

  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.mapred.*"
  7.   import="org.apache.hadoop.util.*"
  8.   import="java.text.SimpleDateFormat"
  9.   import="org.apache.hadoop.mapred.JobHistory.*"
  10. %>
  11. <jsp:include page="loadhistory.jsp">
  12.   <jsp:param name="jobid" value="<%=request.getParameter("jobid") %>"/>
  13.   <jsp:param name="jobTrackerId" value="<%=request.getParameter("jobTrackerId") %>"/>
  14. </jsp:include>
  15. <%! private static SimpleDateFormat dateFormat = new SimpleDateFormat("d/MM HH:mm:ss") ; %>
  16. <%
  17.   String jobid = request.getParameter("jobid");
  18.   String logFile = request.getParameter("logFile");
  19.   String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile);
  20.   String taskid = request.getParameter("taskid"); 
  21.   JobHistory.JobInfo job = (JobHistory.JobInfo)
  22.                               request.getSession().getAttribute("job");
  23.   JobHistory.Task task = job.getAllTasks().get(taskid); 
  24.   String type = task.get(Keys.TASK_TYPE);
  25. %>
  26. <html>
  27. <body>
  28. <h2><%=taskid %> attempts for <a href="jobdetailshistory.jsp?jobid=<%=jobid%>&&logFile=<%=encodedLogFileName%>"> <%=jobid %> </a></h2>
  29. <center>
  30. <table border="2" cellpadding="5" cellspacing="2">
  31. <tr><td>Task Id</td><td>Start Time</td>
  32. <%
  33.   if (Values.REDUCE.name().equals(type)) {
  34. %>
  35.     <td>Shuffle Finished</td><td>Sort Finished</td>
  36. <%
  37.   }
  38. %>
  39. <td>Finish Time</td><td>Host</td><td>Error</td><td>Task Logs</td></tr>
  40. <%
  41.   for (JobHistory.TaskAttempt attempt : task.getTaskAttempts().values()) {
  42.     printTaskAttempt(attempt, type, out);
  43.   }
  44. %>
  45. </table>
  46. </center>
  47. <%
  48.   if (Values.MAP.name().equals(type)) {
  49. %>
  50. <h3>Input Split Locations</h3>
  51. <table border="2" cellpadding="5" cellspacing="2">
  52. <%
  53.     for (String split : StringUtils.split(task.get(Keys.SPLITS)))
  54.     {
  55.       out.println("<tr><td>" + split + "</td></tr>");
  56.     }
  57. %>
  58. </table>    
  59. <%
  60.   }
  61. %>
  62. <%!
  63.   private void printTaskAttempt(JobHistory.TaskAttempt taskAttempt,
  64.                                 String type, JspWriter out) 
  65.   throws IOException {
  66.     out.print("<tr>"); 
  67.     out.print("<td>" + taskAttempt.get(Keys.TASK_ATTEMPT_ID) + "</td>");
  68.     out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat,
  69.               taskAttempt.getLong(Keys.START_TIME), 0 ) + "</td>"); 
  70.     if (Values.REDUCE.name().equals(type)) {
  71.       JobHistory.ReduceAttempt reduceAttempt = 
  72.             (JobHistory.ReduceAttempt)taskAttempt; 
  73.       out.print("<td>" + 
  74.                 StringUtils.getFormattedTimeWithDiff(dateFormat, 
  75.                 reduceAttempt.getLong(Keys.SHUFFLE_FINISHED), 
  76.                 reduceAttempt.getLong(Keys.START_TIME)) + "</td>"); 
  77.       out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 
  78.                 reduceAttempt.getLong(Keys.SORT_FINISHED), 
  79.                 reduceAttempt.getLong(Keys.SHUFFLE_FINISHED)) + "</td>"); 
  80.     }
  81.     out.print("<td>"+ StringUtils.getFormattedTimeWithDiff(dateFormat,
  82.               taskAttempt.getLong(Keys.FINISH_TIME), 
  83.               taskAttempt.getLong(Keys.START_TIME) ) + "</td>"); 
  84.     out.print("<td>" + taskAttempt.get(Keys.HOSTNAME) + "</td>");
  85.     out.print("<td>" + taskAttempt.get(Keys.ERROR) + "</td>");
  86.     // Print task log urls
  87.     out.print("<td>");
  88.     String taskLogsUrl = JobHistory.getTaskLogsUrl(taskAttempt);
  89.     if (taskLogsUrl != null) {
  90.     String tailFourKBUrl = taskLogsUrl + "&start=-4097";
  91.     String tailEightKBUrl = taskLogsUrl + "&start=-8193";
  92.     String entireLogUrl = taskLogsUrl + "&all=true";
  93.     out.print("<a href="" + tailFourKBUrl + "">Last 4KB</a><br/>");
  94.     out.print("<a href="" + tailEightKBUrl + "">Last 8KB</a><br/>");
  95.     out.print("<a href="" + entireLogUrl + "">All</a><br/>");
  96.     } else {
  97.         out.print("n/a");
  98.     }
  99.     out.print("</td>");
  100.     out.print("</tr>"); 
  101.   }
  102. %>
  103. </body>
  104. </html>