source: proiecte/HadoopJUnit/hadoop-0.20.1/src/webapps/job/jobtasks.jsp @ 155

Last change on this file since 155 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 5.5 KB
Line 
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.util.*"
7  import="org.apache.hadoop.mapred.*"
8  import="org.apache.hadoop.util.*"
9  import="java.lang.Integer"
10  import="java.text.SimpleDateFormat"
11%>
12<%! static SimpleDateFormat dateFormat = new SimpleDateFormat("d-MMM-yyyy HH:mm:ss") ; %>
13<%
14  JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
15  String trackerName = 
16           StringUtils.simpleHostname(tracker.getJobTrackerMachine());
17  String jobid = request.getParameter("jobid");
18  if (jobid == null) {
19    out.println("<h2>Missing 'jobid'!</h2>");
20    return;
21  }
22  String type = request.getParameter("type");
23  String pagenum = request.getParameter("pagenum");
24  String state = request.getParameter("state");
25  state = (state!=null) ? state : "all";
26  int pnum = Integer.parseInt(pagenum);
27  int next_page = pnum+1;
28  int numperpage = 2000;
29  JobID jobidObj = JobID.forName(jobid);
30  JobInProgress job = (JobInProgress) tracker.getJob(jobidObj);
31  JobProfile profile = (job != null) ? (job.getProfile()) : null;
32  JobStatus status = (job != null) ? (job.getStatus()) : null;
33  TaskReport[] reports = null;
34  int start_index = (pnum - 1) * numperpage;
35  int end_index = start_index + numperpage;
36  int report_len = 0;
37  if ("map".equals(type)) {
38    reports = (job != null) ? tracker.getMapTaskReports(jobidObj) : null;
39  } else if ("reduce".equals(type)) {
40    reports = (job != null) ? tracker.getReduceTaskReports(jobidObj) : null;
41  } else if ("cleanup".equals(type)) {
42    reports = (job != null) ? tracker.getCleanupTaskReports(jobidObj) : null;
43  } else if ("setup".equals(type)) {
44    reports = (job != null) ? tracker.getSetupTaskReports(jobidObj) : null;
45  }
46%>
47
48<html>
49  <head>
50    <title>Hadoop <%=type%> task list for <%=jobid%> on <%=trackerName%></title>
51    <link rel="stylesheet" type="text/css" href="/static/hadoop.css">
52  </head>
53<body>
54<h1>Hadoop <%=type%> task list for
55<a href="jobdetails.jsp?jobid=<%=jobid%>"><%=jobid%></a> on
56<a href="jobtracker.jsp"><%=trackerName%></a></h1>
57<%
58    if (job == null) {
59    out.print("<b>Job " + jobid + " not found.</b><br>\n");
60    return;
61  }
62  // Filtering the reports if some filter is specified
63  if (!"all".equals(state)) {
64    List<TaskReport> filteredReports = new ArrayList<TaskReport>();
65    for (int i = 0; i < reports.length; ++i) {
66      if (("completed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.COMPLETE) 
67          || ("running".equals(state) && reports[i].getCurrentStatus() == TIPStatus.RUNNING) 
68          || ("killed".equals(state) && reports[i].getCurrentStatus() == TIPStatus.KILLED) 
69          || ("pending".equals(state)  && reports[i].getCurrentStatus() == TIPStatus.PENDING)) {
70        filteredReports.add(reports[i]);
71      }
72    }
73    // using filtered reports instead of all the reports
74    reports = filteredReports.toArray(new TaskReport[0]);
75    filteredReports = null;
76  }
77  report_len = reports.length;
78 
79  if (report_len <= start_index) {
80    out.print("<b>No such tasks</b>");
81  } else {
82    out.print("<hr>");
83    out.print("<h2>" + Character.toUpperCase(state.charAt(0)) 
84              + state.substring(1).toLowerCase() + " Tasks</h2>");
85    out.print("<center>");
86    out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">");
87    out.print("<tr><td align=\"center\">Task</td><td>Complete</td><td>Status</td>" +
88              "<td>Start Time</td><td>Finish Time</td><td>Errors</td><td>Counters</td></tr>");
89    if (end_index > report_len){
90        end_index = report_len;
91    }
92    for (int i = start_index ; i < end_index; i++) {
93          TaskReport report = reports[i];
94          out.print("<tr><td><a href=\"taskdetails.jsp?jobid=" + jobid + 
95                    "&tipid=" + report.getTaskID() + "\">"  + 
96                    report.getTaskID() + "</a></td>");
97         out.print("<td>" + StringUtils.formatPercent(report.getProgress(),2) +
98                           ServletUtil.percentageGraph(report.getProgress() * 100f, 80) + "</td>");
99         out.print("<td>"  + report.getState() + "<br/></td>");
100         out.println("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, report.getStartTime(),0) + "<br/></td>");
101         out.println("<td>" + StringUtils.getFormattedTimeWithDiff(dateFormat, 
102             report.getFinishTime(), report.getStartTime()) + "<br/></td>");
103         String[] diagnostics = report.getDiagnostics();
104         out.print("<td><pre>");
105         for (int j = 0; j < diagnostics.length ; j++) {
106             out.println(diagnostics[j]);
107         }
108         out.println("</pre><br/></td>");
109         out.println("<td>" + 
110             "<a href=\"taskstats.jsp?jobid=" + jobid + 
111             "&tipid=" + report.getTaskID() +
112             "\">" + report.getCounters().size() +
113             "</a></td></tr>");
114    }
115    out.print("</table>");
116    out.print("</center>");
117  }
118  if (end_index < report_len) {
119    out.print("<div style=\"text-align:right\">" + 
120              "<a href=\"jobtasks.jsp?jobid="+ jobid + "&type=" + type +
121              "&pagenum=" + next_page + "&state=" + state +
122              "\">" + "Next" + "</a></div>");
123  }
124  if (start_index != 0) {
125      out.print("<div style=\"text-align:right\">" + 
126                "<a href=\"jobtasks.jsp?jobid="+ jobid + "&type=" + type +
127                "&pagenum=" + (pnum -1) + "&state=" + state + "\">" + "Prev" + "</a></div>");
128  }
129%>
130
131<hr>
132<a href="jobtracker.jsp">Go back to JobTracker</a><br>
133<%
134out.println(ServletUtil.htmlFooter());
135%>
Note: See TracBrowser for help on using the repository browser.