From 63e7134df6c4521e973707edcf99746e4f72f03d Mon Sep 17 00:00:00 2001 From: Wei-Chiu Chuang Date: Sun, 28 Oct 2018 17:04:59 -0700 Subject: [PATCH] Revert "HADOOP-15864. Job submitter / executor fail when SBN domain name can not resolved. Contributed by He Xiaoqiao." This reverts commit fb2b72e6fce019130e10964a644b94cddbab1c06. --- .../apache/hadoop/security/SecurityUtil.java | 9 ++++---- .../ha/TestDelegationTokensWithHA.java | 23 ------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index b573234264..aa12b93be9 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -424,7 +424,7 @@ public static InetSocketAddress getTokenServiceAddr(Token token) { */ public static void setTokenService(Token token, InetSocketAddress addr) { Text service = buildTokenService(addr); - if (token != null && service != null) { + if (token != null) { token.setService(service); if (LOG.isDebugEnabled()) { LOG.debug("Acquired token "+token); // Token#toString() prints service @@ -444,10 +444,9 @@ public static Text buildTokenService(InetSocketAddress addr) { String host = null; if (useIpForTokenService) { if (addr.isUnresolved()) { // host has no ip address - LOG.warn("unable to resolve host name " + addr - + ". Failure to construct a correct token service " - + "name may result in operation failures"); - return null; + throw new IllegalArgumentException( + new UnknownHostException(addr.getHostName()) + ); } host = addr.getAddress().getHostAddress(); } else { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java index e78cee9160..7076ec674b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java @@ -332,29 +332,6 @@ public void testHAUtilClonesDelegationTokens() throws Exception { } } - @Test(timeout = 300000) - public void testHAUtilClonesDTsDomainNameResolvedFail() throws Exception { - final Token token = - getDelegationToken(fs, "JobTracker"); - - UserGroupInformation ugi = UserGroupInformation.createRemoteUser("test"); - - URI haUri = new URI("hdfs://my-ha-uri/"); - token.setService(HAUtilClient.buildTokenServiceForLogicalUri(haUri, - HdfsConstants.HDFS_URI_SCHEME)); - ugi.addToken(token); - - Collection nnAddrs = new HashSet(); - nnAddrs.add(new InetSocketAddress("domainname.doesnot.exist", - nn0.getNameNodeAddress().getPort())); - nnAddrs.add(new InetSocketAddress("localhost", - nn1.getNameNodeAddress().getPort())); - HAUtilClient.cloneDelegationTokenForLogicalUri(ugi, haUri, nnAddrs); - - Collection> tokens = ugi.getTokens(); - assertEquals(3, tokens.size()); - } - /** * HDFS-3062: DistributedFileSystem.getCanonicalServiceName() throws an * exception if the URI is a logical URI. This bug fails the combination of