source: proiecte/HadoopJUnit/hadoop-0.20.1/src/webapps/job/taskdetails.jsp

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