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

Improve RSGroupInfoManagerImpl#getDefaultServers()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 3.0.0-alpha-1, 1.5.0, 2.2.0
    • rsgroup
    • None

    Description

      RSGroupInfoManagerImpl.java
      private SortedSet<Address> getDefaultServers() throws IOException {
        SortedSet<Address> defaultServers = Sets.newTreeSet();
        for (ServerName serverName : getOnlineRS()) {
          Address server = Address.fromParts(serverName.getHostname(), serverName.getPort());
          boolean found = false;
          for (RSGroupInfo rsgi : listRSGroups()) {
            if (!RSGroupInfo.DEFAULT_GROUP.equals(rsgi.getName()) && rsgi.containsServer(server)) {
              found = true;
              break;
            }
          }
          if (!found) {
            defaultServers.add(server);
          }
        }
        return defaultServers;
      }
      

      That is a logic of 2 nested loops. And for each server, listRSGroups() allocates a new LinkedList and calls Map#values(), both of which are very heavy operations.

      Maybe the inner loop could be moved out, that is

      1. Build a list of servers of other groups than default group
      2. Iterate each online servers and check if it is in the list above. If it is not, then it belongs to default group.

      Attachments

        1. HBASE-22009.master.000.patch
          2 kB
          Xiang Li
        2. call_stack_getDefaultServers.png
          167 kB
          Xiang Li
        3. HBASE-22009.branch-1.000.patch
          2 kB
          Xiang Li
        4. HBASE-22009.master.000.addendum.patch
          2 kB
          Xiang Li

        Activity

          People

            xiangli Xiang Li
            xiangli Xiang Li
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: