HBASE-9421 Provide better error message when dropping non-existent namespace (Ted Yu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1520043 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9da78ca043
commit
7c21efdb04
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.hadoop.hbase.master;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.NavigableSet;
|
||||
|
||||
|
@ -46,9 +47,9 @@ import org.apache.hadoop.hbase.master.handler.CreateTableHandler;
|
|||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.apache.hadoop.hbase.util.FSUtils;
|
||||
|
||||
/**
|
||||
* This is a helper class used to manage the namespace
|
||||
|
@ -156,7 +157,12 @@ public class TableNamespaceManager {
|
|||
if (NamespaceDescriptor.RESERVED_NAMESPACES.contains(name)) {
|
||||
throw new ConstraintException("Reserved namespace "+name+" cannot be removed.");
|
||||
}
|
||||
int tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
|
||||
int tableCount;
|
||||
try {
|
||||
tableCount = masterServices.listTableDescriptorsByNamespace(name).size();
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
throw new ConstraintException("namespace " + name + " does not exist");
|
||||
}
|
||||
if (tableCount > 0) {
|
||||
throw new ConstraintException("Only empty namespaces can be removed. " +
|
||||
"Namespace "+name+" has "+tableCount+" tables");
|
||||
|
|
Loading…
Reference in New Issue