All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.mapred.jobdetails_jsp Maven / Gradle / Ivy

The newest version!
package org.apache.hadoop.mapred;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.text.*;
import java.util.*;
import java.text.DecimalFormat;
import org.apache.hadoop.http.HtmlQuoting;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.mapred.JSPUtil.JobWithViewAccessCheck;
import org.apache.hadoop.mapreduce.TaskType;
import org.apache.hadoop.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.jobhistory.JobHistory;
import org.apache.hadoop.mapreduce.JobACL;
import org.apache.hadoop.security.UserGroupInformation;
import java.security.PrivilegedExceptionAction;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.mapred.TaskGraphServlet;

public final class jobdetails_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

	private static final long serialVersionUID = 1L;


  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();
    }
    int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; 
    out.print("" + kind + 
              "" + 
              StringUtils.formatPercent(completePercent, 2) +
              ServletUtil.percentageGraph((int)(completePercent * 100), 80) +
              "" + 
              totalTasks + 
              "" + 
              ((pendingTasks > 0) 
               ? "" + pendingTasks + ""
               : "0") + 
              "" + 
              ((runningTasks > 0) 
               ? "" + runningTasks + "" 
               : "0") + 
              "" + 
              ((finishedTasks > 0) 
               ?"" + finishedTasks + "" 
               : "0") + 
              "" + 
              ((killedTasks > 0) 
               ?"" + killedTasks + ""
               : "0") + 
              "" + 
              ((failedTaskAttempts > 0) ? 
                  ("" + failedTaskAttempts + 
                   "") : 
                  "0"
                  ) + 
              " / " +
              ((killedTaskAttempts > 0) ? 
                  ("" + killedTaskAttempts + 
                   "") : 
                  "0"
                  ) + 
              "\n");
  }

  private void printJobLevelTaskSummary(JspWriter out,
                                String jobId,
                                String kind,
                                TaskInProgress[] tasks
                               ) throws IOException {
    int totalTasks = tasks.length;
    int runningTasks = 0;
    int finishedTasks = 0;
    int killedTasks = 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.isFailed()) {
        killedTasks += 1;
      }
    }
    int pendingTasks = totalTasks - runningTasks - killedTasks - finishedTasks; 
    out.print(((runningTasks > 0)  
               ? "" + " Running" + 
                 "" 
               : ((pendingTasks > 0) ? " Pending" :
                 ((finishedTasks > 0) 
               ?"" + " Successful"
                 + "" 
               : ((killedTasks > 0) 
               ?"" + " Failed" 
                + "" : "None")))));
  }
  
  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 + " ?


" + "
" + "" + "" + "
" + "
"); } private static java.util.List _jspx_dependants; public Object getDependants() { return _jspx_dependants; } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html; charset=UTF-8"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ out.write('\n'); out.write('\n'); out.write('\n'); out.write('\n'); out.write('\n'); final JobTracker tracker = (JobTracker) application.getAttribute( "job.tracker"); String trackerName = StringUtils.simpleHostname(tracker.getJobTrackerMachine()); out.write('\n'); out.write(" \n"); String jobId = request.getParameter("jobid"); String refreshParam = request.getParameter("refresh"); if (jobId == null) { out.println("

Missing 'jobid'!

"); return; } int refresh = 60; // refresh every 60 seconds by default if (refreshParam != null) { try { refresh = Integer.parseInt(refreshParam); } catch (NumberFormatException ignored) { } } final JobID jobIdObj = JobID.forName(jobId); JobWithViewAccessCheck myJob = JSPUtil.checkAccessAndGetJob(tracker, jobIdObj, request, response); if (!myJob.isViewJobAllowed()) { return; // user is not authorized to view this job } JobInProgress job = myJob.getJob(); final String newPriority = request.getParameter("prio"); String user = request.getRemoteUser(); UserGroupInformation ugi = null; if (user != null) { ugi = UserGroupInformation.createRemoteUser(user); } String action = request.getParameter("action"); if(JSPUtil.privateActionsAllowed(tracker.conf) && "changeprio".equalsIgnoreCase(action) && request.getMethod().equalsIgnoreCase("POST")) { if (ugi != null) { try { ugi.doAs(new PrivilegedExceptionAction() { public Void run() throws IOException{ // checks job modify permission tracker.setJobPriority(jobIdObj, JobPriority.valueOf(newPriority)); return null; } }); } catch(AccessControlException e) { String errMsg = "User " + user + " failed to modify priority of " + jobIdObj + "!

" + e.getMessage() + "
Go back to Job
"; JSPUtil.setErrorAndForward(errMsg, request, response); return; } } else {// no authorization needed tracker.setJobPriority(jobIdObj, JobPriority.valueOf(newPriority));; } } if(JSPUtil.privateActionsAllowed(tracker.conf)) { action = request.getParameter("action"); if(action!=null && action.equalsIgnoreCase("confirm")) { printConfirm(out, jobId); return; } else if(action != null && action.equalsIgnoreCase("kill") && request.getMethod().equalsIgnoreCase("POST")) { if (ugi != null) { try { ugi.doAs(new PrivilegedExceptionAction() { public Void run() throws IOException{ // checks job modify permission tracker.killJob(jobIdObj);// checks job modify permission return null; } }); } catch(AccessControlException e) { String errMsg = "User " + user + " failed to kill " + jobIdObj + "!

" + e.getMessage() + "
Go back to Job
"; JSPUtil.setErrorAndForward(errMsg, request, response); return; } } else {// no authorization needed tracker.killJob(jobIdObj); } } } out.write("\n\n\n\n\n "); if (refresh != 0) { out.write("\n \n "); } out.write("\nHadoop "); out.print(jobId); out.write(" on "); out.print(trackerName); out.write("\n\n\n\n

Hadoop "); out.print(jobId); out.write(" on "); out.print(trackerName); out.write("

\n\n"); if (job == null) { String historyFile = tracker.getJobHistory().getHistoryFilePath(jobIdObj); if (historyFile == null) { out.println("

Job " + jobId + " not known!

"); return; } String historyUrl = "/jobdetailshistory.jsp?jobid=" + jobId + "&logFile=" + historyFile; response.sendRedirect(response.encodeRedirectURL(historyUrl)); return; } JobProfile profile = job.getProfile(); JobStatus status = job.getStatus(); int runState = status.getRunState(); int flakyTaskTrackers = job.getNoOfBlackListedTrackers(); out.print("User: " + HtmlQuoting.quoteHtmlChars(profile.getUser()) + "
\n"); out.print("Job Name: " + HtmlQuoting.quoteHtmlChars(profile.getJobName()) + "
\n"); out.print("Job File: " + profile.getJobFile() + "
\n"); out.print("Submit Host: " + HtmlQuoting.quoteHtmlChars(job.getJobSubmitHostName()) + "
\n"); out.print("Submit Host Address: " + HtmlQuoting.quoteHtmlChars(job.getJobSubmitHostAddress()) + "
\n"); Map jobAcls = status.getJobACLs(); JSPUtil.printJobACLs(tracker, jobAcls, out); out.print("Job Setup:"); printJobLevelTaskSummary(out, jobId, "setup", job.getTasks(TaskType.JOB_SETUP)); out.print("
\n"); if (runState == JobStatus.RUNNING) { out.print("Status: Running
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Running 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"); } else if (runState == JobStatus.KILLED) { out.print("Status: Killed
\n"); out.print("Started at: " + new Date(job.getStartTime()) + "
\n"); out.print("Killed at: " + new Date(job.getFinishTime()) + "
\n"); out.print("Killed in: " + StringUtils.formatTimeDiff( job.getFinishTime(), job.getStartTime()) + "
\n"); } } out.print("Job Cleanup:"); printJobLevelTaskSummary(out, jobId, "cleanup", job.getTasks(TaskType.JOB_CLEANUP)); out.print("
\n"); if (flakyTaskTrackers > 0) { out.print("Black-listed TaskTrackers: " + "" + flakyTaskTrackers + "
\n"); } if (job.getSchedulingInfo() != null) { out.print("Job Scheduling information: " + job.getSchedulingInfo().toString() +"\n"); } out.print("
\n"); out.print(""); out.print("" + "" + "" + "\n"); printTaskSummary(out, jobId, "map", status.mapProgress(), job.getTasks(TaskType.MAP)); printTaskSummary(out, jobId, "reduce", status.reduceProgress(), job.getTasks(TaskType.REDUCE)); out.print("
Kind% CompleteNum TasksPendingRunningCompleteKilledFailed/Killed
Task Attempts
\n"); out.write("\n

\n

\n \n \n \n \n \n \n \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 (Counters.Counter counter : totalGroup) { String name = counter.getDisplayName(); String mapValue = decimal.format(mapGroup.getCounter(name)); String reduceValue = decimal.format(reduceGroup.getCounter(name)); String totalValue = decimal.format(counter.getCounter()); out.write("\n \n "); if (isFirst) { isFirst = false; out.write("\n \n "); } out.write("\n \n \n \n \n \n "); } } out.write("\n

CounterMapReduceTotal
\n "); out.print(HtmlQuoting.quoteHtmlChars(totalGroup.getDisplayName())); out.write(""); out.print(HtmlQuoting.quoteHtmlChars(name)); out.write(""); out.print(mapValue); out.write(""); out.print(reduceValue); out.write(""); out.print(totalValue); out.write("
\n\n
Map Completion Graph - \n"); if("off".equals(request.getParameter("map.graph"))) { session.setAttribute("map.graph", "off"); } else if("on".equals(request.getParameter("map.graph"))){ session.setAttribute("map.graph", "on"); } if("off".equals(request.getParameter("reduce.graph"))) { session.setAttribute("reduce.graph", "off"); } else if("on".equals(request.getParameter("reduce.graph"))){ session.setAttribute("reduce.graph", "on"); } if("off".equals(session.getAttribute("map.graph"))) { out.write("\n open \n"); } else { out.write(" \n close \n
\n"); } out.write('\n'); out.write('\n'); if(job.getTasks(TaskType.REDUCE).length > 0) { out.write("\n
Reduce Completion Graph -\n"); if("off".equals(session.getAttribute("reduce.graph"))) { out.write("\n open \n"); } else { out.write(" \n close \n \n
\n"); } } out.write("\n\n
\n"); if(JSPUtil.privateActionsAllowed(tracker.conf)) { out.write("\n
\n Change priority from "); out.print(job.getPriority()); out.write(" to:\n
\n \n \n
\n"); } out.write("\n\n\n \n"); if(JSPUtil.privateActionsAllowed(tracker.conf) && runState == JobStatus.RUNNING) { out.write("\n\t
Kill this job \n"); } out.write("\n\n
\n\n
\nGo back to JobTracker
\n"); out.println(ServletUtil.htmlFooter()); out.write('\n'); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } } }