|
@@ -46,6 +46,7 @@ import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.HATestUtil;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.HATestUtil;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.IPFailoverProxyProvider;
|
|
import org.apache.hadoop.hdfs.server.namenode.ha.IPFailoverProxyProvider;
|
|
|
|
+import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.io.IOUtils;
|
|
import org.apache.hadoop.io.retry.FailoverProxyProvider;
|
|
import org.apache.hadoop.io.retry.FailoverProxyProvider;
|
|
import org.apache.hadoop.net.ConnectTimeoutException;
|
|
import org.apache.hadoop.net.ConnectTimeoutException;
|
|
@@ -291,6 +292,40 @@ public class TestDFSClientFailover {
|
|
Mockito.verify(spyNS, Mockito.never()).lookupAllHostAddr(Mockito.eq(logicalHost));
|
|
Mockito.verify(spyNS, Mockito.never()).lookupAllHostAddr(Mockito.eq(logicalHost));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Test that creating proxy doesn't ever try to DNS-resolve the logical URI.
|
|
|
|
+ * Regression test for HDFS-9364.
|
|
|
|
+ */
|
|
|
|
+ @Test(timeout=60000)
|
|
|
|
+ public void testCreateProxyDoesntDnsResolveLogicalURI() throws IOException {
|
|
|
|
+ final NameService spyNS = spyOnNameService();
|
|
|
|
+ final Configuration conf = new HdfsConfiguration();
|
|
|
|
+ final String service = "nameservice1";
|
|
|
|
+ final String namenode = "namenode113";
|
|
|
|
+ conf.set(DFSConfigKeys.DFS_NAMESERVICES, service);
|
|
|
|
+ conf.set(FileSystem.FS_DEFAULT_NAME_KEY, "hdfs://" + service);
|
|
|
|
+ conf.set(
|
|
|
|
+ HdfsClientConfigKeys.Failover.PROXY_PROVIDER_KEY_PREFIX + "." + service,
|
|
|
|
+ "org.apache.hadoop.hdfs.server.namenode.ha."
|
|
|
|
+ + "ConfiguredFailoverProxyProvider");
|
|
|
|
+ conf.set(DFSConfigKeys.DFS_HA_NAMENODES_KEY_PREFIX + "." + service,
|
|
|
|
+ namenode);
|
|
|
|
+ conf.set(DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY + "." + service + "."
|
|
|
|
+ + namenode, "localhost:8020");
|
|
|
|
+
|
|
|
|
+ // call createProxy implicitly and explicitly
|
|
|
|
+ Path p = new Path("/");
|
|
|
|
+ p.getFileSystem(conf);
|
|
|
|
+ NameNodeProxiesClient.createProxyWithClientProtocol(conf,
|
|
|
|
+ FileSystem.getDefaultUri(conf), null);
|
|
|
|
+ NameNodeProxies.createProxy(conf, FileSystem.getDefaultUri(conf),
|
|
|
|
+ NamenodeProtocol.class, null);
|
|
|
|
+
|
|
|
|
+ // Ensure that the logical hostname was never resolved.
|
|
|
|
+ Mockito.verify(spyNS, Mockito.never()).lookupAllHostAddr(
|
|
|
|
+ Mockito.eq(service));
|
|
|
|
+ }
|
|
|
|
+
|
|
/** Dummy implementation of plain FailoverProxyProvider */
|
|
/** Dummy implementation of plain FailoverProxyProvider */
|
|
public static class DummyLegacyFailoverProxyProvider<T>
|
|
public static class DummyLegacyFailoverProxyProvider<T>
|
|
implements FailoverProxyProvider<T> {
|
|
implements FailoverProxyProvider<T> {
|