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>
This commit is contained in:
parent
77b327320a
commit
422734e73d
|
@ -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;
|
||||
|
@ -1085,9 +1086,11 @@ public interface Admin extends Abortable, Closeable {
|
|||
*
|
||||
* @param name name of namespace descriptor
|
||||
* @return A descriptor
|
||||
* @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
|
||||
|
|
|
@ -52,6 +52,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.ProcedureUtil;
|
||||
|
@ -1981,7 +1982,8 @@ public class HBaseAdmin implements Admin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public NamespaceDescriptor getNamespaceDescriptor(final String name) throws IOException {
|
||||
public NamespaceDescriptor getNamespaceDescriptor(final String name)
|
||||
throws NamespaceNotFoundException, IOException {
|
||||
return executeCallable(new MasterCallable<NamespaceDescriptor>(getConnection(),
|
||||
getRpcControllerFactory()) {
|
||||
@Override
|
||||
|
@ -3652,4 +3654,4 @@ public class HBaseAdmin implements Admin {
|
|||
private RpcControllerFactory getRpcControllerFactory() {
|
||||
return this.rpcControllerFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,12 +173,9 @@ module Hbase
|
|||
|
||||
# Does Namespace exist
|
||||
def namespace_exists?(namespace_name)
|
||||
namespaceDesc = @admin.getNamespaceDescriptor(namespace_name)
|
||||
if(namespaceDesc == nil)
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
return @admin.getNamespaceDescriptor(namespace_name) != nil
|
||||
rescue org.apache.hadoop.hbase.NamespaceNotFoundException => e
|
||||
return false
|
||||
end
|
||||
|
||||
# Make sure that security features are available
|
||||
|
|
Loading…
Reference in New Issue