haohao0103 commented on code in PR #5064:
URL: https://github.com/apache/hbase/pull/5064#discussion_r1125421633
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java:
##########
@@ -198,27 +197,20 @@ public static FSDataOutputStream create(Configuration
conf, FileSystem fs, Path
if (fs instanceof HFileSystem) {
FileSystem backingFs = ((HFileSystem) fs).getBackingFs();
if (backingFs instanceof DistributedFileSystem) {
- // Try to use the favoredNodes version via reflection to allow
backwards-
- // compatibility.
short replication =
Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION,
String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION)));
- try {
- return (FSDataOutputStream) (DistributedFileSystem.class
- .getDeclaredMethod("create", Path.class, FsPermission.class,
boolean.class, int.class,
- short.class, long.class, Progressable.class,
InetSocketAddress[].class)
- .invoke(backingFs, path, perm, true,
CommonFSUtils.getDefaultBufferSize(backingFs),
- replication > 0 ? replication :
CommonFSUtils.getDefaultReplication(backingFs, path),
- CommonFSUtils.getDefaultBlockSize(backingFs, path), null,
favoredNodes));
- } catch (InvocationTargetException ite) {
- // Function was properly called, but threw it's own exception.
- throw new IOException(ite.getCause());
- } catch (NoSuchMethodException e) {
- LOG.debug("DFS Client does not support most favored nodes create;
using default create");
- LOG.trace("Ignoring; use default create", e);
- } catch (IllegalArgumentException | SecurityException |
IllegalAccessException e) {
- 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))
Review Comment:
yes, for some properties that use default values we do not need to call
methods .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]