[
https://issues.apache.org/jira/browse/HBASE-21987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16784199#comment-16784199
]
Xiang Li commented on HBASE-21987:
----------------------------------
Upload patch v000, a small change. [~xucang] Would you please review it at your
convenience to see if it make sense to you? If so, I would like to take this
chance to add some comments to the code in the context, to improve the
readability
> 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
>
>
> 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)