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

Improve RSGroupBasedLoadBalancer#filterServers() to be more efficient

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0-beta-2, 1.4.2, 2.0.0
    • Component/s: rsgroup
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupBasedLoadBalancer.java
      private List<ServerName> filterServers(Collection<Address> servers,
          Collection<ServerName> onlineServers) {
        ArrayList<ServerName> finalList = new ArrayList<ServerName>();
        for (Address server : servers) {
          for(ServerName curr: onlineServers) {
            if(curr.getAddress().equals(server)) {
              finalList.add(curr);
            }
          }
        }
        return finalList;
      }
      

      filterServers is to return the union of servers and onlineServers. The current implementation has time complexity as O(m * n) (2 loops), could be in O(m + n) if HashSet is used. The trade-off is space complexity is increased.

      Another point which could be improved: filterServers() is only called in filterOfflineServers(). filterOfflineServers calls filterServers(Set, List). The current filterServers(Collection, Collection) seems could be improved.

        Attachments

        1. HBASE-19917.master.001.patch
          2 kB
          Xiang Li
        2. HBASE-19917.master.000.patch
          3 kB
          Xiang Li
        3. HBASE-19917.branch-1.000.patch
          3 kB
          Xiang Li

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: