HADOOP-15864. Job submitter / executor fail when SBN domain name can not resolved. Contributed by He Xiaoqiao.

This commit is contained in:
Wei-Chiu Chuang 2018-10-25 09:33:31 -07:00
parent c7f349bc3f
commit fb2b72e6fc
2 changed files with 28 additions and 4 deletions

View File

@ -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) {
if (token != null && service != null) {
token.setService(service);
if (LOG.isDebugEnabled()) {
LOG.debug("Acquired token "+token); // Token#toString() prints service
@ -444,9 +444,10 @@ public static Text buildTokenService(InetSocketAddress addr) {
String host = null;
if (useIpForTokenService) {
if (addr.isUnresolved()) { // host has no ip address
throw new IllegalArgumentException(
new UnknownHostException(addr.getHostName())
);
LOG.warn("unable to resolve host name " + addr
+ ". Failure to construct a correct token service "
+ "name may result in operation failures");
return null;
}
host = addr.getAddress().getHostAddress();
} else {

View File

@ -332,6 +332,29 @@ public void testHAUtilClonesDelegationTokens() throws Exception {
}
}
@Test(timeout = 300000)
public void testHAUtilClonesDTsDomainNameResolvedFail() throws Exception {
final Token<DelegationTokenIdentifier> 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<InetSocketAddress> nnAddrs = new HashSet<InetSocketAddress>();
nnAddrs.add(new InetSocketAddress("domainname.doesnot.exist",
nn0.getNameNodeAddress().getPort()));
nnAddrs.add(new InetSocketAddress("localhost",
nn1.getNameNodeAddress().getPort()));
HAUtilClient.cloneDelegationTokenForLogicalUri(ugi, haUri, nnAddrs);
Collection<Token<? extends TokenIdentifier>> 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