1<%! 2/** 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15%> 16<%@ page 17 contentType="text/html; charset=UTF-8" 18 import="javax.servlet.http.*" 19 import="java.io.*" 20 import="java.util.*" 21 import="org.apache.hadoop.http.HtmlQuoting" 22 import="org.apache.hadoop.mapred.*" 23 import="org.apache.hadoop.fs.*" 24 import="org.apache.hadoop.util.*" 25 import="java.text.SimpleDateFormat" 26 import="org.apache.hadoop.mapred.JobHistory.*" 27%> 28 29<%! 30 private static SimpleDateFormat dateFormat = 31 new SimpleDateFormat("d/MM HH:mm:ss") ; 32%> 33<%! private static final long serialVersionUID = 1L; 34%> 35 36<% 37 String logFile = request.getParameter("logFile"); 38 String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile); 39 String jobid = JSPUtil.getJobID(new Path(logFile).getName()); 40 String taskStatus = request.getParameter("status"); 41 String taskType = request.getParameter("taskType"); 42 43 FileSystem fs = (FileSystem) application.getAttribute("fileSys"); 44 JobConf jobConf = (JobConf) application.getAttribute("jobConf"); 45 ACLsManager aclsManager = (ACLsManager) application.getAttribute("aclManager"); 46 JobHistory.JobInfo job = JSPUtil.checkAccessAndGetJobInfo(request, 47 response, jobConf, aclsManager, fs, new Path(logFile)); 48 if (job == null) { 49 return; 50 } 51 Map<String, JobHistory.Task> tasks = job.getAllTasks(); 52%> 53<!DOCTYPE html> 54<html> 55<body> 56<h2><%=taskStatus%> <%=taskType %> task list for <a href="jobdetailshistory.jsp?logFile=<%=encodedLogFileName%>"><%=jobid %> </a></h2> 57<center> 58<table border="2" cellpadding="5" cellspacing="2"> 59<tr><td>Task Id</td><td>Start Time</td><td>Finish Time<br/></td><td>Error</td></tr> 60<% 61 for (JobHistory.Task task : tasks.values()) { 62 if (taskType.equals(task.get(Keys.TASK_TYPE))){ 63 Map <String, TaskAttempt> taskAttempts = task.getTaskAttempts(); 64 for (JobHistory.TaskAttempt taskAttempt : taskAttempts.values()) { 65 if (taskStatus.equals(taskAttempt.get(Keys.TASK_STATUS)) || 66 taskStatus.equals("all")){ 67 printTask(encodedLogFileName, taskAttempt, out); 68 } 69 } 70 } 71 } 72%> 73</table> 74<%! 75 private void printTask(String logFile, 76 JobHistory.TaskAttempt attempt, JspWriter out) throws IOException{ 77 out.print("<tr>"); 78 out.print("<td>" + "<a href=\"taskdetailshistory.jsp?logFile="+ logFile 79 +"&tipid="+attempt.get(Keys.TASKID)+"\">" + 80 attempt.get(Keys.TASKID) + "</a></td>"); 81 out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 82 attempt.getLong(Keys.START_TIME), 0 ) + "</td>"); 83 out.print("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 84 attempt.getLong(Keys.FINISH_TIME), 85 attempt.getLong(Keys.START_TIME) ) + "</td>"); 86 out.print("<td>" + HtmlQuoting.quoteHtmlChars(attempt.get(Keys.ERROR)) + 87 "</td>"); 88 out.print("</tr>"); 89 } 90%> 91</center> 92</body> 93</html> 94