Author: wang Date: Fri Aug 1 21:56:27 2014 New Revision: 1615245 URL: http://svn.apache.org/r1615245 Log: HDFS-6793. Missing changes in HftpFileSystem when Reintroduce dfs.http.port / dfs.https.port in branch-2. Contributed by Juan Yu.
Modified: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/ (props changed) hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/ (props changed) hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ (props changed) hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HsftpFileSystem.java hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java Propchange: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/ ------------------------------------------------------------------------------ Merged /hadoop/common/branches/branch-2/hadoop-hdfs-project:r1615243 Propchange: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/ ------------------------------------------------------------------------------ Merged /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs:r1615243 Modified: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1615245&r1=1615244&r2=1615245&view=diff ============================================================================== --- hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri Aug 1 21:56:27 2014 @@ -563,6 +563,9 @@ Release 2.5.0 - UNRELEASED HDFS-6717. JIRA HDFS-5804 breaks default nfs-gateway behavior for unsecured config (brandonli) + HDFS-6793. Missing changes in HftpFileSystem when Reintroduce + dfs.http.port / dfs.https.port in branch-2. (Juan Yu via wang). + BREAKDOWN OF HDFS-2006 SUBTASKS AND RELATED JIRAS HDFS-6299. Protobuf for XAttr and client-side implementation. (Yi Liu via umamahesh) Propchange: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ ------------------------------------------------------------------------------ Merged /hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1615243 Modified: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java?rev=1615245&r1=1615244&r2=1615245&view=diff ============================================================================== --- hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java (original) +++ hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HftpFileSystem.java Fri Aug 1 21:56:27 2014 @@ -123,7 +123,8 @@ public class HftpFileSystem extends File @Override protected int getDefaultPort() { - return DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_DEFAULT; + return getConf().getInt(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_KEY, + DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_DEFAULT); } /** Modified: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HsftpFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HsftpFileSystem.java?rev=1615245&r1=1615244&r2=1615245&view=diff ============================================================================== --- hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HsftpFileSystem.java (original) +++ hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/web/HsftpFileSystem.java Fri Aug 1 21:56:27 2014 @@ -64,6 +64,7 @@ public class HsftpFileSystem extends Hft @Override protected int getDefaultPort() { - return DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_DEFAULT; + return getConf().getInt(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_KEY, + DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_DEFAULT); } } Modified: hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java?rev=1615245&r1=1615244&r2=1615245&view=diff ============================================================================== --- hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java (original) +++ hadoop/common/branches/branch-2.5/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/web/TestHftpFileSystem.java Fri Aug 1 21:56:27 2014 @@ -311,6 +311,23 @@ public class TestHftpFileSystem { } @Test + public void testHftpCustomDefaultPorts() throws IOException { + Configuration conf = new Configuration(); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_KEY, 123); + + URI uri = URI.create("hftp://localhost"); + HftpFileSystem fs = (HftpFileSystem) FileSystem.get(uri, conf); + + assertEquals(123, fs.getDefaultPort()); + + assertEquals(uri, fs.getUri()); + + // HFTP uses http to get the token so canonical service name should + // return the http port. + assertEquals("127.0.0.1:123", fs.getCanonicalServiceName()); + } + + @Test public void testHftpCustomUriPortWithDefaultPorts() throws IOException { Configuration conf = new Configuration(); URI uri = URI.create("hftp://localhost:123"); @@ -326,11 +343,12 @@ public class TestHftpFileSystem { @Test public void testHftpCustomUriPortWithCustomDefaultPorts() throws IOException { Configuration conf = new Configuration(); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_KEY, 123); + URI uri = URI.create("hftp://localhost:789"); HftpFileSystem fs = (HftpFileSystem) FileSystem.get(uri, conf); - assertEquals(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_DEFAULT, - fs.getDefaultPort()); + assertEquals(123, fs.getDefaultPort()); assertEquals(uri, fs.getUri()); assertEquals("127.0.0.1:789", fs.getCanonicalServiceName()); @@ -365,6 +383,20 @@ public class TestHftpFileSystem { fs.getCanonicalServiceName()); } + @Test + public void testHsftpCustomDefaultPorts() throws IOException { + Configuration conf = new Configuration(); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_KEY, 123); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_KEY, 456); + + URI uri = URI.create("hsftp://localhost"); + HsftpFileSystem fs = (HsftpFileSystem) FileSystem.get(uri, conf); + + assertEquals(456, fs.getDefaultPort()); + + assertEquals(uri, fs.getUri()); + assertEquals("127.0.0.1:456", fs.getCanonicalServiceName()); + } @Test public void testHsftpCustomUriPortWithDefaultPorts() throws IOException { @@ -382,12 +414,13 @@ public class TestHftpFileSystem { @Test public void testHsftpCustomUriPortWithCustomDefaultPorts() throws IOException { Configuration conf = new Configuration(); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTP_PORT_KEY, 123); + conf.setInt(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_KEY, 456); URI uri = URI.create("hsftp://localhost:789"); HsftpFileSystem fs = (HsftpFileSystem) FileSystem.get(uri, conf); - assertEquals(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_DEFAULT, - fs.getDefaultPort()); + assertEquals(456, fs.getDefaultPort()); assertEquals(uri, fs.getUri()); assertEquals("127.0.0.1:789", fs.getCanonicalServiceName());