<% /* * 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. */ %> <%@ page contentType="text/html; charset=UTF-8" import="javax.servlet.*" import="javax.servlet.http.*" import="java.io.*" import="java.util.*" import="java.text.DecimalFormat" import="org.apache.hadoop.mapred.*" import="org.apache.hadoop.util.*" %> <%! private static final long serialVersionUID = 1L; %> <% JobTracker tracker = (JobTracker) application.getAttribute("job.tracker"); String trackerName = StringUtils.simpleHostname(tracker.getJobTrackerMachine()); String type = request.getParameter("type"); %> <%! public void generateTaskTrackerTable(JspWriter out, String type, JobTracker tracker) throws IOException { Collection c; if (("blacklisted").equals(type)) { out.println("

Blacklisted Task Trackers

"); c = tracker.blacklistedTaskTrackers(); } else if (("active").equals(type)) { out.println("

Active Task Trackers

"); c = tracker.activeTaskTrackers(); } else { out.println("

Task Trackers

"); c = tracker.taskTrackers(); } int noCols = 9 + (3 * tracker.getStatistics().collector.DEFAULT_COLLECT_WINDOWS.length); if(type.equals("blacklisted")) { noCols = noCols + 1; } if (c.size() == 0) { out.print("There are currently no known " + type + " Task Trackers."); } else { out.print("
\n"); out.print("\n"); out.print("\n"); out.print("" + "" + "" + "" + "" + "" + ""); if(type.equals("blacklisted")) { out.print(""); } for(StatisticsCollector.TimeWindow window : tracker.getStatistics(). collector.DEFAULT_COLLECT_WINDOWS) { out.println(""); out.println(""); out.println(""); } out.print("\n"); int maxFailures = 0; String failureKing = null; for (Iterator it = c.iterator(); it.hasNext(); ) { TaskTrackerStatus tt = (TaskTrackerStatus) it.next(); long sinceHeartbeat = System.currentTimeMillis() - tt.getLastSeen(); boolean isHealthy = tt.getHealthStatus().isNodeHealthy(); long sinceHealthCheck = tt.getHealthStatus().getLastReported(); String healthString = ""; if(sinceHealthCheck == 0) { healthString = "N/A"; } else { healthString = (isHealthy?"Healthy":"Unhealthy"); sinceHealthCheck = System.currentTimeMillis() - sinceHealthCheck; sinceHealthCheck = sinceHealthCheck/1000; } if (sinceHeartbeat > 0) { sinceHeartbeat = sinceHeartbeat / 1000; } int numCurTasks = 0; for (Iterator it2 = tt.getTaskReports().iterator(); it2.hasNext(); ) { it2.next(); numCurTasks++; } int numFailures = tt.getFailures(); if (numFailures > maxFailures) { maxFailures = numFailures; failureKing = tt.getTrackerName(); } out.print("\n"); } out.print("
Task Trackers
NameHost# running tasksMax Map TasksMax Reduce TasksFailuresNode Health StatusSeconds Since Node Last HealthyReason For blacklistingTotal Tasks "+window.name+"Succeeded Tasks "+window.name+"Failed Health Checks " + window.name+"Seconds since heartbeat
"); out.print(tt.getTrackerName() + ""); out.print(tt.getHost() + "" + numCurTasks + "" + tt.getMaxMapSlots() + "" + tt.getMaxReduceSlots() + "" + numFailures + "" + healthString + "" + sinceHealthCheck); if(type.equals("blacklisted")) { out.print("" + tracker.getFaultReport(tt.getHost())); } for(StatisticsCollector.TimeWindow window : tracker.getStatistics(). collector.DEFAULT_COLLECT_WINDOWS) { JobTrackerStatistics.TaskTrackerStat ttStat = tracker.getStatistics(). getTaskTrackerStat(tt.getTrackerName()); out.println("" + ttStat.totalTasksStat.getValues(). get(window).getValue()); out.println("" + ttStat.succeededTasksStat.getValues(). get(window).getValue()); out.println("" + ttStat.healthCheckFailedStat. getValues().get(window).getValue()); } out.print("" + sinceHeartbeat + "
\n"); out.print("
\n"); if (maxFailures > 0) { out.print("Highest Failures: " + failureKing + " with " + maxFailures + " failures
\n"); } } } public void generateTableForExcludedNodes(JspWriter out, JobTracker tracker) throws IOException { // excluded nodes out.println("

Excluded Nodes

"); Collection d = tracker.getExcludedNodes(); if (d.size() == 0) { out.print("There are currently no excluded hosts."); } else { out.print("
\n"); out.print("\n"); out.print(""); out.print("\n"); for (Iterator it = d.iterator(); it.hasNext(); ) { String dt = (String)it.next(); out.print("\n"); } out.print("
Host Name
" + dt + "
\n"); out.print("
\n"); } } %> <%=trackerName%> Hadoop Machine List

<%=trackerName%> Hadoop Machine List

<% if (("excluded").equals(type)) { generateTableForExcludedNodes(out, tracker); } else { generateTaskTrackerTable(out, type, tracker); } %> <% out.println(ServletUtil.htmlFooter()); %>