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

Simplify RSGroupInfoManagerImpl#flushConfig() for offline mode

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0.0, 1.5.0, 2.2.0
    • Component/s: rsgroup
    • Labels:

      Description

      The logic to handle offline mode in RSGroupInfoManagerImpl#flushConfig(Map<String, RSGroupInfo> newGroupMap) could be simplified.

      RSGroupInfoManagerImpl.java # flushConfig(Map<String, RSGroupInfo> newGroupMap)
      if (!isOnline()) {
          Map<String, RSGroupInfo> m = Maps.newHashMap(rsGroupMap);
          RSGroupInfo oldDefaultGroup = m.remove(RSGroupInfo.DEFAULT_GROUP);
          RSGroupInfo newDefaultGroup = newGroupMap.remove(RSGroupInfo.DEFAULT_GROUP);
          if (!m.equals(newGroupMap) ||
              !oldDefaultGroup.getTables().equals(newDefaultGroup.getTables())) {
              throw new IOException("Only default servers can be updated during offline mode");
          }
          newGroupMap.put(RSGroupInfo.DEFAULT_GROUP, newDefaultGroup);
          rsGroupMap = newGroupMap;
          return;
       }
      

      The logic is to make a copy of the private member called "rsGroupMap" as m, and get the default group out of m and newGroupMap and then compare. Then restore the newGroupMap and update rsGroupMap.
      This function is called by

      RSGroupInfoManagerImpl.java # flushConfig()
      private synchronized void flushConfig() throws IOException {
          flushConfig(this.rsGroupMap);
      }
      

      by RSGroupInfoManagerImpl.RSGroupStartupWorker#waitForGroupTableOnline() during HMaster starts, in which, newGroupMap (the input of flushConfig()) is this.rsGroupMap, the comparison is not needed, because they are the same.

        Attachments

        1. HBASE-21987.branch-1.000.patch
          3 kB
          Xiang Li
        2. HBASE-21987.master.004.patch
          3 kB
          Xiang Li
        3. HBASE-21987.master.003.patch
          3 kB
          Xiang Li
        4. HBASE-21987.master.002.patch
          3 kB
          Xiang Li
        5. HBASE-21987.master.001.patch
          3 kB
          Xiang Li
        6. HBASE-21987.master.000.patch
          1 kB
          Xiang Li

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: