You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/03/04 14:53:36 UTC
[hbase] branch branch-2.5 updated: HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream (#5064)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-2.5
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.5 by this push:
new 4effc85e444 HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream (#5064)
4effc85e444 is described below
commit 4effc85e444386130d077cb1b2e69ab64084c1af
Author: alan.zhao <30...@users.noreply.github.com>
AuthorDate: Sat Mar 4 21:46:45 2023 +0800
HBASE-27670 Improve FSUtils to directly obtain FSDataOutputStream (#5064)
Co-authored-by: alanzhao <al...@126.com>
Signed-off-by: Duo Zhang <zh...@apache.org>
(cherry picked from commit 59fdaa28f726dcd65fbfb58f9ea6aa499f2a903c)
---
.../java/org/apache/hadoop/hbase/util/FSUtils.java | 28 ++++++++--------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 6e4fb8a91f3..728a46b51a4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -85,7 +85,6 @@ import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.util.Progressable;
import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
@@ -199,27 +198,20 @@ public final class FSUtils {
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();
+ if (favoredNodes != null) {
+ builder.favoredNodes(favoredNodes);
+ }
+ if (replication > 0) {
+ builder.replication(replication);
}
+ return builder.build();
}
+
}
return CommonFSUtils.create(fs, path, perm, true);
}