Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,26 @@ public boolean delete(final Path f)
public BlockLocation[] getFileBlockLocations(final FileStatus fs,
final long start, final long len) throws
FileNotFoundException, IOException {

// When application calls listFiles on internalDir, it would return
// RemoteIterator from InternalDirOfViewFs. If there is a fallBack, there
// is a chance of files exists under that internalDir in fallback.
// Iterator#next will call getFileBlockLocations with that files. So, we
// should return getFileBlockLocations on fallback. See HDFS-15532.
if (fs.getPath() != InodeTree.SlashPath && this.fsState
.getRootFallbackLink() != null) {
FileSystem linkedFallbackFs =
this.fsState.getRootFallbackLink().getTargetFileSystem();
Path parent = Path.getPathWithoutSchemeAndAuthority(
new Path(theInternalDir.fullPath));
String leafChild = (InodeTree.SlashPath.equals(fs.getPath())) ?
InodeTree.SlashPath.toString() :
fs.getPath().getName();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(InodeTree.SlashPath.equals(fs.getPath()))
In which case this would be true? Provided there is a check in the if condition

Copy link
Contributor Author

@umamaheswararao umamaheswararao Sep 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ayushtkn for review! I have removed this redundant condition.
I realized that, this bug exist in ViewFs as well. I fixed and added a test case for it. Thanks

Path pathToFallbackFs = new Path(parent, leafChild);
return linkedFallbackFs
.getFileBlockLocations(pathToFallbackFs, start, len);
}

checkPathIsSlash(fs.getPath());
throw new FileNotFoundException("Path points to dir not a file");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

import java.io.File;
Expand Down Expand Up @@ -86,9 +85,4 @@ public void testRenameRootDirForbidden() throws Exception {
super.testRenameRootDirForbidden();
});
}

@Ignore("Ignore this test until HDFS-15532")
@Override
public void testLSRootDir() throws Throwable {
}
}