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

网格计算

开发平台:

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="logFile" value="<%=request.getParameter("logFile") %>"/>
  14. </jsp:include>
  15. <%!
  16.   private static SimpleDateFormat dateFormat =
  17.                                     new SimpleDateFormat("d/MM HH:mm:ss") ; 
  18. %>
  19. <%
  20.   String jobid = request.getParameter("jobid");
  21.   String logFile = request.getParameter("logFile");
  22.   String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile);
  23.   String taskStatus = request.getParameter("status"); 
  24.   String taskType = request.getParameter("taskType"); 
  25.   
  26.   JobHistory.JobInfo job = (JobHistory.JobInfo)request.
  27.                             getSession().getAttribute("job");
  28.   Map<String, JobHistory.Task> tasks = job.getAllTasks(); 
  29. %>
  30. <html>
  31. <body>
  32. <h2><%=taskStatus%> <%=taskType %> task list for <a href="jobdetailshistory.jsp?jobid=<%=jobid%>&&logFile=<%=encodedLogFileName%>"><%=jobid %> </a></h2>
  33. <center>
  34. <table border="2" cellpadding="5" cellspacing="2">
  35. <tr><td>Task Id</td><td>Start Time</td><td>Finish Time<br/></td><td>Error</td></tr>
  36. <%
  37.   for (JobHistory.Task task : tasks.values()) {
  38.     if (taskType.equals(task.get(Keys.TASK_TYPE))){
  39.       Map <String, TaskAttempt> taskAttempts = task.getTaskAttempts();
  40.       for (JobHistory.TaskAttempt taskAttempt : taskAttempts.values()) {
  41.         if (taskStatus.equals(taskAttempt.get(Keys.TASK_STATUS)) || 
  42.           taskStatus.equals("all")){
  43.           printTask(jobid, encodedLogFileName, taskAttempt, out); 
  44.         }
  45.       }
  46.     }
  47.   }
  48. %>
  49. </table>
  50. <%!
  51.   private void printTask(String jobid, String logFile,
  52.     JobHistory.TaskAttempt attempt, JspWriter out) throws IOException{
  53.     out.print("<tr>"); 
  54.     out.print("<td>" + "<a href="taskdetailshistory.jsp?jobid=" + jobid + 
  55.           "&logFile="+ logFile +"&taskid="+attempt.get(Keys.TASKID)+"">" +
  56.           attempt.get(Keys.TASKID) + "</a></td>");
  57.     out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 
  58.           attempt.getLong(Keys.START_TIME), 0 ) + "</td>");
  59.     out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 
  60.           attempt.getLong(Keys.FINISH_TIME),
  61.           attempt.getLong(Keys.START_TIME) ) + "</td>");
  62.     out.print("<td>" + attempt.get(Keys.ERROR) + "</td>");
  63.     out.print("</tr>"); 
  64.   }
  65. %>
  66. </center>
  67. </body>
  68. </html>