From fb498926becbbf5c281bb9012ae3473ac3af93b0 Mon Sep 17 00:00:00 2001 From: Siddharth Seth Date: Tue, 7 Feb 2012 20:55:10 +0000 Subject: [PATCH] MAPREDUCE-3436. JobHistory webapp address should use the host configured in the jobhistory address. (Contributed by Ahmed Radwan) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1241620 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../v2/jobhistory/JobHistoryUtils.java | 17 ++++++++++++++++- .../src/main/resources/mapred-default.xml | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 0ed0fe3429b..f3a5debfcd1 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -747,6 +747,9 @@ Release 0.23.1 - Unreleased MAPREDUCE-3709. TestDistributedShell is failing. (Hitesh Shah via mahadev) + + MAPREDUCE-3436. JobHistory webapp address should use the host configured + in the jobhistory address. (Ahmed Radwan via sseth) Release 0.23.0 - 2011-11-01 diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java index 711dd18118b..c1da2fe6a94 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/v2/jobhistory/JobHistoryUtils.java @@ -24,6 +24,7 @@ import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.Calendar; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -46,6 +47,9 @@ import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.ApplicationId; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; + public class JobHistoryUtils { /** @@ -110,6 +114,9 @@ public class JobHistoryUtils { public static final Pattern TIMESTAMP_DIR_PATTERN = Pattern.compile(TIMESTAMP_DIR_REGEX); private static final String TIMESTAMP_DIR_FORMAT = "%04d" + File.separator + "%02d" + File.separator + "%02d"; + private static final Splitter ADDR_SPLITTER = Splitter.on(':').trimResults(); + private static final Joiner JOINER = Joiner.on(""); + private static final PathFilter CONF_FILTER = new PathFilter() { @Override public boolean accept(Path path) { @@ -478,8 +485,16 @@ public class JobHistoryUtils { public static String getHistoryUrl(Configuration conf, ApplicationId appId) throws UnknownHostException { //construct the history url for job - String hsAddress = conf.get(JHAdminConfig.MR_HISTORY_WEBAPP_ADDRESS, + String addr = conf.get(JHAdminConfig.MR_HISTORY_WEBAPP_ADDRESS, JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS); + Iterator it = ADDR_SPLITTER.split(addr).iterator(); + it.next(); // ignore the bind host + String port = it.next(); + // Use hs address to figure out the host for webapp + addr = conf.get(JHAdminConfig.MR_HISTORY_ADDRESS, + JHAdminConfig.DEFAULT_MR_HISTORY_ADDRESS); + String host = ADDR_SPLITTER.split(addr).iterator().next(); + String hsAddress = JOINER.join(host, ":", port); InetSocketAddress address = NetUtils.createSocketAddr( hsAddress, JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_PORT, JHAdminConfig.DEFAULT_MR_HISTORY_WEBAPP_ADDRESS); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml index 80406132a44..f6fc57ba0fd 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/resources/mapred-default.xml @@ -1262,4 +1262,18 @@ to the RM to fetch Application Status. + + + + mapreduce.jobhistory.address + 0.0.0.0:10020 + MapReduce JobHistory Server host:port + + + + mapreduce.jobhistory.webapp.address + 0.0.0.0:19888 + MapReduce JobHistory Server Web UI host:port + +