HBASE-15297 Correct handling of namespace existence checks in shell.

Changes namespace_exists? method in SecurityAdmin ruby code to catch NamespaceNotFoundException
and modified Admin.java file to document the exception.

Signed-off-by: Sean Busbey <busbey@apache.org>

 Conflicts:
	hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
	hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
This commit is contained in:
Umesh Agashe 2016-09-12 16:24:44 -07:00 committed by Sean Busbey
parent 7028a0d889
commit 059a169d3a
3 changed files with 10 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableExistsException;
@ -897,10 +898,11 @@ public interface Admin extends Abortable, Closeable {
*
* @param name name of namespace descriptor
* @return A descriptor
* @throws IOException
* @throws org.apache.hadoop.hbase.NamespaceNotFoundException
* @throws IOException if a remote or network exception occurs
*/
NamespaceDescriptor getNamespaceDescriptor(final String name)
throws IOException;
throws NamespaceNotFoundException, IOException;
/**
* List available namespace descriptors

View File

@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.MetaTableAccessor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.NamespaceNotFoundException;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.RegionException;
@ -3037,7 +3038,8 @@ public class HBaseAdmin implements Admin {
* @throws IOException
*/
@Override
public NamespaceDescriptor getNamespaceDescriptor(final String name) throws IOException {
public NamespaceDescriptor getNamespaceDescriptor(final String name)
throws NamespaceNotFoundException, IOException {
return
executeCallable(new MasterCallable<NamespaceDescriptor>(getConnection()) {
@Override

View File

@ -173,12 +173,9 @@ module Hbase
# Does Namespace exist
def namespace_exists?(namespace_name)
namespaceDesc = @admin.getNamespaceDescriptor(namespace_name)
if(namespaceDesc == nil)
return @admin.getNamespaceDescriptor(namespace_name) != nil
rescue org.apache.hadoop.hbase.NamespaceNotFoundException => e
return false
else
return true
end
end
# Make sure that security features are available