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

 ##########
 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:
   Just pushed one commit to avoid region transitions (by direct API instead of 
procedure way), because the rename operations shouldn't require region 
transitions. And due to its an admin operation, sounds like reasonable to skip 
coprocessor hook.
   
   > which may lead to unexpected behavior...
   
   Let's see what QA says

----------------------------------------------------------------
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