ddupg commented on a change in pull request #1550:
URL: https://github.com/apache/hbase/pull/1550#discussion_r414327347



##########
File path: 
hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
##########
@@ -535,17 +476,22 @@ public void preCreateTableAction(
       final ObserverContext<MasterCoprocessorEnvironment> ctx,
       final TableDescriptor desc,
       final RegionInfo[] regions) throws IOException {
-    if (!desc.getTableName().isSystemTable() && 
!rsgroupHasServersOnline(desc)) {
-      throw new HBaseIOException("No online servers in the rsgroup, which 
table " +
-          desc.getTableName().getNameAsString() + " belongs to");
+    if (desc.getTableName().isSystemTable()) {
+      return;
+    }
+    RSGroupInfo rsGroupInfo = 
groupInfoManager.determineRSGroupInfoForTable(desc.getTableName());
+    if (rsGroupInfo == null) {
+      throw new ConstraintException("Default RSGroup for this table " + 
desc.getTableName()
+        + " does not exist.");
+    }
+    if (!RSGroupUtil.rsGroupHasOnlineServer(master, rsGroupInfo)) {
+      throw new HBaseIOException("No online servers in the rsgroup " + 
rsGroupInfo.getName()
+        + " which table " + desc.getTableName().getNameAsString() + " belongs 
to");
+    }
+    synchronized (groupInfoManager) {
+      groupInfoManager.moveTables(
+        Collections.singleton(desc.getTableName()), rsGroupInfo.getName());
     }
-  }
-
-  // Assign table to default RSGroup.
-  @Override
-  public void postCreateTable(ObserverContext<MasterCoprocessorEnvironment> 
ctx,

Review comment:
       Method assignTableToGroup do two things:
   1. groupInfoManager.moveTables to store which group that the table belong to
   2. move regions. In this case, it always fails.
   we just need to do the first one in preCreateTableAction, 
CreateTableProcedure will assign regions to right RS via RSGroupableBalancer.

##########
File path: 
hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java
##########
@@ -535,17 +476,22 @@ public void preCreateTableAction(
       final ObserverContext<MasterCoprocessorEnvironment> ctx,
       final TableDescriptor desc,
       final RegionInfo[] regions) throws IOException {
-    if (!desc.getTableName().isSystemTable() && 
!rsgroupHasServersOnline(desc)) {
-      throw new HBaseIOException("No online servers in the rsgroup, which 
table " +
-          desc.getTableName().getNameAsString() + " belongs to");
+    if (desc.getTableName().isSystemTable()) {
+      return;
+    }
+    RSGroupInfo rsGroupInfo = 
groupInfoManager.determineRSGroupInfoForTable(desc.getTableName());
+    if (rsGroupInfo == null) {
+      throw new ConstraintException("Default RSGroup for this table " + 
desc.getTableName()
+        + " does not exist.");
+    }
+    if (!RSGroupUtil.rsGroupHasOnlineServer(master, rsGroupInfo)) {
+      throw new HBaseIOException("No online servers in the rsgroup " + 
rsGroupInfo.getName()
+        + " which table " + desc.getTableName().getNameAsString() + " belongs 
to");
+    }
+    synchronized (groupInfoManager) {
+      groupInfoManager.moveTables(
+        Collections.singleton(desc.getTableName()), rsGroupInfo.getName());
     }
-  }
-
-  // Assign table to default RSGroup.
-  @Override
-  public void postCreateTable(ObserverContext<MasterCoprocessorEnvironment> 
ctx,

Review comment:
       Method assignTableToGroup do two things:
   1. groupInfoManager.moveTables to store which group that the table belong to
   2. move regions. In this case, it always fails.
   
   we just need to do the first one in preCreateTableAction, 
CreateTableProcedure will assign regions to right RS via RSGroupableBalancer.




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


Reply via email to