DelegateToFileSystem erroneously uses default FS's port in constructor. (Brahma Reddy Battula via gera)

(cherry picked from commit 64eb068ee8)
This commit is contained in:
Gera Shegalov 2015-03-10 13:52:06 -07:00
parent 6802e8fefc
commit f1b32d1436
4 changed files with 62 additions and 2 deletions

View File

@ -668,6 +668,9 @@ Release 2.7.0 - UNRELEASED
HADOOP-11692. Improve authentication failure WARN message to avoid user HADOOP-11692. Improve authentication failure WARN message to avoid user
confusion. (Yongjun Zhang) confusion. (Yongjun Zhang)
HADOOP-11618. DelegateToFileSystem erroneously uses default FS's port in
constructor. (Brahma Reddy Battula via gera)
Release 2.6.1 - UNRELEASED Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -29,7 +29,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Options.ChecksumOpt; import org.apache.hadoop.fs.Options.ChecksumOpt;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.util.Progressable; import org.apache.hadoop.util.Progressable;
@ -47,7 +46,7 @@ public abstract class DelegateToFileSystem extends AbstractFileSystem {
Configuration conf, String supportedScheme, boolean authorityRequired) Configuration conf, String supportedScheme, boolean authorityRequired)
throws IOException, URISyntaxException { throws IOException, URISyntaxException {
super(theUri, supportedScheme, authorityRequired, super(theUri, supportedScheme, authorityRequired,
FileSystem.getDefaultUri(conf).getPort()); theFsImpl.getDefaultPort());
fsImpl = theFsImpl; fsImpl = theFsImpl;
fsImpl.initialize(theUri, conf); fsImpl.initialize(theUri, conf);
fsImpl.statistics = getStatistics(); fsImpl.statistics = getStatistics();

View File

@ -572,6 +572,12 @@ for ldap providers in the same way as above does.
(ie client side mount table:).</description> (ie client side mount table:).</description>
</property> </property>
<property>
<name>fs.AbstractFileSystem.ftp.impl</name>
<value>org.apache.hadoop.fs.ftp.FtpFs</value>
<description>The FileSystem for Ftp: uris.</description>
</property>
<property> <property>
<name>fs.ftp.host</name> <name>fs.ftp.host</name>
<value>0.0.0.0</value> <value>0.0.0.0</value>

View File

@ -0,0 +1,52 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.fs;
import java.net.URI;
import org.apache.commons.net.ftp.FTP;
import org.apache.hadoop.conf.Configuration;
import org.junit.Assert;
import org.junit.Test;
public class TestDelegateToFileSystem {
private static final String FTP_DUMMYHOST = "ftp://dummyhost";
private static final URI FTP_URI_NO_PORT = URI.create(FTP_DUMMYHOST);
private static final URI FTP_URI_WITH_PORT = URI.create(FTP_DUMMYHOST + ":"
+ FTP.DEFAULT_PORT);
private void testDefaultUriInternal(String defaultUri)
throws UnsupportedFileSystemException {
final Configuration conf = new Configuration();
FileSystem.setDefaultUri(conf, defaultUri);
final AbstractFileSystem ftpFs =
AbstractFileSystem.get(FTP_URI_NO_PORT, conf);
Assert.assertEquals(FTP_URI_WITH_PORT, ftpFs.getUri());
}
@Test
public void testDefaultURIwithOutPort() throws Exception {
testDefaultUriInternal("hdfs://dummyhost");
}
@Test
public void testDefaultURIwithPort() throws Exception {
testDefaultUriInternal("hdfs://dummyhost:8020");
}
}