hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-19088 move_tables_rsgroup will throw an exception when the table is disabled
Date Wed, 08 Nov 2017 01:39:24 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 264cf0d47 -> dc1310f48


HBASE-19088 move_tables_rsgroup will throw an exception when the table is disabled

Signed-off-by: Andrew Purtell <apurtell@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/dc1310f4
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/dc1310f4
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/dc1310f4

Branch: refs/heads/branch-1
Commit: dc1310f48731c6855d7df7a93dea773e4d46e579
Parents: 264cf0d
Author: Guangxu Cheng <guangxucheng@gmail.com>
Authored: Mon Oct 30 16:29:40 2017 +0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Tue Nov 7 17:14:03 2017 -0800

----------------------------------------------------------------------
 .../hbase/rsgroup/RSGroupAdminServer.java       |  7 ++++
 .../hadoop/hbase/rsgroup/TestRSGroupsBase.java  | 34 ++++++++++++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/dc1310f4/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
index 13b3141..125e08e 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
@@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.master.RegionState;
 import org.apache.hadoop.hbase.master.ServerManager;
 import org.apache.hadoop.hbase.master.TableLockManager.TableLock;
 import org.apache.hadoop.hbase.net.Address;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 
 /**
  * Service to support Region Server Grouping (HBase-6721)
@@ -276,6 +277,12 @@ public class RSGroupAdminServer implements RSGroupAdmin {
       }
     }
     for(TableName table: tables) {
+      if (master.getAssignmentManager().getTableStateManager().isTableState(table,
+          ZooKeeperProtos.Table.State.DISABLED,
+          ZooKeeperProtos.Table.State.DISABLING)) {
+        LOG.debug("Skipping move regions because the table" + table + " is disabled.");
+        continue;
+      }
       TableLock lock = master.getTableLockManager().writeLock(table, "Group: table move");
       try {
         lock.acquire();

http://git-wip-us.apache.org/repos/asf/hbase/blob/dc1310f4/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
index 0db0fea..a0d1401 100644
--- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
+++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroupsBase.java
@@ -812,4 +812,38 @@ public abstract class TestRSGroupsBase {
     Set<TableName> newGroupTables = rsGroupAdmin.getRSGroupInfo(newGroup.getName()).getTables();
     assertTrue(newGroupTables.contains(tableName));
   }
+
+  @Test
+  public void testDisabledTableMove() throws Exception {
+    final TableName tableName = TableName.valueOf(tablePrefix + "_testDisabledTableMove");
+    final byte[] familyNameBytes = Bytes.toBytes("f");
+    String newGroupName = getGroupName("testDisabledTableMove");
+    final RSGroupInfo newGroup = addGroup(rsGroupAdmin, newGroupName, 2);
+
+    TEST_UTIL.createMultiRegionTable(tableName, familyNameBytes, 5);
+    TEST_UTIL.waitFor(WAIT_TIMEOUT, new Waiter.Predicate<Exception>() {
+      @Override
+      public boolean evaluate() throws Exception {
+        List<String> regions = getTableRegionMap().get(tableName);
+        if (regions == null) {
+          return false;
+        }
+        return getTableRegionMap().get(tableName).size() >= 5;
+      }
+    });
+
+    RSGroupInfo tableGrp = rsGroupAdmin.getRSGroupInfoOfTable(tableName);
+    assertTrue(tableGrp.getName().equals(RSGroupInfo.DEFAULT_GROUP));
+
+    //test disable table
+    admin.disableTable(tableName);
+
+    //change table's group
+    LOG.info("Moving table "+ tableName + " to " + newGroup.getName());
+    rsGroupAdmin.moveTables(Sets.newHashSet(tableName), newGroup.getName());
+
+    //verify group change
+    Assert.assertEquals(newGroup.getName(),
+        rsGroupAdmin.getRSGroupInfoOfTable(tableName).getName());
+  }
 }


Mime
View raw message