liuml07 commented on a change in pull request #1435: HBASE-24112 [RSGroup] Support renaming rsgroup URL: https://github.com/apache/hbase/pull/1435#discussion_r405178082
########## File path: hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java ########## @@ -1221,4 +1221,32 @@ 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); + Set<TableName> updateTables = new HashSet<>(); Review comment: ``` Set<TableName> updateTables = new HashSet<>(); TableDescriptors tableDescriptors = masterServices.getTableDescriptors(); 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()); } } ``` can be replaced with, if stream is preferred, following code (not tested): ``` Set<TableName> updateTables = masterServices.getTableDescriptors().getAll().values() .stream() .filter(t -> oldName.equals(t.getRegionServerGroup().orElse(null))) .map(TableDescriptor::getTableName) .collect(Collectors.toSet()); ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services