HBASE-17785 RSGroupBasedLoadBalancer fails to assign new table regions when cloning snapshot
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/029fa297 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/029fa297 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/029fa297 Branch: refs/heads/HBASE-16961 Commit: 029fa297129f7ced276d19c4877d19bf32dcfde0 Parents: cbcbcf4 Author: Andrew Purtell <apurt...@apache.org> Authored: Wed Apr 5 16:25:56 2017 -0700 Committer: Andrew Purtell <apurt...@apache.org> Committed: Wed Apr 5 16:25:56 2017 -0700 ---------------------------------------------------------------------- .../hbase/rsgroup/RSGroupAdminEndpoint.java | 28 ++++++++++++++------ .../hadoop/hbase/rsgroup/TestRSGroups.java | 19 +++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/029fa297/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java ---------------------------------------------------------------------- diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java index 83389e4..14907ba 100644 --- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java +++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminEndpoint.java @@ -67,6 +67,7 @@ import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.MoveTablesR import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RSGroupAdminService; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupRequest; import org.apache.hadoop.hbase.protobuf.generated.RSGroupAdminProtos.RemoveRSGroupResponse; +import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.SnapshotDescription; @InterfaceAudience.Private public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService { @@ -267,14 +268,7 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService } } - ///////////////////////////////////////////////////////////////////////////// - // MasterObserver overrides - ///////////////////////////////////////////////////////////////////////////// - - // Assign table to default RSGroup. - @Override - public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> ctx, - HTableDescriptor desc, HRegionInfo[] regions) throws IOException { + void assignTableToGroup(HTableDescriptor desc) throws IOException { String groupName = master.getClusterSchema().getNamespace(desc.getTableName().getNamespaceAsString()) .getConfigurationValue(RSGroupInfo.NAMESPACE_DESC_PROP_GROUP); @@ -292,6 +286,17 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService } } + ///////////////////////////////////////////////////////////////////////////// + // MasterObserver overrides + ///////////////////////////////////////////////////////////////////////////// + + // Assign table to default RSGroup. + @Override + public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> ctx, + HTableDescriptor desc, HRegionInfo[] regions) throws IOException { + assignTableToGroup(desc); + } + // Remove table from its RSGroup. @Override public void postDeleteTable(ObserverContext<MasterCoprocessorEnvironment> ctx, @@ -322,5 +327,12 @@ public class RSGroupAdminEndpoint implements MasterObserver, CoprocessorService NamespaceDescriptor ns) throws IOException { preCreateNamespace(ctx, ns); } + + @Override + public void preCloneSnapshot(ObserverContext<MasterCoprocessorEnvironment> ctx, + SnapshotDescription snapshot, HTableDescriptor desc) throws IOException { + assignTableToGroup(desc); + } + ///////////////////////////////////////////////////////////////////////////// } http://git-wip-us.apache.org/repos/asf/hbase/blob/029fa297/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java ---------------------------------------------------------------------- diff --git a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java index 3886684..d6bd43b 100644 --- a/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java +++ b/hbase-rsgroup/src/test/java/org/apache/hadoop/hbase/rsgroup/TestRSGroups.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.client.ClusterConnection; import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; import org.apache.hadoop.hbase.master.HMaster; import org.apache.hadoop.hbase.master.ServerManager; +import org.apache.hadoop.hbase.master.snapshot.SnapshotManager; import org.apache.hadoop.hbase.net.Address; import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; import org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos; @@ -77,6 +78,7 @@ public class TestRSGroups extends TestRSGroupsBase { TEST_UTIL.getConfiguration().set( ServerManager.WAIT_ON_REGIONSERVERS_MINTOSTART, ""+NUM_SLAVES_BASE); + TEST_UTIL.getConfiguration().setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true); admin = TEST_UTIL.getAdmin(); cluster = TEST_UTIL.getHBaseCluster(); @@ -270,4 +272,21 @@ public class TestRSGroups extends TestRSGroupsBase { } }); } + + @Test + public void testCloneSnapshot() throws Exception { + byte[] FAMILY = Bytes.toBytes("test"); + String snapshotName = tableName.getNameAsString() + "_snap"; + TableName clonedTableName = TableName.valueOf(tableName.getNameAsString() + "_clone"); + + // create base table + TEST_UTIL.createTable(tableName, FAMILY); + + // create snapshot + admin.snapshot(snapshotName, tableName); + + // clone + admin.cloneSnapshot(snapshotName, clonedTableName); + } + }