source: proiecte/HadoopJUnit/hadoop-0.20.1/build/src/org/apache/hadoop/mapred/taskdetails_jsp.java @ 120

Last change on this file since 120 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: 12.2 KB
Line 
1package org.apache.hadoop.mapred;
2
3import javax.servlet.*;
4import javax.servlet.http.*;
5import javax.servlet.jsp.*;
6import javax.servlet.*;
7import javax.servlet.http.*;
8import java.io.*;
9import java.lang.String;
10import java.util.*;
11import org.apache.hadoop.mapred.*;
12import org.apache.hadoop.util.*;
13import java.text.SimpleDateFormat;
14import org.apache.hadoop.util.*;
15
16public final class taskdetails_jsp extends org.apache.jasper.runtime.HttpJspBase
17    implements org.apache.jasper.runtime.JspSourceDependent {
18
19static SimpleDateFormat dateFormat = new SimpleDateFormat(
20      "d-MMM-yyyy HH:mm:ss");
21
22  private static final String PRIVATE_ACTIONS_KEY = "webinterface.private.actions";
23private void printConfirm(JspWriter out, String jobid, String tipid,
24      String taskid, String action) throws IOException {
25    String url = "taskdetails.jsp?jobid=" + jobid + "&tipid=" + tipid
26        + "&taskid=" + taskid;
27    out.print("<html><head><META http-equiv=\"refresh\" content=\"15;URL="
28        + url + "\"></head>" + "<body><h3> Are you sure you want to kill/fail "
29        + taskid + " ?<h3><br><table border=\"0\"><tr><td width=\"100\">"
30        + "<form action=\"" + url + "\" method=\"post\">"
31        + "<input type=\"hidden\" name=\"action\" value=\"" + action + "\" />"
32        + "<input type=\"submit\" name=\"Kill/Fail\" value=\"Kill/Fail\" />"
33        + "</form>"
34        + "</td><td width=\"100\"><form method=\"post\" action=\"" + url
35        + "\"><input type=\"submit\" value=\"Cancel\" name=\"Cancel\""
36        + "/></form></td></tr></table></body></html>");
37  }
38  private static java.util.List _jspx_dependants;
39
40  public Object getDependants() {
41    return _jspx_dependants;
42  }
43
44  public void _jspService(HttpServletRequest request, HttpServletResponse response)
45        throws java.io.IOException, ServletException {
46
47    JspFactory _jspxFactory = null;
48    PageContext pageContext = null;
49    HttpSession session = null;
50    ServletContext application = null;
51    ServletConfig config = null;
52    JspWriter out = null;
53    Object page = this;
54    JspWriter _jspx_out = null;
55    PageContext _jspx_page_context = null;
56
57
58    try {
59      _jspxFactory = JspFactory.getDefaultFactory();
60      response.setContentType("text/html; charset=UTF-8");
61      pageContext = _jspxFactory.getPageContext(this, request, response,
62                        null, true, 8192, true);
63      _jspx_page_context = pageContext;
64      application = pageContext.getServletContext();
65      config = pageContext.getServletConfig();
66      session = pageContext.getSession();
67      out = pageContext.getOut();
68      _jspx_out = out;
69
70      out.write('\n');
71      out.write('\n');
72      out.write('\n');
73
74    JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
75    String jobid = request.getParameter("jobid");
76    String tipid = request.getParameter("tipid");
77    String taskid = request.getParameter("taskid");
78    JobID jobidObj = JobID.forName(jobid);
79    TaskID tipidObj = TaskID.forName(tipid);
80    TaskAttemptID taskidObj = TaskAttemptID.forName(taskid);
81   
82    JobInProgress job = (JobInProgress) tracker.getJob(jobidObj);
83   
84    boolean privateActions = JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY,
85        false);
86    if (privateActions) {
87      String action = request.getParameter("action");
88      if (action != null) {
89        if (action.equalsIgnoreCase("confirm")) {
90          String subAction = request.getParameter("subaction");
91          if (subAction == null)
92            subAction = "fail-task";
93          printConfirm(out, jobid, tipid, taskid, subAction);
94          return;
95        }
96        else if (action.equalsIgnoreCase("kill-task") 
97            && request.getMethod().equalsIgnoreCase("POST")) {
98          tracker.killTask(taskidObj, false);
99          //redirect again so that refreshing the page will not attempt to rekill the task
100          response.sendRedirect("/taskdetails.jsp?" + "&subaction=kill-task"
101              + "&jobid=" + jobid + "&tipid=" + tipid);
102        }
103        else if (action.equalsIgnoreCase("fail-task")
104            && request.getMethod().equalsIgnoreCase("POST")) {
105          tracker.killTask(taskidObj, true);
106          response.sendRedirect("/taskdetails.jsp?" + "&subaction=fail-task"
107              + "&jobid=" + jobid + "&tipid=" + tipid);
108        }
109      }
110    }
111    TaskInProgress tip = null;
112    if (job != null && tipidObj != null) {
113      tip = job.getTaskInProgress(tipidObj);
114    }
115    TaskStatus[] ts = null;
116    if (tip != null) { 
117      ts = tip.getTaskStatuses();
118    }
119    boolean isCleanupOrSetup = false;
120    if ( tip != null) {
121      isCleanupOrSetup = tip.isJobCleanupTask();
122      if (!isCleanupOrSetup) {
123        isCleanupOrSetup = tip.isJobSetupTask();
124      }
125    }
126
127      out.write("\n\n\n<html>\n<head>\n  <link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n  <title>Hadoop Task Details</title>\n</head>\n<body>\n<h1>Job <a href=\"/jobdetails.jsp?jobid=");
128      out.print(jobid);
129      out.write('"');
130      out.write('>');
131      out.print(jobid);
132      out.write("</a></h1>\n\n<hr>\n\n<h2>All Task Attempts</h2>\n<center>\n");
133
134    if (ts == null || ts.length == 0) {
135
136      out.write("\n\t\t<h3>No Task Attempts found</h3>\n");
137
138    } else {
139
140      out.write("\n<table border=2 cellpadding=\"5\" cellspacing=\"2\">\n<tr><td align=\"center\">Task Attempts</td><td>Machine</td><td>Status</td><td>Progress</td><td>Start Time</td> \n  ");
141
142   if (!ts[0].getIsMap() && !isCleanupOrSetup) {
143   
144      out.write("\n<td>Shuffle Finished</td><td>Sort Finished</td>\n  ");
145
146  }
147 
148      out.write("\n<td>Finish Time</td><td>Errors</td><td>Task Logs</td><td>Counters</td><td>Actions</td></tr>\n  ");
149
150    for (int i = 0; i < ts.length; i++) {
151      TaskStatus status = ts[i];
152      String taskTrackerName = status.getTaskTracker();
153      TaskTrackerStatus taskTracker = tracker.getTaskTracker(taskTrackerName);
154      out.print("<tr><td>" + status.getTaskID() + "</td>");
155      String taskAttemptTracker = null;
156      String cleanupTrackerName = null;
157      TaskTrackerStatus cleanupTracker = null;
158      String cleanupAttemptTracker = null;
159      boolean hasCleanupAttempt = false;
160      if (tip != null && tip.isCleanupAttempt(status.getTaskID())) {
161        cleanupTrackerName = tip.machineWhereCleanupRan(status.getTaskID());
162        cleanupTracker = tracker.getTaskTracker(cleanupTrackerName);
163        if (cleanupTracker != null) {
164          cleanupAttemptTracker = "http://" + cleanupTracker.getHost() + ":"
165            + cleanupTracker.getHttpPort();
166        }
167        hasCleanupAttempt = true;
168      }
169      out.print("<td>");
170      if (hasCleanupAttempt) {
171        out.print("Task attempt: ");
172      }
173      if (taskTracker == null) {
174        out.print(taskTrackerName);
175      } else {
176        taskAttemptTracker = "http://" + taskTracker.getHost() + ":"
177          + taskTracker.getHttpPort();
178        out.print("<a href=\"" + taskAttemptTracker + "\">"
179          + tracker.getNode(taskTracker.getHost()) + "</a>");
180      }
181      if (hasCleanupAttempt) {
182        out.print("<br/>Cleanup Attempt: ");
183        if (cleanupAttemptTracker == null ) {
184          out.print(cleanupTrackerName);
185        } else {
186          out.print("<a href=\"" + cleanupAttemptTracker + "\">"
187            + tracker.getNode(cleanupTracker.getHost()) + "</a>");
188        }
189      }
190      out.print("</td>");
191        out.print("<td>" + status.getRunState() + "</td>");
192        out.print("<td>" + StringUtils.formatPercent(status.getProgress(), 2)
193          + ServletUtil.percentageGraph(status.getProgress() * 100f, 80) + "</td>");
194        out.print("<td>"
195          + StringUtils.getFormattedTimeWithDiff(dateFormat, status
196          .getStartTime(), 0) + "</td>");
197        if (!ts[i].getIsMap() && !isCleanupOrSetup) {
198          out.print("<td>"
199          + StringUtils.getFormattedTimeWithDiff(dateFormat, status
200          .getShuffleFinishTime(), status.getStartTime()) + "</td>");
201        out.println("<td>"
202          + StringUtils.getFormattedTimeWithDiff(dateFormat, status
203          .getSortFinishTime(), status.getShuffleFinishTime())
204          + "</td>");
205        }
206        out.println("<td>"
207          + StringUtils.getFormattedTimeWithDiff(dateFormat, status
208          .getFinishTime(), status.getStartTime()) + "</td>");
209
210        out.print("<td><pre>");
211        String [] failures = tracker.getTaskDiagnostics(status.getTaskID());
212        if (failures == null) {
213          out.print("&nbsp;");
214        } else {
215          for(int j = 0 ; j < failures.length ; j++){
216            out.print(failures[j]);
217            if (j < (failures.length - 1)) {
218              out.print("\n-------\n");
219            }
220          }
221        }
222        out.print("</pre></td>");
223        out.print("<td>");
224        String taskLogUrl = null;
225        if (taskTracker != null ) {
226                taskLogUrl = TaskLogServlet.getTaskLogUrl(taskTracker.getHost(),
227                                                        String.valueOf(taskTracker.getHttpPort()),
228                                                        status.getTaskID().toString());
229        }
230        if (hasCleanupAttempt) {
231          out.print("Task attempt: <br/>");
232        }
233        if (taskLogUrl == null) {
234          out.print("n/a");
235        } else {
236          String tailFourKBUrl = taskLogUrl + "&start=-4097";
237          String tailEightKBUrl = taskLogUrl + "&start=-8193";
238          String entireLogUrl = taskLogUrl + "&all=true";
239          out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>");
240          out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>");
241          out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>");
242        }
243        if (hasCleanupAttempt) {
244          out.print("Cleanup attempt: <br/>");
245          taskLogUrl = null;
246          if (cleanupTracker != null ) {
247                taskLogUrl = TaskLogServlet.getTaskLogUrl(cleanupTracker.getHost(),
248                                String.valueOf(cleanupTracker.getHttpPort()),
249                                status.getTaskID().toString());
250          }
251          if (taskLogUrl == null) {
252            out.print("n/a");
253          } else {
254            String tailFourKBUrl = taskLogUrl + "&start=-4097&cleanup=true";
255            String tailEightKBUrl = taskLogUrl + "&start=-8193&cleanup=true";
256            String entireLogUrl = taskLogUrl + "&all=true&cleanup=true";
257            out.print("<a href=\"" + tailFourKBUrl + "\">Last 4KB</a><br/>");
258            out.print("<a href=\"" + tailEightKBUrl + "\">Last 8KB</a><br/>");
259            out.print("<a href=\"" + entireLogUrl + "\">All</a><br/>");
260          }
261        }
262        out.print("</td><td>" + "<a href=\"/taskstats.jsp?jobid=" + jobid
263          + "&tipid=" + tipid + "&taskid=" + status.getTaskID() + "\">"
264          + ((status.getCounters() != null) ? status.getCounters().size() : 0) + "</a></td>");
265        out.print("<td>");
266        if (privateActions
267          && status.getRunState() == TaskStatus.State.RUNNING) {
268        out.print("<a href=\"/taskdetails.jsp?action=confirm"
269          + "&subaction=kill-task" + "&jobid=" + jobid + "&tipid="
270          + tipid + "&taskid=" + status.getTaskID() + "\" > Kill </a>");
271        out.print("<br><a href=\"/taskdetails.jsp?action=confirm"
272          + "&subaction=fail-task" + "&jobid=" + jobid + "&tipid="
273          + tipid + "&taskid=" + status.getTaskID() + "\" > Fail </a>");
274        }
275        else
276          out.print("<pre>&nbsp;</pre>");
277        out.println("</td></tr>");
278      }
279 
280      out.write("\n</table>\n</center>\n\n");
281
282      if (ts[0].getIsMap() && !isCleanupOrSetup) {
283
284      out.write("\n<h3>Input Split Locations</h3>\n<table border=2 cellpadding=\"5\" cellspacing=\"2\">\n");
285
286        for (String split: StringUtils.split(tracker.getTip(
287                                         tipidObj).getSplitNodes())) {
288          out.println("<tr><td>" + split + "</td></tr>");
289        }
290
291      out.write("\n</table>\n");
292   
293      }
294    }
295
296      out.write("\n\n<hr>\n<a href=\"jobdetails.jsp?jobid=");
297      out.print(jobid);
298      out.write("\">Go back to the job</a><br>\n<a href=\"jobtracker.jsp\">Go back to JobTracker</a><br>\n");
299
300out.println(ServletUtil.htmlFooter());
301
302      out.write('\n');
303    } catch (Throwable t) {
304      if (!(t instanceof SkipPageException)){
305        out = _jspx_out;
306        if (out != null && out.getBufferSize() != 0)
307          out.clearBuffer();
308        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
309      }
310    } finally {
311      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
312    }
313  }
314}
Note: See TracBrowser for help on using the repository browser.