MAPREDUCE-6951. Improve exception message when mapreduce.jobhistory.webapp.address is in wrong format. Contributed by Prabhu Joseph.
This commit is contained in:
parent
d8d37b63c7
commit
639f98cc9d
@ -33,6 +33,7 @@
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import static org.apache.hadoop.http.HttpConfig.Policy;
|
||||
@ -126,9 +127,15 @@ public static String getApplicationWebURLOnJHSWithoutScheme(Configuration conf,
|
||||
throws UnknownHostException {
|
||||
//construct the history url for job
|
||||
String addr = getJHSWebappURLWithoutScheme(conf);
|
||||
Iterator<String> it = ADDR_SPLITTER.split(addr).iterator();
|
||||
it.next(); // ignore the bind host
|
||||
String port = it.next();
|
||||
String port;
|
||||
try{
|
||||
Iterator<String> it = ADDR_SPLITTER.split(addr).iterator();
|
||||
it.next(); // ignore the bind host
|
||||
port = it.next();
|
||||
} catch(NoSuchElementException e) {
|
||||
throw new IllegalArgumentException("MapReduce JobHistory WebApp Address"
|
||||
+ " does not contain a valid host:port authority: " + addr);
|
||||
}
|
||||
// Use hs address to figure out the host for webapp
|
||||
addr = conf.get(JHAdminConfig.MR_HISTORY_ADDRESS,
|
||||
JHAdminConfig.DEFAULT_MR_HISTORY_ADDRESS);
|
||||
|
@ -51,6 +51,7 @@
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskId;
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskState;
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.TaskType;
|
||||
import org.apache.hadoop.mapreduce.v2.jobhistory.JHAdminConfig;
|
||||
import org.apache.hadoop.util.ApplicationClassLoader;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.yarn.api.ApplicationConstants;
|
||||
@ -527,4 +528,12 @@ public void testSystemClasses() {
|
||||
assertFalse("/fake/Klass must not be a system class",
|
||||
ApplicationClassLoader.isSystemClass("/fake/Klass", systemClasses));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidWebappAddress() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(JHAdminConfig.MR_HISTORY_WEBAPP_ADDRESS, "19888");
|
||||
MRWebAppUtil.getApplicationWebURLOnJHSWithScheme(
|
||||
conf, ApplicationId.newInstance(0, 1));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user