%!
/**
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
%>
<%@ page
contentType="text/html; charset=UTF-8"
import="javax.servlet.http.*"
import="java.io.*"
import="java.util.*"
import="org.apache.hadoop.http.HtmlQuoting"
import="org.apache.hadoop.mapred.*"
import="org.apache.hadoop.fs.*"
import="org.apache.hadoop.util.*"
import="java.text.SimpleDateFormat"
import="org.apache.hadoop.mapred.JobHistory.*"
%>
<%! private static SimpleDateFormat dateFormat = new SimpleDateFormat("d/MM HH:mm:ss") ; %>
<%! private static final long serialVersionUID = 1L;
%>
<%
String logFile = request.getParameter("logFile");
String tipid = request.getParameter("tipid");
if (logFile == null || tipid == null) {
out.println("Missing job!!");
return;
}
String encodedLogFileName = JobHistory.JobInfo.encodeJobHistoryFilePath(logFile);
String jobid = JSPUtil.getJobID(new Path(encodedLogFileName).getName());
FileSystem fs = (FileSystem) application.getAttribute("fileSys");
JobConf jobConf = (JobConf) application.getAttribute("jobConf");
ACLsManager aclsManager = (ACLsManager) application.getAttribute("aclManager");
JobHistory.JobInfo job = JSPUtil.checkAccessAndGetJobInfo(request,
response, jobConf, aclsManager, fs, new Path(logFile));
if (job == null) {
return;
}
JobHistory.Task task = job.getAllTasks().get(tipid);
String type = task.get(Keys.TASK_TYPE);
%>
<%=tipid %> attempts for <%=jobid %>
Task Id | Start Time |
<%
if (Values.REDUCE.name().equals(type)) {
%>
Shuffle Finished | Sort Finished |
<%
}
%>
Finish Time | Host | Error | Task Logs |
Counters |
<%
for (JobHistory.TaskAttempt attempt : task.getTaskAttempts().values()) {
printTaskAttempt(attempt, type, out, encodedLogFileName);
}
%>
<%
if (Values.MAP.name().equals(type)) {
%>
Input Split Locations
<%
for (String split : StringUtils.split(task.get(Keys.SPLITS)))
{
out.println("" + split + " |
");
}
%>
<%
}
%>
<%!
private void printTaskAttempt(JobHistory.TaskAttempt taskAttempt,
String type, JspWriter out,
String logFile)
throws Exception {
out.print("");
out.print("" + taskAttempt.get(Keys.TASK_ATTEMPT_ID) + " | ");
out.print("" + StringUtils.getFormattedTimeWithDiff(dateFormat,
taskAttempt.getLong(Keys.START_TIME), 0 ) + " | ");
if (Values.REDUCE.name().equals(type)) {
JobHistory.ReduceAttempt reduceAttempt =
(JobHistory.ReduceAttempt)taskAttempt;
out.print("" +
StringUtils.getFormattedTimeWithDiff(dateFormat,
reduceAttempt.getLong(Keys.SHUFFLE_FINISHED),
reduceAttempt.getLong(Keys.START_TIME)) + " | ");
out.print("" + StringUtils.getFormattedTimeWithDiff(dateFormat,
reduceAttempt.getLong(Keys.SORT_FINISHED),
reduceAttempt.getLong(Keys.SHUFFLE_FINISHED)) + " | ");
}
out.print(""+ StringUtils.getFormattedTimeWithDiff(dateFormat,
taskAttempt.getLong(Keys.FINISH_TIME),
taskAttempt.getLong(Keys.START_TIME) ) + " | ");
out.print("" + taskAttempt.get(Keys.HOSTNAME) + " | ");
out.print("" + HtmlQuoting.quoteHtmlChars(taskAttempt.get(Keys.ERROR)) +
" | ");
// Print task log urls
out.print("");
String taskLogsUrl = JobHistory.getTaskLogsUrl(taskAttempt);
if (taskLogsUrl != null) {
String tailFourKBUrl = taskLogsUrl + "&start=-4097";
String tailEightKBUrl = taskLogsUrl + "&start=-8193";
String entireLogUrl = taskLogsUrl + "&all=true";
out.print("Last 4KB ");
out.print("Last 8KB ");
out.print("All ");
} else {
out.print("n/a");
}
out.print(" | ");
Counters counters =
Counters.fromEscapedCompactString(taskAttempt.get(Keys.COUNTERS));
if (counters != null) {
TaskAttemptID attemptId =
TaskAttemptID.forName(taskAttempt.get(Keys.TASK_ATTEMPT_ID));
TaskID tipid = attemptId.getTaskID();
org.apache.hadoop.mapreduce.JobID jobId = tipid.getJobID();
out.print(""
+ ""
+ counters.size() + " | ");
} else {
out.print(" | ");
}
out.print("
");
}
%>