-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream #5064
Conversation
Improve FSUtils to directly obtain FSDataOutputStream
As replied on jira, we need to know whether it is OK to change to use the builder API, as not all hadoop versions have this API. Please check the compatibility matrix of HBase and also check which version does hadoop begin to add the builder API support. |
thanks,i have confirmed that earlier versions of Hadoop did not have this API, [2.9.0], [3.0.0-alpha4] hadoop began to add the builder API support. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Please run Thanks. |
Ok, I'll do it |
Improve FSUtils to directly obtain FSDataOutputStream fix style error
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
@Apache9 hello, I do not know the reason for this check failed, please tell me how to solve this check failed , thank you!! |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Improve FSUtils to directly obtain FSDataOutputStream fix npe
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@Apache9 Hello, I have fixed this error, thank you very much for your patience, some places are not familiar with the first submission. thanks!!! |
} | ||
builder.recursive(); | ||
return builder.build(); | ||
} catch (IllegalArgumentException | SecurityException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to catch these exceptions? They are all RuntimeException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my idea to communicate with you, the builder.build () is executed in addition to throw an IOException, code will throw a runtime exception: IllegalArgumentException, the main purpose of handling a catch IllegalArgumentException is to prevent code from returning. the code can go down to get the normal stream (non favoritenodes) and the method still works; the SecurityException looks a little redundant,Maybe I need to remove the SecurityException?
FSDataOutputStreamBuilder.build():
/**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically we should not catch RuntimeException. Here, the IllegalArgumentException means we misuse the builder API, for exmaple, forget to specify some necessary parameters. We should fix our code instead of catching the exception and going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I see. I have removed the RuntimeExceptions
Improve FSUtils to directly obtain FSDataOutputStream do not catch RuntimeException
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
LOG.debug("Ignoring (most likely Reflection related exception) " + e); | ||
DistributedFileSystem.HdfsDataOutputStreamBuilder builder = | ||
((DistributedFileSystem) backingFs).createFile(path).recursive().permission(perm).create() | ||
.overwrite(true).bufferSize(CommonFSUtils.getDefaultBufferSize(backingFs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for builder pattern, if we just want to use the default value, then we just do not call the method?
For here, bufferSize and blockSize are not needed, and replication is not needed if replication parameter is not greater than 0.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, for some properties that use default values we do not need to call methods .
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
) Co-authored-by: alanzhao <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 59fdaa2)
) Co-authored-by: alanzhao <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 59fdaa2)
) Co-authored-by: alanzhao <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 59fdaa2)
…ache#5064) Co-authored-by: alanzhao <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 59fdaa2) (cherry picked from commit 11d3a9d) Change-Id: I38911d73d4645e555853f08590d4a98e6aee7fa0
JIRAID:HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream
jira: https://issues.apache.org/jira/browse/HBASE-27670