You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2011/03/04 05:35:27 UTC
svn commit: r1077607 - in
/hadoop/common/branches/branch-0.20-security-patches/src:
mapred/org/apache/hadoop/mapred/ test/org/apache/hadoop/mapred/
webapps/history/
Author: omalley
Date: Fri Mar 4 04:35:26 2011
New Revision: 1077607
URL: http://svn.apache.org/viewvc?rev=1077607&view=rev
Log:
commit 319fff84064b72f8306f07c50781df63f43064b5
Author: Chris Douglas <cd...@apache.org>
Date: Tue Jul 27 18:41:44 2010 -0700
JobHistory links broken in embedded mode
Modified:
hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistoryServer.java
hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestWebUIAuthorization.java
hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/jobhistoryhome.jsp
hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/legacyjobhistory.jsp
Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistoryServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistoryServer.java?rev=1077607&r1=1077606&r2=1077607&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistoryServer.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/JobHistoryServer.java Fri Mar 4 04:35:26 2011
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
import org.apache.hadoop.http.HttpServer;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.SecurityUtil;
@@ -164,17 +165,18 @@ public class JobHistoryServer {
}
final String historyLogDir =
JobHistory.getCompletedJobHistoryLocation().toString();
+ FileSystem historyFS = new Path(historyLogDir).getFileSystem(conf);
context = historyServer.addContext("history", true);
historyServer.setAttribute(context, "historyLogDir", historyLogDir);
- historyServer.setAttribute(context, "fileSys", fs);
+ historyServer.setAttribute(context, "fileSys", historyFS);
historyServer.setAttribute(context, "jobConf", conf);
historyServer.setAttribute(context, "aclManager", aclsManager);
if (!isEmbedded(conf)) {
historyServer.setAttribute("historyLogDir", historyLogDir);
- historyServer.setAttribute("fileSys", fs);
+ historyServer.setAttribute("fileSys", historyFS);
historyServer.setAttribute("jobConf", conf);
historyServer.setAttribute("aclManager", aclsManager);
}
@@ -250,7 +252,8 @@ public class JobHistoryServer {
}
static String getHistoryUrlPrefix(JobConf conf) {
- return "http://" + getAddress(conf) + "/history";
+ return (isEmbedded(conf) ? "" : "http://" + getAddress(conf))
+ + "/history";
}
private static String getBindAddress(JobConf conf) {
Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestWebUIAuthorization.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestWebUIAuthorization.java?rev=1077607&r1=1077606&r2=1077607&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestWebUIAuthorization.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/TestWebUIAuthorization.java Fri Mar 4 04:35:26 2011
@@ -335,12 +335,20 @@ public class TestWebUIAuthorization exte
JobConf conf = new JobConf(cluster.createJobConf());
conf.set(JobContext.JOB_ACL_VIEW_JOB, viewColleague + " group3");
+ JobTracker jobTracker = getMRCluster().getJobTrackerRunner().getJobTracker();
+
//Initialize history server, if need to be started in standalone mode
+ String jhUrlPrefix = JobHistoryServer.getHistoryUrlPrefix(jobTracker.conf);
+ String jobHistoryUrl;
if ("false".equals(props.getProperty(
JobHistoryServer.MAPRED_HISTORY_SERVER_EMBEDDED, "true"))) {
JobHistoryServer historyServer = new JobHistoryServer(cluster.
getJobTrackerRunner().getJobTracker().conf);
historyServer.start();
+ jobHistoryUrl = jhUrlPrefix;
+ } else {
+ jobHistoryUrl = "http://" + JobHistoryServer.getAddress(jobTracker.conf) +
+ jhUrlPrefix;
}
// Let us add group1 and group3 to modify-job-acl. So modifyColleague and
@@ -367,7 +375,6 @@ public class TestWebUIAuthorization exte
JobID jobid = job.getID();
- JobTracker jobTracker = getMRCluster().getJobTrackerRunner().getJobTracker();
JobInProgress jip = jobTracker.getJob(jobid);
JobConf finalJobConf = jip.getJobConf();
Path doneDir = JobHistory.getCompletedJobHistoryLocation();
@@ -381,7 +388,6 @@ public class TestWebUIAuthorization exte
JobHistory.JobInfo.getDoneJobHistoryFileName(finalJobConf, jobid));
String urlEncodedHistoryFileName = URLEncoder.encode(historyFilePath.toString());
- String jobHistoryUrl = JobHistoryServer.getHistoryUrlPrefix(jobTracker.conf);
// validate access of jobdetails_history.jsp
String jobDetailsJSP = jobHistoryUrl +
Modified: hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/jobhistoryhome.jsp
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/jobhistoryhome.jsp?rev=1077607&r1=1077606&r2=1077607&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/jobhistoryhome.jsp (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/jobhistoryhome.jsp Fri Mar 4 04:35:26 2011
@@ -1,13 +1,14 @@
<%@ page
contentType="text/html; charset=UTF-8"
import="java.io.*"
- import="java.net.URLEncoder"
+ import="java.net.*"
import="java.util.*"
import="java.util.regex.Pattern"
import="java.util.regex.Matcher"
import="java.util.concurrent.atomic.AtomicBoolean"
- import="org.apache.hadoop.mapred.*"
+ import="org.apache.hadoop.net.*"
import="org.apache.hadoop.util.*"
+ import="org.apache.hadoop.mapred.*"
import="org.apache.hadoop.fs.*"
import="javax.servlet.jsp.*"
import="java.text.SimpleDateFormat"
@@ -15,9 +16,19 @@
%>
<%
JobConf jobConf = (JobConf) application.getAttribute("jobConf");
+ String trackerUrl;
+ String trackerName;
+
String trackerAddress = jobConf.get("mapred.job.tracker.http.address");
- String trackerName =
- StringUtils.simpleHostname(trackerAddress);
+ InetSocketAddress infoSocAddr = NetUtils.createSocketAddr(trackerAddress);
+ if (JobHistoryServer.isEmbedded(jobConf)) {
+ trackerName = StringUtils.simpleHostname(InetAddress.
+ getLocalHost().getCanonicalHostName());
+ trackerUrl = "";
+ } else {
+ trackerUrl = "http://" + trackerAddress;
+ trackerName = StringUtils.simpleHostname(infoSocAddr.getHostName());
+ }
%>
<%!
private static SimpleDateFormat dateFormat =
@@ -46,7 +57,7 @@ window.location.href = url;
<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
</head>
<body>
-<h1> <a href="http://<%=trackerAddress%>/jobtracker.jsp"><%= trackerName %></a> Hadoop Map/Reduce
+<h1> <a href="<%=trackerUrl%>/jobtracker.jsp"><%= trackerName %></a> Hadoop Map/Reduce
<a href="jobhistoryhome.jsp">History Viewer</a></h1>
<hr>
<%
Modified: hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/legacyjobhistory.jsp
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/legacyjobhistory.jsp?rev=1077607&r1=1077606&r2=1077607&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/legacyjobhistory.jsp (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/webapps/history/legacyjobhistory.jsp Fri Mar 4 04:35:26 2011
@@ -1,9 +1,11 @@
<%@ page
contentType="text/html; charset=UTF-8"
import="java.io.*"
+ import="java.net.*"
import="java.util.*"
import="org.apache.hadoop.mapred.*"
import="org.apache.hadoop.util.*"
+ import="org.apache.hadoop.net.*"
import="org.apache.hadoop.fs.*"
import="javax.servlet.jsp.*"
import="java.text.SimpleDateFormat"
@@ -11,9 +13,21 @@
import="org.apache.hadoop.mapred.*"
%>
<%
- JobConf jobConf = (JobConf)application.getAttribute("jobConf");
- String trackerAddress = jobConf.get("mapred.job.tracker.http.address");
- String trackerName = StringUtils.simpleHostname(trackerAddress);
+ JobConf jobConf = (JobConf) application.getAttribute("jobConf");
+ String trackerUrl;
+ String trackerName;
+
+ String trackerAddress = jobConf.get("mapred.job.tracker.http.address");
+ InetSocketAddress infoSocAddr = NetUtils.createSocketAddr(trackerAddress);
+ if (JobHistoryServer.isEmbedded(jobConf)) {
+ trackerName = StringUtils.simpleHostname(InetAddress.
+ getLocalHost().getCanonicalHostName());
+ trackerName = StringUtils.getHostname();
+ trackerUrl = "";
+ } else {
+ trackerUrl = "http://" + trackerAddress;
+ trackerName = StringUtils.simpleHostname(infoSocAddr.getHostName());
+ }
%>
<%!
private static SimpleDateFormat dateFormat =
@@ -42,7 +56,7 @@ window.location.href = url;
<link rel="stylesheet" type="text/css" href="/static/hadoop.css">
</head>
<body>
-<h1> <a href="http://<%=trackerAddress%>/jobtracker.jsp"><%= trackerName %></a> Hadoop Map/Reduce
+<h1> <a href="<%=trackerUrl%>/jobtracker.jsp"><%= trackerName %></a> Hadoop Map/Reduce
<a href="jobhistoryhome.jsp">History Viewer</a></h1>
<hr>
<%