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

Xiang Li updated HBASE-21987:
-----------------------------
    Description: 
The logic of offline mode for RSGroupInfoManagerImpl#flushConfig(Map<String, 
RSGroupInfo> newGroupMap) could be simplified.
{code:title=RSGroupInfoManagerImpl.java|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 sometimes is called by 
{code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
private synchronized void flushConfig() throws IOException {
    flushConfig(this.rsGroupMap);
}
{code}
by RSGroupInfoManagerImpl.RSGroupStartupWorker#waitForGroupTableOnline() during 
HMaster starts
When newGroupMap (the input of flushConfig() is this.rsGroupMap, the comparison 
is not needed, as they are the same.

  was:
The logic of offline mode for RSGroupInfoManagerImpl#flushConfig(Map<String, 
RSGroupInfo> newGroupMap) could be simplified.
{code:title=RSGroupInfoManagerImpl.java|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 sometimes is called by 
{code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
private synchronized void flushConfig() throws IOException {
    flushConfig(this.rsGroupMap);
}
{code}
by RSGroupInfoManagerImpl.RSGroupStartupWorker#waitForGroupTableOnline() during 
HMaster starts
When newGroupMap (the input of flushConfig() is this.rsGroupMap, the 
comparision is not needed, as they are the same.


> 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
>
> The logic of offline mode for RSGroupInfoManagerImpl#flushConfig(Map<String, 
> RSGroupInfo> newGroupMap) could be simplified.
> {code:title=RSGroupInfoManagerImpl.java|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 sometimes is called by 
> {code:title=RSGroupInfoManagerImpl.java|borderStyle=solid}
> private synchronized void flushConfig() throws IOException {
>     flushConfig(this.rsGroupMap);
> }
> {code}
> by RSGroupInfoManagerImpl.RSGroupStartupWorker#waitForGroupTableOnline() 
> during HMaster starts
> When newGroupMap (the input of flushConfig() is this.rsGroupMap, the 
> comparison is not needed, as they are the same.



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

Reply via email to