HADOOP-13605. Clean up FileSystem javadocs, logging; improve diagnostics on FS load. Contributed by Steve Loughran

This commit is contained in:
Mingliang Liu 2016-11-23 16:32:42 -08:00
parent de4894936a
commit 860d49aa6a
4 changed files with 919 additions and 578 deletions

View File

@ -419,7 +419,7 @@ If the filesystem is not location aware, it SHOULD return
BlockLocation(["localhost:9866"] , BlockLocation(["localhost:9866"] ,
["localhost"], ["localhost"],
["/default/localhost"] ["/default/localhost"]
0, F.getLen()) 0, f.getLen())
] ; ] ;

View File

@ -21,14 +21,14 @@
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.Test; import org.junit.Test;
import static org.apache.hadoop.test.LambdaTestUtils.*;
/** /**
* Test default URI related APIs in {@link FileSystem}. * Test default URI related APIs in {@link FileSystem}.
@ -69,15 +69,12 @@ public void tetGetDefaultUriNoScheme() {
} }
@Test @Test
public void tetGetDefaultUriNoSchemeTrailingSlash() { public void tetGetDefaultUriNoSchemeTrailingSlash() throws Exception {
conf.set(FS_DEFAULT_NAME_KEY, "nn_host/"); conf.set(FS_DEFAULT_NAME_KEY, "nn_host/");
try { intercept(IllegalArgumentException.class,
FileSystem.getDefaultUri(conf); "No scheme in default FS",
fail("Expect IAE: No scheme in default FS"); () -> FileSystem.getDefaultUri(conf));
} catch (IllegalArgumentException e) {
GenericTestUtils.assertExceptionContains(
"No scheme in default FS", e);
}
} }
@Test @Test
@ -88,28 +85,19 @@ public void tetFsGet() throws IOException {
} }
@Test @Test
public void tetFsGetNoScheme() throws IOException { public void tetFsGetNoScheme() throws Exception {
// Bare host name or address indicates hdfs scheme // Bare host name or address indicates hdfs scheme
conf.set(FS_DEFAULT_NAME_KEY, "nn_host"); conf.set(FS_DEFAULT_NAME_KEY, "nn_host");
try { intercept(UnsupportedFileSystemException.class, "hdfs",
FileSystem.get(conf); () -> FileSystem.get(conf));
fail("Expect IOE: No FileSystem for scheme: hdfs");
} catch (IOException e) {
GenericTestUtils.assertExceptionContains(
"No FileSystem for scheme: hdfs", e);
}
} }
@Test @Test
public void tetFsGetNoSchemeTrailingSlash() throws IOException { public void tetFsGetNoSchemeTrailingSlash() throws Exception {
// Bare host name or address with trailing slash is invalid // Bare host name or address with trailing slash is invalid
conf.set(FS_DEFAULT_NAME_KEY, "nn_host/"); conf.set(FS_DEFAULT_NAME_KEY, "nn_host/");
try { intercept(IllegalArgumentException.class,
FileSystem.get(conf); "No scheme in default FS",
fail("Expect IAE: No scheme in default FS"); () -> FileSystem.get(conf));
} catch (IllegalArgumentException e) {
GenericTestUtils.assertExceptionContains(
"No scheme in default FS", e);
}
} }
} }

View File

@ -95,16 +95,14 @@ public void testDefaultFsUris() throws Exception {
try { try {
fs = FileSystem.get(URI.create("//host"), conf); fs = FileSystem.get(URI.create("//host"), conf);
fail("got fs with auth but no scheme"); fail("got fs with auth but no scheme");
} catch (Exception e) { } catch (UnsupportedFileSystemException e) {
assertEquals("No FileSystem for scheme: null", e.getMessage());
} }
// no scheme, different auth // no scheme, different auth
try { try {
fs = FileSystem.get(URI.create("//host2"), conf); fs = FileSystem.get(URI.create("//host2"), conf);
fail("got fs with auth but no scheme"); fail("got fs with auth but no scheme");
} catch (Exception e) { } catch (UnsupportedFileSystemException e) {
assertEquals("No FileSystem for scheme: null", e.getMessage());
} }
} }