hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuc...@apache.org
Subject [hbase] branch branch-1 updated: HBASE-21987 Simplify RSGroupInfoManagerImpl#flushConfig() for offline mode
Date Mon, 11 Mar 2019 21:12:29 GMT
This is an automated email from the ASF dual-hosted git repository.

xucang pushed a commit to branch branch-1
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-1 by this push:
     new 6bbf363  HBASE-21987 Simplify RSGroupInfoManagerImpl#flushConfig() for offline mode
6bbf363 is described below

commit 6bbf363b6c12805e01848566079dde0458385a88
Author: Xiang Li <lixiang@freewheel.tv>
AuthorDate: Sat Mar 9 03:53:17 2019 +0000

    HBASE-21987 Simplify RSGroupInfoManagerImpl#flushConfig() for offline mode
    
    Signed-off-by: Xu Cang <xucang@apache.org>
---
 .../hbase/rsgroup/RSGroupInfoManagerImpl.java      | 29 +++++++++++++++++-----
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
index 12c4faf..2fcaf03 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
@@ -388,20 +388,37 @@ public class RSGroupInfoManagerImpl implements RSGroupInfoManager, ServerListene
     Map<TableName, String> newTableMap;
 
     // For offline mode persistence is still unavailable
-    // We're refreshing in-memory state but only for default servers
+    // We're refreshing in-memory state but only for servers in default group
     if (!isOnline()) {
-      Map<String, RSGroupInfo> m = Maps.newHashMap(rsGroupMap);
-      RSGroupInfo oldDefaultGroup = m.remove(RSGroupInfo.DEFAULT_GROUP);
+      if (newGroupMap == this.rsGroupMap) {
+        // When newGroupMap is this.rsGroupMap itself,
+        // do not need to check default group and other groups as followed
+        return;
+      }
+
+      Map<String, RSGroupInfo> oldGroupMap = Maps.newHashMap(rsGroupMap);
+      RSGroupInfo oldDefaultGroup = oldGroupMap.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");
+      if (!oldGroupMap.equals(newGroupMap) /* compare both tables and servers in other groups
*/ ||
+          !oldDefaultGroup.getTables().equals(newDefaultGroup.getTables())
+          /* compare tables in default group */) {
+        throw new IOException("Only servers in default group can be updated during offline
mode");
       }
+
+      // Restore newGroupMap by putting its default group back
       newGroupMap.put(RSGroupInfo.DEFAULT_GROUP, newDefaultGroup);
+
+      // Refresh rsGroupMap
+      // according to the inputted newGroupMap (an updated copy of rsGroupMap)
       rsGroupMap = newGroupMap;
+
+      // Do not need to update tableMap
+      // because only the update on servers in default group is allowed above,
+      // or IOException will be thrown
       return;
     }
 
+    /* For online mode, persist to Zookeeper */
     newTableMap = flushConfigTable(newGroupMap);
 
     // make changes visible since it has been


Mime
View raw message