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:
parent
7028a0d889
commit
059a169d3a
|
@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.NamespaceNotFoundException;
|
||||||
import org.apache.hadoop.hbase.ProcedureInfo;
|
import org.apache.hadoop.hbase.ProcedureInfo;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableExistsException;
|
import org.apache.hadoop.hbase.TableExistsException;
|
||||||
|
@ -897,10 +898,11 @@ public interface Admin extends Abortable, Closeable {
|
||||||
*
|
*
|
||||||
* @param name name of namespace descriptor
|
* @param name name of namespace descriptor
|
||||||
* @return A 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)
|
NamespaceDescriptor getNamespaceDescriptor(final String name)
|
||||||
throws IOException;
|
throws NamespaceNotFoundException, IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List available namespace descriptors
|
* List available namespace descriptors
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.MasterNotRunningException;
|
import org.apache.hadoop.hbase.MasterNotRunningException;
|
||||||
import org.apache.hadoop.hbase.MetaTableAccessor;
|
import org.apache.hadoop.hbase.MetaTableAccessor;
|
||||||
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
import org.apache.hadoop.hbase.NamespaceDescriptor;
|
||||||
|
import org.apache.hadoop.hbase.NamespaceNotFoundException;
|
||||||
import org.apache.hadoop.hbase.NotServingRegionException;
|
import org.apache.hadoop.hbase.NotServingRegionException;
|
||||||
import org.apache.hadoop.hbase.ProcedureInfo;
|
import org.apache.hadoop.hbase.ProcedureInfo;
|
||||||
import org.apache.hadoop.hbase.RegionException;
|
import org.apache.hadoop.hbase.RegionException;
|
||||||
|
@ -3037,7 +3038,8 @@ public class HBaseAdmin implements Admin {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public NamespaceDescriptor getNamespaceDescriptor(final String name) throws IOException {
|
public NamespaceDescriptor getNamespaceDescriptor(final String name)
|
||||||
|
throws NamespaceNotFoundException, IOException {
|
||||||
return
|
return
|
||||||
executeCallable(new MasterCallable<NamespaceDescriptor>(getConnection()) {
|
executeCallable(new MasterCallable<NamespaceDescriptor>(getConnection()) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -173,12 +173,9 @@ module Hbase
|
||||||
|
|
||||||
# Does Namespace exist
|
# Does Namespace exist
|
||||||
def namespace_exists?(namespace_name)
|
def namespace_exists?(namespace_name)
|
||||||
namespaceDesc = @admin.getNamespaceDescriptor(namespace_name)
|
return @admin.getNamespaceDescriptor(namespace_name) != nil
|
||||||
if(namespaceDesc == nil)
|
rescue org.apache.hadoop.hbase.NamespaceNotFoundException => e
|
||||||
return false
|
return false
|
||||||
else
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make sure that security features are available
|
# Make sure that security features are available
|
||||||
|
|
Loading…
Reference in New Issue