Apache9 commented on code in PR #5064:
URL: https://github.com/apache/hbase/pull/5064#discussion_r1124500270


##########
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:
   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.



-- 
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]

Reply via email to