Apache9 commented on a change in pull request #1435: HBASE-24112 [RSGroup] 
Support renaming rsgroup
URL: https://github.com/apache/hbase/pull/1435#discussion_r403817503
 
 

 ##########
 File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
 ##########
 @@ -1221,4 +1221,33 @@ public String determineRSGroupInfoForTable(TableName 
tableName) {
     return script.getRSGroup(tableName.getNamespaceAsString(), 
tableName.getQualifierAsString());
   }
 
+  @Override
+  public synchronized void renameRSGroup(String oldName, String newName) 
throws IOException {
+    if (oldName.equals(RSGroupInfo.DEFAULT_GROUP)) {
+      throw new ConstraintException(RSGroupInfo.DEFAULT_GROUP + " can't be 
rename");
+    }
+    checkGroupName(newName);
+
+    RSGroupInfo oldRSG = getRSGroupInfo(oldName);
+    Map<String, RSGroupInfo> rsGroupMap = holder.groupName2Group;
+    Map<String, RSGroupInfo> newGroupMap = Maps.newHashMap(rsGroupMap);
+    newGroupMap.remove(oldRSG.getName());
+    RSGroupInfo newRSG = new RSGroupInfo(newName, oldRSG.getServers());
+    newGroupMap.put(newName, newRSG);
+    flushConfig(newGroupMap);
+
+    TableDescriptors tableDescriptors = masterServices.getTableDescriptors();
+    Set<TableName> updateTables = new HashSet<>();
+    for (Map.Entry<String, TableDescriptor> table : 
tableDescriptors.getAll().entrySet()) {
+      Optional<String> rsgroup = table.getValue().getRegionServerGroup();
+      if (!rsgroup.isPresent()) {
+        continue;
+      }
+      if (rsgroup.get().equals(oldName)) {
+        updateTables.add(table.getValue().getTableName());
+      }
+    }
+    setRSGroup(updateTables, newName);
 
 Review comment:
   When you call setRSGroup here, all the regions will be reopened... No 
difference to the old implementation...
   
   I think the approach maybe possible on branch-2 but on master, it is a bit 
tricky as we need to change the table descriptor without reopening the regions, 
which may lead to unexpected behavior...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to