jobtracker.jsp
上传用户:quxuerui
上传日期:2018-01-08
资源大小:41811k
文件大小:5k
源码类别:

网格计算

开发平台:

Java

  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.util.*"
  7.   import="java.text.DecimalFormat"
  8.   import="org.apache.hadoop.mapred.*"
  9.   import="org.apache.hadoop.util.*"
  10. %>
  11. <%
  12.   JobTracker tracker = (JobTracker) application.getAttribute("job.tracker");
  13.   ClusterStatus status = tracker.getClusterStatus();
  14.   String trackerName = 
  15.            StringUtils.simpleHostname(tracker.getJobTrackerMachine());
  16.   JobQueueInfo[] queues = tracker.getQueues();
  17.   Vector<JobInProgress> runningJobs = tracker.runningJobs();
  18.   Vector<JobInProgress> completedJobs = tracker.completedJobs();
  19.   Vector<JobInProgress> failedJobs = tracker.failedJobs();
  20. %>
  21. <%!
  22.   private static DecimalFormat percentFormat = new DecimalFormat("##0.00");
  23.   
  24.   public void generateSummaryTable(JspWriter out, ClusterStatus status,
  25.                                    JobTracker tracker) throws IOException {
  26.     String tasksPerNode = status.getTaskTrackers() > 0 ?
  27.       percentFormat.format(((double)(status.getMaxMapTasks() +
  28.                       status.getMaxReduceTasks())) / status.getTaskTrackers()):
  29.       "-";
  30.     out.print("<table border="1" cellpadding="5" cellspacing="0">n"+
  31.               "<tr><th>Maps</th><th>Reduces</th>" + 
  32.               "<th>Total Submissions</th>" +
  33.               "<th>Nodes</th><th>Map Task Capacity</th>" +
  34.               "<th>Reduce Task Capacity</th><th>Avg. Tasks/Node</th>" + 
  35.               "<th>Blacklisted Nodes</th></tr>n");
  36.     out.print("<tr><td>" + status.getMapTasks() + "</td><td>" +
  37.               status.getReduceTasks() + "</td><td>" + 
  38.               tracker.getTotalSubmissions() +
  39.               "</td><td><a href="machines.jsp?type=active">" +
  40.               status.getTaskTrackers() +
  41.               "</a></td><td>" + status.getMaxMapTasks() +
  42.               "</td><td>" + status.getMaxReduceTasks() +
  43.               "</td><td>" + tasksPerNode +
  44.               "</td><td><a href="machines.jsp?type=blacklisted">" +
  45.               status.getBlacklistedTrackers() + "</a>" +
  46.               "</td></tr></table>n");
  47.     out.print("<br>");
  48.     if (tracker.hasRestarted()) {
  49.       out.print("<span class="small"><i>");
  50.       if (tracker.hasRecovered()) {
  51.         out.print("The JobTracker got restarted and recovered back in " );
  52.         out.print(StringUtils.formatTime(tracker.getRecoveryDuration()));
  53.       } else {
  54.         out.print("The JobTracker got restarted and is still recovering");
  55.       }
  56.       out.print("</i></span>");
  57.     }
  58.   }%>
  59. <html>
  60. <head>
  61. <title><%= trackerName %> Hadoop Map/Reduce Administration</title>
  62. <link rel="stylesheet" type="text/css" href="/static/hadoop.css">
  63. <script type="text/javascript" src="/static/jobtracker.js"></script>
  64. </head>
  65. <body>
  66. <% JSPUtil.processButtons(request, response, tracker); %>
  67. <h1><%= trackerName %> Hadoop Map/Reduce Administration</h1>
  68. <div id="quicklinks">
  69.   <a href="#quicklinks" onclick="toggle('quicklinks-list'); return false;">Quick Links</a>
  70.   <ul id="quicklinks-list">
  71.     <li><a href="#scheduling_info">Scheduling Info</a></li>
  72.     <li><a href="#running_jobs">Running Jobs</a></li>
  73.     <li><a href="#completed_jobs">Completed Jobs</a></li>
  74.     <li><a href="#failed_jobs">Failed Jobs</a></li>
  75.     <li><a href="#local_logs">Local Logs</a></li>
  76.   </ul>
  77. </div>
  78. <b>State:</b> <%= status.getJobTrackerState() %><br>
  79. <b>Started:</b> <%= new Date(tracker.getStartTime())%><br>
  80. <b>Version:</b> <%= VersionInfo.getVersion()%>,
  81.                 r<%= VersionInfo.getRevision()%><br>
  82. <b>Compiled:</b> <%= VersionInfo.getDate()%> by 
  83.                  <%= VersionInfo.getUser()%><br>
  84. <b>Identifier:</b> <%= tracker.getTrackerIdentifier()%><br>                 
  85.                    
  86. <hr>
  87. <h2>Cluster Summary (Heap Size is <%= StringUtils.byteDesc(status.getUsedMemory()) %>/<%= StringUtils.byteDesc(status.getMaxMemory()) %>)</h2>
  88. <% 
  89.  generateSummaryTable(out, status, tracker); 
  90. %>
  91. <hr>
  92. <h2 id="scheduling_info">Scheduling Information</h2>
  93. <table border="2" cellpadding="5" cellspacing="2">
  94. <thead style="font-weight: bold">
  95. <tr>
  96. <td> Queue Name </td>
  97. <td> Scheduling Information</td>
  98. </tr>
  99. </thead>
  100. <tbody>
  101. <%
  102. for(JobQueueInfo queue: queues) {
  103.   String queueName = queue.getQueueName();
  104.   String schedulingInformation = queue.getSchedulingInfo();
  105.   if(schedulingInformation == null || schedulingInformation.trim().equals("")) {
  106.     schedulingInformation = "NA";
  107.   }
  108. %>
  109. <tr>
  110. <td><a href="jobqueue_details.jsp?queueName=<%=queueName%>"><%=queueName%></a></td>
  111. <td><%=schedulingInformation.replaceAll("n","<br/>") %>
  112. </td>
  113. </tr>
  114. <%
  115. }
  116. %>
  117. </tbody>
  118. </table>
  119. <hr/>
  120. <b>Filter (Jobid, Priority, User, Name)</b> <input type="text" id="filter" onkeyup="applyfilter()"> <br>
  121. <span class="small">Example: 'user:smith 3200' will filter by 'smith' only in the user field and '3200' in all fields</span>
  122. <hr>
  123. <h2 id="running_jobs">Running Jobs</h2>
  124. <%=JSPUtil.generateJobTable("Running", runningJobs, 30, 0)%>
  125. <hr>
  126. <h2 id="completed_jobs">Completed Jobs</h2>
  127. <%=JSPUtil.generateJobTable("Completed", completedJobs, 0, runningJobs.size())%>
  128. <hr>
  129. <h2 id="failed_jobs">Failed Jobs</h2>
  130. <%=JSPUtil.generateJobTable("Failed", failedJobs, 0, 
  131.     (runningJobs.size()+completedJobs.size()))%>
  132. <hr>
  133. <h2 id="local_logs">Local Logs</h2>
  134. <a href="logs/">Log</a> directory, <a href="jobhistory.jsp">
  135. Job Tracker History</a>
  136. <%
  137. out.println(ServletUtil.htmlFooter());
  138. %>