<%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*" import="javax.servlet.http.*" import="java.io.*" import="java.text.*" import="java.util.*" import="java.text.DecimalFormat" import="org.apache.hadoop.mapred.*" import="org.apache.hadoop.util.*" import="org.apache.hadoop.dfs.JspHelper" %> <%! private static final String PRIVATE_ACTIONS_KEY = "webinterface.private.actions"; JobTracker tracker = JobTracker.getTracker(); String trackerName = StringUtils.simpleHostname(tracker.getJobTrackerMachine()); private void printTaskSummary(JspWriter out, String jobId, String kind, double completePercent, TaskInProgress[] tasks ) throws IOException { int totalTasks = tasks.length; int runningTasks = 0; int finishedTasks = 0; int killedTasks = 0; int failedTaskAttempts = 0; int killedTaskAttempts = 0; for(int i=0; i < totalTasks; ++i) { TaskInProgress task = tasks[i]; if (task.isComplete()) { finishedTasks += 1; } else if (task.isRunning()) { runningTasks += 1; } else if (task.wasKilled()) { killedTasks += 1; } failedTaskAttempts += task.numTaskFailures(); killedTaskAttempts += task.numKilledTasks(); } out.print("" + kind + "" + StringUtils.formatPercent(completePercent, 2) + "" + totalTasks + "" + (totalTasks - runningTasks - finishedTasks - killedTasks) + "" + runningTasks + "" + finishedTasks + "" + killedTasks + "" + ((failedTaskAttempts > 0) ? ("" + failedTaskAttempts + "") : "0" ) + " / " + ((killedTaskAttempts > 0) ? ("" + killedTaskAttempts + "") : "0" ) + "\n"); } private void printConfirm(JspWriter out, String jobId) throws IOException{ String url = "jobdetails.jsp?jobid=" + jobId; out.print("" + "

Are you sure you want to kill " + jobId + " ?


" + "KillDon't Kill
"); } %> <% String jobId = request.getParameter("jobid"); String refreshParam = request.getParameter("refresh"); int refresh = 60; // refresh every 60 seconds by default if (refreshParam != null) { try { refresh = Integer.parseInt(refreshParam); } catch (NumberFormatException ignored) { } } JobInProgress job = (JobInProgress) tracker.getJob(jobId); String action = request.getParameter("action"); if("changeprio".equalsIgnoreCase(action)) { job.setPriority(JobPriority.valueOf(request.getParameter("prio"))); tracker.resortPriority(); } if(JspHelper.conf.getBoolean(PRIVATE_ACTIONS_KEY, false)) { action = request.getParameter("action"); if(action!=null && action.equalsIgnoreCase("confirm")) { printConfirm(out, jobId); return; } else if(action != null && action.equalsIgnoreCase("kill")) { job.kill(); } } %> <% if (refresh != 0) { %> <% } %> Hadoop <%=jobId%> on <%=trackerName%>

Hadoop <%=jobId%> on <%=trackerName%>

<% if (job == null) { out.print("Job " + jobId + " not found.
\n"); return; } JobProfile profile = job.getProfile(); JobStatus status = job.getStatus(); int runState = status.getRunState(); int flakyTaskTrackers = job.getNoOfBlackListedTrackers(); out.print("User: " + profile.getUser() + "
\n"); out.print("Job Name: " + profile.getJobName() + "
\n"); if (runState == JobStatus.RUNNING) { out.print("Job File: " + profile.getJobFile() + "
\n"); } else { out.print("Job File: " + profile.getJobFile() + "
\n"); } if (runState == JobStatus.RUNNING) { out.print("Status: Running
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Runnning for: " + StringUtils.formatTimeDiff( System.currentTimeMillis(), job.getStartTime()) + "
\n"); } else { if (runState == JobStatus.SUCCEEDED) { out.print("Status: Succeeded
\n"); out.print("Started at : " + new Date(job.getStartTime()) + "
\n"); out.print("Finished at: " + new Date(job.getFinishTime()) + "
\n"); out.print("Finished in: " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } else if (runState == JobStatus.FAILED) { out.print("Status: Failed
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Failed at : " + new Date(job.getFinishTime()) + "
\n"); out.print("Failed in : " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } } if (flakyTaskTrackers > 0) { out.print("Black-listed TaskTrackers: " + "" + flakyTaskTrackers + "
\n"); } out.print("
\n"); out.print(""); out.print("" + "" + "" + "\n"); printTaskSummary(out, jobId, "map", status.mapProgress(), job.getMapTasks()); printTaskSummary(out, jobId, "reduce", status.reduceProgress(), job.getReduceTasks()); out.print("
Kind% CompleteNum TasksPendingRunningCompleteKilledFailed/Killed
Task Attempts
\n"); %>

<% Counters mapCounters = job.getMapCounters(); Counters reduceCounters = job.getReduceCounters(); Counters totalCounters = job.getCounters(); for (String groupName : totalCounters.getGroupNames()) { Counters.Group totalGroup = totalCounters.getGroup(groupName); Counters.Group mapGroup = mapCounters.getGroup(groupName); Counters.Group reduceGroup = reduceCounters.getGroup(groupName); Format decimal = new DecimalFormat(); boolean isFirst = true; for (String counter : totalGroup.getCounterNames()) { String mapValue = decimal.format(mapGroup.getCounter(counter)); String reduceValue = decimal.format(reduceGroup.getCounter(counter)); String totalValue = decimal.format(totalGroup.getCounter(counter)); %> <% if (isFirst) { isFirst = false; %> <% } %> <% } } %>

Counter Map Reduce Total
<%=totalGroup.getDisplayName()%><%=totalGroup.getDisplayName(counter)%> <%=mapValue%> <%=reduceValue%> <%=totalValue%>


Change priority from <%=job.getPriority()%> to: <% JobPriority jobPrio = job.getPriority(); for (JobPriority prio : JobPriority.values()) { if(jobPrio != prio) { %> <%=prio%> <% } } %>
<% if(JspHelper.conf.getBoolean(PRIVATE_ACTIONS_KEY, false) && runState == JobStatus.RUNNING) { %>
Kill this job <% } %>
Go back to JobTracker
Hadoop, 2006.