HDFS-15193. Improving the error message for missing dfs.namenode.rpc-address.$NAMESERVICE. Contributed by Ctest.

This commit is contained in:
Ayush Saxena 2020-03-29 00:01:22 +05:30
parent f531a4a487
commit 696a663cd0
2 changed files with 16 additions and 2 deletions

View File

@ -627,8 +627,9 @@ public static Map<String, Map<String, InetSocketAddress>> getNNServiceRpcAddress
DFS_NAMENODE_RPC_ADDRESS_KEY);
if (addressList.isEmpty()) {
throw new IOException("Incorrect configuration: namenode address "
+ DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + " or "
+ DFS_NAMENODE_RPC_ADDRESS_KEY
+ DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + "." + parentNameServices
+ " or "
+ DFS_NAMENODE_RPC_ADDRESS_KEY + "." + parentNameServices
+ " is not configured.");
}
return addressList;

View File

@ -79,6 +79,7 @@
import org.apache.hadoop.security.alias.CredentialProviderFactory;
import org.apache.hadoop.security.alias.JavaKeyStoreProvider;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.LambdaTestUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@ -1096,4 +1097,16 @@ public void testFileIdPath() throws Throwable {
}
}
@Test
public void testErrorMessageForInvalidNameservice() throws Exception {
Configuration conf = new HdfsConfiguration();
conf.set(DFSConfigKeys.DFS_NAMESERVICES, "ns1, ns2");
String expectedErrorMessage = "Incorrect configuration: namenode address "
+ DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY + ".[ns1, ns2]"
+ " or "
+ DFS_NAMENODE_RPC_ADDRESS_KEY + ".[ns1, ns2]"
+ " is not configured.";
LambdaTestUtils.intercept(IOException.class, expectedErrorMessage,
()->DFSUtil.getNNServiceRpcAddressesForCluster(conf));
}
}