Use FileSystem.openFile with FileStatus to reduce NameNode RPCs#6460
Use FileSystem.openFile with FileStatus to reduce NameNode RPCs#6460dlmarion wants to merge 2 commits into
Conversation
This commit changes how we open Hadoop files for reading. Instead of calling Filesystem.open this changes the code to use FileSystem.openFile. The openFile method returns a Builder object that has a setter method for a FileStatus object. HDFS-17593 adds logic to the DFSClient to use the located blocks in the FileStatus to reduce NameNode RPCs to get the block locations. This is useful in code where we happen to already have the FileStatus object for the associated file that we want to open.
|
The places in the 2.1 code that can currently take advantage of this are in the bulk import code, FileUtils, and RecoveryLogsIterator. FYI that HDFS-17593 has been merged into the un-released Hadoop 3.5.1 and 3.6.0 versions. The changes are compatible with the current Hadoop dependency, but not with older versions. We would need to change our minimum compatibility level for Hadoop from 3.0.3 to 3.3.0. |
|
This change requires #6461 to pass the build checks |
ctubbsii
left a comment
There was a problem hiding this comment.
null is used a lot. Instead of adding a nullable parameter, it'd be better to overload the forFile method with a version that requires the parameter (requireNonNull) and one that omits it. The diff would be a lot smaller that way, as code that passes null wouldn't need to change.
I agree, but I think I'd rather fix this in a follow-on issue. Breaking the code by adding the parameter allows me to quickly identify broken code and evaluate whether or not a FileStatus for the file already exists. If I add the overloaded method before I merge to main, then I probably have to re-evaluate things I've already looked at. |
This commit changes how we open Hadoop files for reading. Instead of calling Filesystem.open this changes the code to use FileSystem.openFile. The openFile method returns a Builder object that has a setter method for a FileStatus object. HDFS-17593 adds logic to the DFSClient to use the located blocks in the FileStatus to reduce NameNode RPCs to get the block locations. This is useful in code where we happen to already have the FileStatus object for the associated file that we want to open.