HBASE-17785 RSGroupBasedLoadBalancer fails to assign new table regions when cloning snapshot
This commit is contained in:
parent
cbcbcf4dcd
commit
029fa29712
|
@ -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);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue