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

Provide RSGroupInfo with a new constructor using shallow copy

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Patch Available
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: rsgroup
    • Labels:
      None

      Description

      As for org.apache.hadoop.hbase.rsgroup.RSGroupInfo, the following constructor performs deep copies on both servers and tables inputed.

      hbase-common/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfo.java.java
      RSGroupInfo(String name, SortedSet<Address> servers, SortedSet<TableName> tables) {
        this.name = name;
        this.servers = (servers == null) ? new TreeSet<>() : new TreeSet<>(servers);
        this.tables  = (tables  == null) ? new TreeSet<>() : new TreeSet<>(tables);
      }
      

      The constructor of TreeSet is heavy and I think it is better to have a new constructor with shallow copy and it could be used at least in

      hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
      private synchronized void refresh(boolean forceOnline) throws IOException {
        ...
        groupList.add(new RSGroupInfo(RSGroupInfo.DEFAULT_GROUP, getDefaultServers(), orphanTables));
        ...
      

      It is not needed to allocate new TreeSet to deep copy the output of getDefaultServers() and orphanTables, both of which are allocated in the near context and not updated in the code followed. So it is safe to make a shadow copy here.

        Attachments

        1. HBASE-22031.master.002.patch
          4 kB
          Xiang Li
        2. HBASE-22031.master.001.patch
          4 kB
          Xiang Li
        3. HBASE-22031.master.000.patch
          4 kB
          Xiang Li

          Activity

            People

            • Assignee:
              water Xiang Li
              Reporter:
              water Xiang Li
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: