hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [23/50] [abbrv] hbase git commit: HBASE-15297 Correct handling of namespace existence checks in shell.
Date Mon, 19 Sep 2016 23:17:36 GMT
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>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/422734e7
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/422734e7
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/422734e7

Branch: refs/heads/hbase-12439
Commit: 422734e73d8846e4a357178cf665220d689e2e6e
Parents: 77b3273
Author: Umesh Agashe <uagashe@cloudera.com>
Authored: Mon Sep 12 16:24:44 2016 -0700
Committer: Sean Busbey <busbey@apache.org>
Committed: Mon Sep 12 23:29:42 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/hadoop/hbase/client/Admin.java | 5 ++++-
 .../java/org/apache/hadoop/hbase/client/HBaseAdmin.java     | 6 ++++--
 hbase-shell/src/main/ruby/hbase/security.rb                 | 9 +++------
 3 files changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/422734e7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
index 321ea55..0f66834 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Admin.java
@@ -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

http://git-wip-us.apache.org/repos/asf/hbase/blob/422734e7/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
index bdd23ab..3b41755 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
@@ -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;
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/422734e7/hbase-shell/src/main/ruby/hbase/security.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/security.rb b/hbase-shell/src/main/ruby/hbase/security.rb
index 55519ed..4c884d6 100644
--- a/hbase-shell/src/main/ruby/hbase/security.rb
+++ b/hbase-shell/src/main/ruby/hbase/security.rb
@@ -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


Mime
View raw message