<%@ page contentType="text/html; charset=UTF-8" import="java.io.*" import="java.util.*" import="org.apache.hadoop.mapred.*" import="org.apache.hadoop.util.*" import="org.apache.hadoop.fs.*" import="javax.servlet.jsp.*" import="java.text.SimpleDateFormat" import="org.apache.hadoop.mapred.*" import="org.apache.hadoop.mapred.JobHistory.*" %> <%! private static SimpleDateFormat dateFormat = new SimpleDateFormat("d/MM HH:mm:ss"); %> Hadoop Map/Reduce Administration

Hadoop Map/Reduce History Viewer


Available History

<% PathFilter jobLogFileFilter = new PathFilter() { public boolean accept(Path path) { return !(path.getName().endsWith(".xml")); } }; FileSystem fs = (FileSystem) application.getAttribute("fileSys"); String historyLogDir = (String) application.getAttribute("historyLogDir"); if (fs == null) { out.println("Null file system. May be namenode is in safemode!"); return; } Path[] jobFiles = FileUtil.stat2Paths(fs.listStatus(new Path(historyLogDir), jobLogFileFilter)); if (null == jobFiles ) { out.println("NULL files !!!"); return ; } // sort the files on creation time. Arrays.sort(jobFiles, new Comparator() { public int compare(Path p1, Path p2) { String dp1 = null; String dp2 = null; try { dp1 = JobHistory.JobInfo.decodeJobHistoryFileName(p1.getName()); dp2 = JobHistory.JobInfo.decodeJobHistoryFileName(p2.getName()); } catch (IOException ioe) { throw new RuntimeException(ioe); } String[] split1 = dp1.split("_"); String[] split2 = dp2.split("_"); // compare job tracker start time int res = new Date(Long.parseLong(split1[1])).compareTo( new Date(Long.parseLong(split2[1]))); if (res == 0) { res = new Date(Long.parseLong(split1[3])).compareTo( new Date(Long.parseLong(split2[3]))); } if (res == 0) { Long l1 = Long.parseLong(split1[4]); res = l1.compareTo(Long.parseLong(split2[4])); } return res; } }); out.print(""); out.print("\n"); out.print(""); out.print("" + "" + "") ; out.print(""); for (Path jobFile: jobFiles) { String decodedJobFileName = JobHistory.JobInfo.decodeJobHistoryFileName(jobFile.getName()); String[] jobDetails = decodedJobFileName.split("_"); String trackerHostName = jobDetails[0]; String trackerStartTime = jobDetails[1]; String jobId = jobDetails[2] + "_" +jobDetails[3] + "_" + jobDetails[4] ; String user = jobDetails[5]; String jobName = jobDetails[6]; // Encode the logfile name again to cancel the decoding done by the browser String encodedJobFileName = JobHistory.JobInfo.encodeJobHistoryFileName(jobFile.getName()); %>
<% printJob(trackerHostName, trackerStartTime, jobId, jobName, user, new Path(jobFile.getParent(), encodedJobFileName), out) ; %>
<% } // end while trackers %> <%! private void printJob(String trackerHostName, String trackerid, String jobId, String jobName, String user, Path logFile, JspWriter out) throws IOException { out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); out.print(""); } %>
Available Jobs
Job tracker Host NameJob tracker Start timeJob IdNameUser
" + trackerHostName + "" + new Date(Long.parseLong(trackerid)) + "" + "" + jobId + "" + jobName + "" + user + "