source: proiecte/HadoopJUnit/hadoop-0.20.1/build/src/org/apache/hadoop/mapred/jobdetails_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: 18.0 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.text.*;
10import java.util.*;
11import java.text.DecimalFormat;
12import org.apache.hadoop.mapred.*;
13import org.apache.hadoop.util.*;
14import org.apache.hadoop.mapred.TaskGraphServlet;
15
16public final class jobdetails_jsp extends org.apache.jasper.runtime.HttpJspBase
17    implements org.apache.jasper.runtime.JspSourceDependent {
18
19
20  private static final String PRIVATE_ACTIONS_KEY
21                = "webinterface.private.actions";
22 
23  private void printTaskSummary(JspWriter out,
24                                String jobId,
25                                String kind,
26                                double completePercent,
27                                TaskInProgress[] tasks
28                               ) throws IOException {
29    int totalTasks = tasks.length;
30    int runningTasks = 0;
31    int finishedTasks = 0;
32    int killedTasks = 0;
33    int failedTaskAttempts = 0;
34    int killedTaskAttempts = 0;
35    for(int i=0; i < totalTasks; ++i) {
36      TaskInProgress task = tasks[i];
37      if (task.isComplete()) {
38        finishedTasks += 1;
39      } else if (task.isRunning()) {
40        runningTasks += 1;
41      } else if (task.wasKilled()) {
42        killedTasks += 1;
43      }
44      failedTaskAttempts += task.numTaskFailures();
45      killedTaskAttempts += task.numKilledTasks();
46    }
47    int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; 
48    out.print("<tr><th><a href=\"jobtasks.jsp?jobid=" + jobId + 
49              "&type="+ kind + "&pagenum=1\">" + kind + 
50              "</a></th><td align=\"right\">" + 
51              StringUtils.formatPercent(completePercent, 2) +
52              ServletUtil.percentageGraph((int)(completePercent * 100), 80) +
53              "</td><td align=\"right\">" + 
54              totalTasks + 
55              "</td><td align=\"right\">" + 
56              ((pendingTasks > 0) 
57               ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + 
58                 "&pagenum=1" + "&state=pending\">" + pendingTasks + "</a>"
59               : "0") + 
60              "</td><td align=\"right\">" + 
61              ((runningTasks > 0) 
62               ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + 
63                 "&pagenum=1" + "&state=running\">" + runningTasks + "</a>" 
64               : "0") + 
65              "</td><td align=\"right\">" + 
66              ((finishedTasks > 0) 
67               ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + 
68                "&pagenum=1" + "&state=completed\">" + finishedTasks + "</a>" 
69               : "0") + 
70              "</td><td align=\"right\">" + 
71              ((killedTasks > 0) 
72               ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind +
73                "&pagenum=1" + "&state=killed\">" + killedTasks + "</a>"
74               : "0") + 
75              "</td><td align=\"right\">" + 
76              ((failedTaskAttempts > 0) ? 
77                  ("<a href=\"jobfailures.jsp?jobid=" + jobId + 
78                   "&kind=" + kind + "&cause=failed\">" + failedTaskAttempts + 
79                   "</a>") : 
80                  "0"
81                  ) + 
82              " / " +
83              ((killedTaskAttempts > 0) ? 
84                  ("<a href=\"jobfailures.jsp?jobid=" + jobId + 
85                   "&kind=" + kind + "&cause=killed\">" + killedTaskAttempts + 
86                   "</a>") : 
87                  "0"
88                  ) + 
89              "</td></tr>\n");
90  }
91
92  private void printJobLevelTaskSummary(JspWriter out,
93                                String jobId,
94                                String kind,
95                                TaskInProgress[] tasks
96                               ) throws IOException {
97    int totalTasks = tasks.length;
98    int runningTasks = 0;
99    int finishedTasks = 0;
100    int killedTasks = 0;
101    for(int i=0; i < totalTasks; ++i) {
102      TaskInProgress task = tasks[i];
103      if (task.isComplete()) {
104        finishedTasks += 1;
105      } else if (task.isRunning()) {
106        runningTasks += 1;
107      } else if (task.isFailed()) {
108        killedTasks += 1;
109      }
110    }
111    int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; 
112    out.print(((runningTasks > 0) 
113               ? "<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + 
114                 "&pagenum=1" + "&state=running\">" + " Running" + 
115                 "</a>" 
116               : ((pendingTasks > 0) ? " Pending" :
117                 ((finishedTasks > 0) 
118               ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind + 
119                "&pagenum=1" + "&state=completed\">" + " Successful"
120                 + "</a>" 
121               : ((killedTasks > 0) 
122               ?"<a href=\"jobtasks.jsp?jobid=" + jobId + "&type="+ kind +
123                "&pagenum=1" + "&state=killed\">" + " Failed" 
124                + "</a>" : "None")))));
125  }
126 
127  private void printConfirm(JspWriter out, String jobId) throws IOException{
128    String url = "jobdetails.jsp?jobid=" + jobId;
129    out.print("<html><head><META http-equiv=\"refresh\" content=\"15;URL="
130        + url+"\"></head>"
131        + "<body><h3> Are you sure you want to kill " + jobId
132        + " ?<h3><br><table border=\"0\"><tr><td width=\"100\">"
133        + "<form action=\"" + url + "\" method=\"post\">"
134        + "<input type=\"hidden\" name=\"action\" value=\"kill\" />"
135        + "<input type=\"submit\" name=\"kill\" value=\"Kill\" />"
136        + "</form>"
137        + "</td><td width=\"100\"><form method=\"post\" action=\"" + url
138        + "\"><input type=\"submit\" value=\"Cancel\" name=\"Cancel\""
139        + "/></form></td></tr></table></body></html>");
140  }
141 
142
143  private static java.util.List _jspx_dependants;
144
145  public Object getDependants() {
146    return _jspx_dependants;
147  }
148
149  public void _jspService(HttpServletRequest request, HttpServletResponse response)
150        throws java.io.IOException, ServletException {
151
152    JspFactory _jspxFactory = null;
153    PageContext pageContext = null;
154    HttpSession session = null;
155    ServletContext application = null;
156    ServletConfig config = null;
157    JspWriter out = null;
158    Object page = this;
159    JspWriter _jspx_out = null;
160    PageContext _jspx_page_context = null;
161
162
163    try {
164      _jspxFactory = JspFactory.getDefaultFactory();
165      response.setContentType("text/html; charset=UTF-8");
166      pageContext = _jspxFactory.getPageContext(this, request, response,
167                        null, true, 8192, true);
168      _jspx_page_context = pageContext;
169      application = pageContext.getServletContext();
170      config = pageContext.getServletConfig();
171      session = pageContext.getSession();
172      out = pageContext.getOut();
173      _jspx_out = out;
174
175      out.write('\n');
176      out.write('\n');
177
178  JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
179  String trackerName = 
180           StringUtils.simpleHostname(tracker.getJobTrackerMachine());
181
182      out.write('\n');
183      out.write("       \n");
184   
185    String jobId = request.getParameter("jobid"); 
186    String refreshParam = request.getParameter("refresh");
187    if (jobId == null) {
188      out.println("<h2>Missing 'jobid'!</h2>");
189      return;
190    }
191   
192    int refresh = 60; // refresh every 60 seconds by default
193    if (refreshParam != null) {
194        try {
195            refresh = Integer.parseInt(refreshParam);
196        }
197        catch (NumberFormatException ignored) {
198        }
199    }
200    JobID jobIdObj = JobID.forName(jobId);
201    JobInProgress job = (JobInProgress) tracker.getJob(jobIdObj);
202   
203    String action = request.getParameter("action");
204    if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) && 
205        "changeprio".equalsIgnoreCase(action) 
206        && request.getMethod().equalsIgnoreCase("POST")) {
207      tracker.setJobPriority(jobIdObj, 
208                             JobPriority.valueOf(request.getParameter("prio")));
209    }
210   
211    if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) {
212        action = request.getParameter("action");
213            if(action!=null && action.equalsIgnoreCase("confirm")) {
214              printConfirm(out, jobId);
215            return;
216            }
217            else if(action != null && action.equalsIgnoreCase("kill") && 
218                request.getMethod().equalsIgnoreCase("POST")) {
219              tracker.killJob(jobIdObj);
220            }
221    }
222
223      out.write("\n\n\n<html>\n<head>\n  ");
224 
225  if (refresh != 0) {
226     
227      out.write("\n      <meta http-equiv=\"refresh\" content=\"");
228      out.print(refresh);
229      out.write("\">\n      ");
230
231  }
232 
233      out.write("\n<title>Hadoop ");
234      out.print(jobId);
235      out.write(" on ");
236      out.print(trackerName);
237      out.write("</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n</head>\n<body>\n<h1>Hadoop ");
238      out.print(jobId);
239      out.write(" on <a href=\"jobtracker.jsp\">");
240      out.print(trackerName);
241      out.write("</a></h1>\n\n");
242 
243    if (job == null) {
244      out.print("<b>Job " + jobId + " not found.</b><br>\n");
245      return;
246    }
247    JobProfile profile = job.getProfile();
248    JobStatus status = job.getStatus();
249    int runState = status.getRunState();
250    int flakyTaskTrackers = job.getNoOfBlackListedTrackers();
251    out.print("<b>User:</b> " + profile.getUser() + "<br>\n");
252    out.print("<b>Job Name:</b> " + profile.getJobName() + "<br>\n");
253    out.print("<b>Job File:</b> <a href=\"jobconf.jsp?jobid=" + jobId + "\">" 
254              + profile.getJobFile() + "</a><br>\n");
255    out.print("<b>Job Setup:</b>");
256    printJobLevelTaskSummary(out, jobId, "setup", job.getSetupTasks());
257    out.print("<br>\n");
258    if (runState == JobStatus.RUNNING) {
259      out.print("<b>Status:</b> Running<br>\n");
260      out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
261      out.print("<b>Running for:</b> " + StringUtils.formatTimeDiff(
262          System.currentTimeMillis(), job.getStartTime()) + "<br>\n");
263    } else {
264      if (runState == JobStatus.SUCCEEDED) {
265        out.print("<b>Status:</b> Succeeded<br>\n");
266        out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
267        out.print("<b>Finished at:</b> " + new Date(job.getFinishTime()) +
268                  "<br>\n");
269        out.print("<b>Finished in:</b> " + StringUtils.formatTimeDiff(
270            job.getFinishTime(), job.getStartTime()) + "<br>\n");
271      } else if (runState == JobStatus.FAILED) {
272        out.print("<b>Status:</b> Failed<br>\n");
273        out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
274        out.print("<b>Failed at:</b> " + new Date(job.getFinishTime()) +
275                  "<br>\n");
276        out.print("<b>Failed in:</b> " + StringUtils.formatTimeDiff(
277            job.getFinishTime(), job.getStartTime()) + "<br>\n");
278      } else if (runState == JobStatus.KILLED) {
279        out.print("<b>Status:</b> Killed<br>\n");
280        out.print("<b>Started at:</b> " + new Date(job.getStartTime()) + "<br>\n");
281        out.print("<b>Killed at:</b> " + new Date(job.getFinishTime()) +
282                  "<br>\n");
283        out.print("<b>Killed in:</b> " + StringUtils.formatTimeDiff(
284            job.getFinishTime(), job.getStartTime()) + "<br>\n");
285      }
286    }
287    out.print("<b>Job Cleanup:</b>");
288    printJobLevelTaskSummary(out, jobId, "cleanup", job.getCleanupTasks());
289    out.print("<br>\n");
290    if (flakyTaskTrackers > 0) {
291      out.print("<b>Black-listed TaskTrackers:</b> " + 
292          "<a href=\"jobblacklistedtrackers.jsp?jobid=" + jobId + "\">" +
293          flakyTaskTrackers + "</a><br>\n");
294    }
295    if (job.getSchedulingInfo() != null) {
296      out.print("<b>Job Scheduling information: </b>" +
297          job.getSchedulingInfo().toString() +"\n");
298    }
299    out.print("<hr>\n");
300    out.print("<table border=2 cellpadding=\"5\" cellspacing=\"2\">");
301    out.print("<tr><th>Kind</th><th>% Complete</th><th>Num Tasks</th>" +
302              "<th>Pending</th><th>Running</th><th>Complete</th>" +
303              "<th>Killed</th>" +
304              "<th><a href=\"jobfailures.jsp?jobid=" + jobId + 
305              "\">Failed/Killed<br>Task Attempts</a></th></tr>\n");
306    printTaskSummary(out, jobId, "map", status.mapProgress(), 
307                     job.getMapTasks());
308    printTaskSummary(out, jobId, "reduce", status.reduceProgress(),
309                     job.getReduceTasks());
310    out.print("</table>\n");
311   
312   
313      out.write("\n    <p/>\n    <table border=2 cellpadding=\"5\" cellspacing=\"2\">\n    <tr>\n      <th><br/></th>\n      <th>Counter</th>\n      <th>Map</th>\n      <th>Reduce</th>\n      <th>Total</th>\n    </tr>\n    ");
314
315    Counters mapCounters = job.getMapCounters();
316    Counters reduceCounters = job.getReduceCounters();
317    Counters totalCounters = job.getCounters();
318   
319    for (String groupName : totalCounters.getGroupNames()) {
320      Counters.Group totalGroup = totalCounters.getGroup(groupName);
321      Counters.Group mapGroup = mapCounters.getGroup(groupName);
322      Counters.Group reduceGroup = reduceCounters.getGroup(groupName);
323     
324      Format decimal = new DecimalFormat();
325     
326      boolean isFirst = true;
327      for (Counters.Counter counter : totalGroup) {
328        String name = counter.getDisplayName();
329        String mapValue = decimal.format(mapGroup.getCounter(name));
330        String reduceValue = decimal.format(reduceGroup.getCounter(name));
331        String totalValue = decimal.format(counter.getCounter());
332       
333      out.write("\n        <tr>\n          ");
334
335          if (isFirst) {
336            isFirst = false;
337           
338      out.write("\n            <td rowspan=\"");
339      out.print(totalGroup.size());
340      out.write('"');
341      out.write('>');
342      out.print(totalGroup.getDisplayName());
343      out.write("</td>\n            ");
344
345          }
346         
347      out.write("\n          <td>");
348      out.print(name);
349      out.write("</td>\n          <td align=\"right\">");
350      out.print(mapValue);
351      out.write("</td>\n          <td align=\"right\">");
352      out.print(reduceValue);
353      out.write("</td>\n          <td align=\"right\">");
354      out.print(totalValue);
355      out.write("</td>\n        </tr>\n        ");
356
357      }
358    }
359   
360      out.write("\n    </table>\n\n<hr>Map Completion Graph - \n");
361
362if("off".equals(request.getParameter("map.graph"))) {
363  session.setAttribute("map.graph", "off");
364} else if("on".equals(request.getParameter("map.graph"))){
365  session.setAttribute("map.graph", "on");
366}
367if("off".equals(request.getParameter("reduce.graph"))) {
368  session.setAttribute("reduce.graph", "off");
369} else if("on".equals(request.getParameter("reduce.graph"))){
370  session.setAttribute("reduce.graph", "on");
371}
372
373if("off".equals(session.getAttribute("map.graph"))) { 
374      out.write("\n<a href=\"/jobdetails.jsp?jobid=");
375      out.print(jobId);
376      out.write("&refresh=");
377      out.print(refresh);
378      out.write("&map.graph=on\" > open </a>\n");
379} else { 
380      out.write(" \n<a href=\"/jobdetails.jsp?jobid=");
381      out.print(jobId);
382      out.write("&refresh=");
383      out.print(refresh);
384      out.write("&map.graph=off\" > close </a>\n<br><embed src=\"/taskgraph?type=map&jobid=");
385      out.print(jobId);
386      out.write("\" \n       width=\"");
387      out.print(TaskGraphServlet.width + 2 * TaskGraphServlet.xmargin);
388      out.write("\" \n       height=\"");
389      out.print(TaskGraphServlet.height + 3 * TaskGraphServlet.ymargin);
390      out.write("\"\n       style=\"width:100%\" type=\"image/svg+xml\" pluginspage=\"http://www.adobe.com/svg/viewer/install/\" />\n");
391}
392      out.write('\n');
393      out.write('\n');
394if(job.getReduceTasks().length > 0) { 
395      out.write("\n<hr>Reduce Completion Graph -\n");
396if("off".equals(session.getAttribute("reduce.graph"))) { 
397      out.write("\n<a href=\"/jobdetails.jsp?jobid=");
398      out.print(jobId);
399      out.write("&refresh=");
400      out.print(refresh);
401      out.write("&reduce.graph=on\" > open </a>\n");
402} else { 
403      out.write(" \n<a href=\"/jobdetails.jsp?jobid=");
404      out.print(jobId);
405      out.write("&refresh=");
406      out.print(refresh);
407      out.write("&reduce.graph=off\" > close </a>\n \n <br><embed src=\"/taskgraph?type=reduce&jobid=");
408      out.print(jobId);
409      out.write("\" \n       width=\"");
410      out.print(TaskGraphServlet.width + 2 * TaskGraphServlet.xmargin);
411      out.write("\" \n       height=\"");
412      out.print(TaskGraphServlet.height + 3 * TaskGraphServlet.ymargin);
413      out.write("\" \n       style=\"width:100%\" type=\"image/svg+xml\" pluginspage=\"http://www.adobe.com/svg/viewer/install/\" />\n");
414} }
415      out.write("\n\n<hr>\n");
416 if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { 
417      out.write("\n  <table border=\"0\"> <tr> <td>\n  Change priority from ");
418      out.print(job.getPriority());
419      out.write(" to:\n  <form action=\"jobdetails.jsp\" method=\"post\">\n  <input type=\"hidden\" name=\"action\" value=\"changeprio\"/>\n  <input type=\"hidden\" name=\"jobid\" value=\"");
420      out.print(jobId);
421      out.write("\"/>\n  </td><td> <select name=\"prio\"> \n  ");
422
423    JobPriority jobPrio = job.getPriority();
424    for (JobPriority prio : JobPriority.values()) {
425      if(jobPrio != prio) {
426       
427      out.write(" <option value=");
428      out.print(prio);
429      out.write('>');
430      out.print(prio);
431      out.write("</option> ");
432
433      }
434    }
435 
436      out.write("\n  </select> </td><td><input type=\"submit\" value=\"Submit\"> </form></td></tr> </table>\n");
437 } 
438      out.write("\n\n<table border=\"0\"> <tr>\n    \n");
439 if(JSPUtil.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) 
440        && runState == JobStatus.RUNNING) { 
441      out.write("\n\t<br/><a href=\"jobdetails.jsp?action=confirm&jobid=");
442      out.print(jobId);
443      out.write("\"> Kill this job </a>\n");
444 } 
445      out.write("\n\n<hr>\n\n<hr>\n<a href=\"jobtracker.jsp\">Go back to JobTracker</a><br>\n");
446
447out.println(ServletUtil.htmlFooter());
448
449      out.write('\n');
450    } catch (Throwable t) {
451      if (!(t instanceof SkipPageException)){
452        out = _jspx_out;
453        if (out != null && out.getBufferSize() != 0)
454          out.clearBuffer();
455        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
456      }
457    } finally {
458      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
459    }
460  }
461}
Note: See TracBrowser for help on using the repository browser.