HDFS-15418. CHeckstyle and test fixes
This commit is contained in:
parent
2d156bcbdd
commit
2c55c9a5cf
|
@ -213,8 +213,6 @@ public class ViewFileSystem extends FileSystem {
|
|||
InodeTree<FileSystem> fsState; // the fs state; ie the mount table
|
||||
Path homeDir = null;
|
||||
private boolean enableInnerCache = false;
|
||||
private static boolean showMountLinksAsSymlinks = true;
|
||||
|
||||
private InnerCache cache;
|
||||
// Default to rename within same mountpoint
|
||||
private RenameStrategy renameStrategy = RenameStrategy.SAME_MOUNTPOINT;
|
||||
|
@ -271,9 +269,6 @@ public class ViewFileSystem extends FileSystem {
|
|||
config = conf;
|
||||
enableInnerCache = config.getBoolean(CONFIG_VIEWFS_ENABLE_INNER_CACHE,
|
||||
CONFIG_VIEWFS_ENABLE_INNER_CACHE_DEFAULT);
|
||||
showMountLinksAsSymlinks = config
|
||||
.getBoolean(CONFIG_VIEWFS_MOUNT_LINKS_AS_SYMLINKS,
|
||||
CONFIG_VIEWFS_MOUNT_LINKS_AS_SYMLINKS_DEFAULT);
|
||||
FsGetter fsGetter = fsGetter();
|
||||
final InnerCache innerCache = new InnerCache(fsGetter);
|
||||
// Now build client side view (i.e. client side mount table) from config.
|
||||
|
@ -1121,6 +1116,7 @@ public class ViewFileSystem extends FileSystem {
|
|||
final long creationTime; // of the the mount table
|
||||
final UserGroupInformation ugi; // the user/group of user who created mtable
|
||||
final URI myUri;
|
||||
final boolean showMountLinksAsSymlinks;
|
||||
|
||||
public InternalDirOfViewFs(final InodeTree.INodeDir<FileSystem> dir,
|
||||
final long cTime, final UserGroupInformation ugi, URI uri,
|
||||
|
@ -1134,6 +1130,9 @@ public class ViewFileSystem extends FileSystem {
|
|||
theInternalDir = dir;
|
||||
creationTime = cTime;
|
||||
this.ugi = ugi;
|
||||
showMountLinksAsSymlinks = config
|
||||
.getBoolean(CONFIG_VIEWFS_MOUNT_LINKS_AS_SYMLINKS,
|
||||
CONFIG_VIEWFS_MOUNT_LINKS_AS_SYMLINKS_DEFAULT);
|
||||
}
|
||||
|
||||
static private void checkPathIsSlash(final Path f) throws IOException {
|
||||
|
@ -1240,9 +1239,9 @@ public class ViewFileSystem extends FileSystem {
|
|||
}
|
||||
|
||||
// We will represent as non-symlinks. Here it will show target
|
||||
// directories properties like permissions, isDirectory etc on mount
|
||||
// path. The path will be a mount link path and isDirectory is true
|
||||
// if target is dir, otherwise false.
|
||||
// directory/file properties like permissions, isDirectory etc on
|
||||
// mount path. The path will be a mount link path and isDirectory is
|
||||
// true if target is dir, otherwise false.
|
||||
String linkedPath = link.getTargetFileSystem().getUri().getPath();
|
||||
if ("".equals(linkedPath)) {
|
||||
linkedPath = "/";
|
||||
|
@ -1257,10 +1256,9 @@ public class ViewFileSystem extends FileSystem {
|
|||
status.getPermission(), status.getOwner(), status.getGroup(),
|
||||
null, path);
|
||||
} catch (FileNotFoundException ex) {
|
||||
LOG.warn(
|
||||
"Cannot get one of the children's(" + path + ") target path("
|
||||
+ link.getTargetFileSystem().getUri() + linkedPath
|
||||
+ ") file status.", ex);
|
||||
LOG.warn("Cannot get one of the children's(" + path
|
||||
+ ") target path(" + link.getTargetFileSystem().getUri()
|
||||
+ ") file status.", ex);
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1007,8 +1007,7 @@ public class ViewFs extends AbstractFileSystem {
|
|||
* will be listed in the returned result.
|
||||
*/
|
||||
@Override
|
||||
public FileStatus[] listStatus(final Path f) throws AccessControlException,
|
||||
IOException {
|
||||
public FileStatus[] listStatus(final Path f) throws IOException {
|
||||
checkPathIsSlash(f);
|
||||
FileStatus[] fallbackStatuses = listStatusForFallbackLink();
|
||||
FileStatus[] result = new FileStatus[theInternalDir.getChildren().size()];
|
||||
|
@ -1034,9 +1033,9 @@ public class ViewFs extends AbstractFileSystem {
|
|||
}
|
||||
|
||||
// We will represent as non-symlinks. Here it will show target
|
||||
// directories properties like permissions, isDirectory etc on mount
|
||||
// path. The path will be a mount link path and isDirectory is true
|
||||
// if target is dir, otherwise false.
|
||||
// directory/file properties like permissions, isDirectory etc on
|
||||
// mount path. The path will be a mount link path and isDirectory is
|
||||
// true if target is dir, otherwise false.
|
||||
String linkedPath = link.getTargetFileSystem().getUri().getPath();
|
||||
if ("".equals(linkedPath)) {
|
||||
linkedPath = "/";
|
||||
|
@ -1050,13 +1049,12 @@ public class ViewFs extends AbstractFileSystem {
|
|||
status.getModificationTime(), status.getAccessTime(),
|
||||
status.getPermission(), status.getOwner(), status.getGroup(),
|
||||
null, path);
|
||||
} catch (FileNotFoundException ex){
|
||||
LOG.warn(
|
||||
"Cannot get one of the children's(" + path + ") target path("
|
||||
+ link.getTargetFileSystem().getUri() + linkedPath
|
||||
+ ") file status.", ex);
|
||||
throw ex;
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
LOG.warn("Cannot get one of the children's(" + path
|
||||
+ ") target path(" + link.getTargetFileSystem().getUri()
|
||||
+ ") file status.", ex);
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
result[i++] = new FileStatus(0, true, 0, 0,
|
||||
creationTime, creationTime,
|
||||
|
|
|
@ -30,21 +30,17 @@ import org.apache.hadoop.fs.FileUtil;
|
|||
import org.apache.hadoop.fs.FsConstants;
|
||||
import org.apache.hadoop.fs.LocalFileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.fs.contract.ContractTestUtils;
|
||||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.io.DataInputBuffer;
|
||||
import org.apache.hadoop.io.DataOutputBuffer;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* ViewFsOverloadScheme ListStatus
|
||||
* ViewFsOverloadScheme ListStatus.
|
||||
*/
|
||||
public class TestViewFsOverloadSchemeListStatus {
|
||||
|
||||
|
@ -64,7 +60,8 @@ public class TestViewFsOverloadSchemeListStatus {
|
|||
* Tests the ACL and isDirectory returned from listStatus for directories and
|
||||
* files.
|
||||
*/
|
||||
@Test public void testListStatusACL() throws IOException, URISyntaxException {
|
||||
@Test
|
||||
public void testListStatusACL() throws IOException, URISyntaxException {
|
||||
String testfilename = "testFileACL";
|
||||
String childDirectoryName = "testDirectoryACL";
|
||||
TEST_DIR.mkdirs();
|
||||
|
@ -81,24 +78,24 @@ public class TestViewFsOverloadSchemeListStatus {
|
|||
Configuration conf = new Configuration();
|
||||
ConfigUtil.addLink(conf, "/file", infile.toURI());
|
||||
ConfigUtil.addLink(conf, "/dir", childDir.toURI());
|
||||
String FILE_SCHEME = "file";
|
||||
conf.set(String.format("fs.%s.impl", FILE_SCHEME),
|
||||
String fileScheme = "file";
|
||||
conf.set(String.format("fs.%s.impl", fileScheme),
|
||||
ViewFileSystemOverloadScheme.class.getName());
|
||||
conf.set(String
|
||||
.format(FsConstants.FS_VIEWFS_OVERLOAD_SCHEME_TARGET_FS_IMPL_PATTERN,
|
||||
FILE_SCHEME), LocalFileSystem.class.getName());
|
||||
String FILE_URI_STR = "file:///";
|
||||
try (FileSystem vfs = FileSystem.get(new URI(FILE_URI_STR), conf)) {
|
||||
fileScheme), LocalFileSystem.class.getName());
|
||||
String fileUriStr = "file:///";
|
||||
try (FileSystem vfs = FileSystem.get(new URI(fileUriStr), conf)) {
|
||||
assertEquals(ViewFileSystemOverloadScheme.class, vfs.getClass());
|
||||
FileStatus[] statuses = vfs.listStatus(new Path("/"));
|
||||
|
||||
FileSystem localFs = ((ViewFileSystemOverloadScheme) vfs)
|
||||
.getRawFileSystem(new Path(FILE_URI_STR), conf);
|
||||
.getRawFileSystem(new Path(fileUriStr), conf);
|
||||
FileStatus fileStat = localFs.getFileStatus(new Path(infile.getPath()));
|
||||
FileStatus dirStat = localFs.getFileStatus(new Path(childDir.getPath()));
|
||||
|
||||
for (FileStatus status : statuses) {
|
||||
if (status.getPath().getName().equals(FILE_SCHEME)) {
|
||||
if (status.getPath().getName().equals(fileScheme)) {
|
||||
assertEquals(fileStat.getPermission(), status.getPermission());
|
||||
} else {
|
||||
assertEquals(dirStat.getPermission(), status.getPermission());
|
||||
|
@ -112,7 +109,7 @@ public class TestViewFsOverloadSchemeListStatus {
|
|||
|
||||
statuses = vfs.listStatus(new Path("/"));
|
||||
for (FileStatus status : statuses) {
|
||||
if (status.getPath().getName().equals(FILE_SCHEME)) {
|
||||
if (status.getPath().getName().equals(fileScheme)) {
|
||||
assertEquals(FsPermission.valueOf("-rwxr--r--"),
|
||||
status.getPermission());
|
||||
assertEquals(false, status.isDirectory());
|
||||
|
@ -125,7 +122,8 @@ public class TestViewFsOverloadSchemeListStatus {
|
|||
}
|
||||
}
|
||||
|
||||
@AfterClass public static void cleanup() throws IOException {
|
||||
@AfterClass
|
||||
public static void cleanup() throws IOException {
|
||||
FileUtil.fullyDelete(TEST_DIR);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,11 @@ public class TestViewFileSystemOverloadSchemeHdfsFileSystemContract
|
|||
assumeTrue(rootDirTestEnabled());
|
||||
Path dir = path("/");
|
||||
Path child = path("/FileSystemContractBaseTest");
|
||||
try (FileSystem dfs = ((ViewFileSystemOverloadScheme) fs).getRawFileSystem(
|
||||
new Path(conf.get(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY), "/"),
|
||||
conf)) {
|
||||
dfs.mkdirs(child);
|
||||
}
|
||||
assertListStatusFinds(dir, child);
|
||||
}
|
||||
|
||||
|
|
|
@ -191,8 +191,17 @@ public class TestViewFileSystemOverloadSchemeWithHdfsScheme {
|
|||
new String[] {hdfsTargetPath.toUri().toString(),
|
||||
localTargetDir.toURI().toString() },
|
||||
conf);
|
||||
try (DistributedFileSystem dfs = new DistributedFileSystem()) {
|
||||
dfs.initialize(defaultFSURI, conf);
|
||||
dfs.mkdirs(hdfsTargetPath);
|
||||
}
|
||||
|
||||
try (RawLocalFileSystem lfs = new RawLocalFileSystem()) {
|
||||
lfs.initialize(localTargetDir.toURI(), conf);
|
||||
lfs.mkdirs(new Path(localTargetDir.toURI()));
|
||||
}
|
||||
try (FileSystem fs = FileSystem.get(conf)) {
|
||||
fs.mkdirs(hdfsTargetPath);
|
||||
FileStatus[] ls = fs.listStatus(new Path("/"));
|
||||
Assert.assertEquals(2, ls.length);
|
||||
String lsPath1 =
|
||||
|
|
Loading…
Reference in New Issue