[ 
https://issues.apache.org/jira/browse/HBASE-21987?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Xiang Li updated HBASE-21987:
-----------------------------
    Status: Patch Available  (was: Open)

> Simplify RSGroupInfoManagerImpl#flushConfig() for offline mode
> --------------------------------------------------------------
>
>                 Key: HBASE-21987
>                 URL: https://issues.apache.org/jira/browse/HBASE-21987
>             Project: HBase
>          Issue Type: Improvement
>          Components: rsgroup
>            Reporter: Xiang Li
>            Assignee: Xiang Li
>            Priority: Minor
>         Attachments: HBASE-21987.master.000.patch, 
> HBASE-21987.master.001.patch, HBASE-21987.master.002.patch, 
> HBASE-21987.master.003.patch, HBASE-21987.master.004.patch
>
>
> The logic to handle offline mode in 
> RSGroupInfoManagerImpl#flushConfig(Map<String, RSGroupInfo> newGroupMap) 
> could be simplified.
> {code:title=RSGroupInfoManagerImpl.java # flushConfig(Map<String, 
> RSGroupInfo> newGroupMap)|borderStyle=solid}
> 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;
>  }
> {code}
> 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 
> {code:title=RSGroupInfoManagerImpl.java # flushConfig() |borderStyle=solid}
> private synchronized void flushConfig() throws IOException {
>     flushConfig(this.rsGroupMap);
> }
> {code}
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to