From 7c426c4446dc9a22996ac71c5830e9c6d3d7daf2 Mon Sep 17 00:00:00 2001 From: Guangxu Cheng Date: Tue, 25 Sep 2018 11:05:00 +0800 Subject: [PATCH] HBASE-20690 Moving table to target rsgroup needs to handle TableStateNotFoundException --- .../hbase/rsgroup/RSGroupAdminEndpoint.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) 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 3d1f780628..9cdd189d27 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 @@ -461,14 +461,20 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver { if (groupName == null) { groupName = RSGroupInfo.DEFAULT_GROUP; } - RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName); - if (rsGroupInfo == null) { - throw new ConstraintException("Default RSGroup (" + groupName + ") for this table's " - + "namespace does not exist."); - } - if (!rsGroupInfo.containsTable(desc.getTableName())) { - LOG.debug("Pre-moving table " + desc.getTableName() + " to RSGroup " + groupName); - groupAdminServer.moveTables(Sets.newHashSet(desc.getTableName()), groupName); + synchronized (groupInfoManager) { + RSGroupInfo rsGroupInfo = groupAdminServer.getRSGroupInfo(groupName); + if (rsGroupInfo == null) { + throw new ConstraintException("Default RSGroup (" + groupName + ") for this table's " + + "namespace does not exist."); + } + if (!desc.getTableName().isSystemTable() && !rsgroupHasServersOnline(desc)) { + throw new HBaseIOException("No online servers in the rsgroup, which table " + + desc.getTableName().getNameAsString() + " belongs to"); + } + if (!rsGroupInfo.containsTable(desc.getTableName())) { + LOG.debug("Pre-moving table " + desc.getTableName() + " to RSGroup " + groupName); + groupInfoManager.moveTables(Sets.newHashSet(desc.getTableName()), groupName); + } } } @@ -481,16 +487,6 @@ public class RSGroupAdminEndpoint implements MasterCoprocessor, MasterObserver { final ObserverContext 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"); - } - } - - // Assign table to default RSGroup. - @Override - public void postCreateTable(ObserverContext ctx, - TableDescriptor desc, RegionInfo[] regions) throws IOException { assignTableToGroup(desc); } -- 2.17.1