infraio commented on a change in pull request #498: HBASE-22819 Automatically
migrate the rs group config for table after…
URL: https://github.com/apache/hbase/pull/498#discussion_r317335323
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
##########
@@ -356,9 +388,90 @@ public synchronized void removeServers(Set<Address>
servers) throws IOException
return RSGroupInfoList;
}
- @Override
- public void refresh() throws IOException {
- refresh(false);
+ private void migrate(Collection<RSGroupInfo> groupList) {
+ TableDescriptors tds = masterServices.getTableDescriptors();
+ for (RSGroupInfo groupInfo : groupList) {
+ if (groupInfo.getName().equals(RSGroupInfo.DEFAULT_GROUP)) {
+ continue;
+ }
+ SortedSet<TableName> failedTables = new TreeSet<>();
+ for (TableName tableName : groupInfo.getTables()) {
+ LOG.info("Migrating {} in group {}", tableName, groupInfo.getName());
+ TableDescriptor oldTd;
+ try {
+ oldTd = tds.get(tableName);
+ } catch (IOException e) {
+ LOG.warn("Failed to migrate {} in group {}", tableName,
groupInfo.getName(), e);
+ failedTables.add(tableName);
+ continue;
+ }
+ if (oldTd == null) {
+ continue;
+ }
+ if (oldTd.getRegionServerGroup().isPresent()) {
+ // either we have already migrated it or that user has set the rs
group using the new
+ // code which will set the group directly on table descriptor, skip.
+ LOG.debug("Skip migrating {} since it is already in group {}",
tableName,
+ oldTd.getRegionServerGroup().get());
+ continue;
+ }
+ TableDescriptor newTd = TableDescriptorBuilder.newBuilder(oldTd)
+ .setRegionServerGroup(groupInfo.getName()).build();
+ // This is a bit tricky. Since we know that the region server group
config in
+ // TableDescriptor will only be used at master side, it is fine to
just update the table
+ // descriptor on file system and also the cache, without reopening all
the regions. This
+ // will be much faster than the normal modifyTable. And when
upgrading, we will update
+ // master first and then region server, so after all the region
servers has been reopened,
+ // the new TableDescriptor will be loaded.
+ try {
+ tds.add(newTd);
+ } catch (IOException e) {
+ LOG.warn("Failed to migrate {} in group {}", tableName,
groupInfo.getName(), e);
+ failedTables.add(tableName);
+ continue;
+ }
+ }
+ LOG.info("Done migrating {}, failed tables {}", groupInfo.getName(),
failedTables);
+ synchronized (RSGroupInfoManagerImpl.this) {
+ Map<String, RSGroupInfo> rsGroupMap = holder.groupName2Group;
+ RSGroupInfo currentInfo = rsGroupMap.get(groupInfo.getName());
+ if (currentInfo != null) {
+ RSGroupInfo newInfo =
+ new RSGroupInfo(currentInfo.getName(), currentInfo.getServers(),
failedTables);
+ Map<String, RSGroupInfo> newGroupMap = new HashMap<>(rsGroupMap);
+ newGroupMap.put(groupInfo.getName(), newInfo);
+ try {
+ flushConfig(newGroupMap);
+ } catch (IOException e) {
+ LOG.warn("Failed to persist rs group", e);
Review comment:
log the rs group name?
----------------------------------------------------------------
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