Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-27670

Improve FSUtils to directly obtain FSDataOutputStream

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      hbase interacts with hdfs and obtains FSDataOutputStream to generate HFiles. In order to support favoredNodes, reflection is used. The DistributedFileSystem has a more direct way to get the FSDataOutputStream,for example:dfs.createFile(path).permission(perm).create()...;  this API allows you to set various parameters, including favoredNodes. I think avoiding reflection can improve performance, and if you agree with me, I can optimize this part of the code;

      Model:hbase-server

      class:FSUtils

       

      public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path path,
      FsPermission perm, InetSocketAddress[] favoredNodes) throws IOException {
      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));

      Attachments

        Issue Links

          Activity

            People

              alanlemma alan.zhao
              alanlemma alan.zhao
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: