You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/08/20 06:56:12 UTC

[GitHub] [hbase] infraio commented on a change in pull request #498: HBASE-22819 Automatically migrate the rs group config for table after…

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_r315531254
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupInfoManagerImpl.java
 ##########
 @@ -356,9 +363,129 @@ public synchronized void removeServers(Set<Address> servers) throws IOException
     return RSGroupInfoList;
   }
 
-  @Override
-  public void refresh() throws IOException {
-    refresh(false);
+  private void waitUntilSomeProcsDone(Set<Long> pendingProcIds) {
+    int size = pendingProcIds.size();
+    while (!masterServices.isStopped()) {
+      for (Iterator<Long> iter = pendingProcIds.iterator(); iter.hasNext();) {
+        long procId = iter.next();
+        if (masterServices.getMasterProcedureExecutor().isFinished(procId)) {
+          iter.remove();
+        }
+      }
+      if (pendingProcIds.size() < size) {
+        return;
+      }
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
+    }
+  }
+
+  private void waitUntilMasterStarted() {
+    while (!masterServices.isInitialized() && !masterServices.isStopped()) {
+      try {
+        Thread.sleep(1000);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
+    }
+  }
+
+  private void migrate(Collection<RSGroupInfo> groupList, int maxConcurrency) {
+    waitUntilMasterStarted();
+    Set<Long> pendingProcIds = new HashSet<>();
+    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 = masterServices.getTableDescriptors().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();
+        try {
+          pendingProcIds.add(
 
 Review comment:
   For the user which used RSGroup feature a lot, when user restart master with new code, this migrate thing will reopen all regions... This is not friendly for user? Can we finish this job by a tool? Only use the tool to change the TableDescriptor first, then upgrade cluster to new version code.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services