hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject svn commit: r1520488 - /hbase/branches/0.94/src/main/ruby/hbase/admin.rb
Date Fri, 06 Sep 2013 03:58:54 GMT
Author: apurtell
Date: Fri Sep  6 03:58:54 2013
New Revision: 1520488

URL: http://svn.apache.org/r1520488
Log:
HBASE-9448. [0.94] Shell needs to fall back after HBASE-9182 if talking to older servers

Modified:
    hbase/branches/0.94/src/main/ruby/hbase/admin.rb

Modified: hbase/branches/0.94/src/main/ruby/hbase/admin.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/ruby/hbase/admin.rb?rev=1520488&r1=1520487&r2=1520488&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/ruby/hbase/admin.rb (original)
+++ hbase/branches/0.94/src/main/ruby/hbase/admin.rb Fri Sep  6 03:58:54 2013
@@ -41,7 +41,19 @@ module Hbase
     #----------------------------------------------------------------------------------------------
     # Returns a list of tables in hbase
     def list(regex = ".*")
-      @admin.getTableNames(regex)
+      begin
+        # Use the old listTables API first for compatibility with older servers
+        @admin.listTables(regex).map { |t| t.getNameAsString }
+      rescue => e
+        # listTables failed, try the new unprivileged getTableNames API if the cause was
+        # an AccessDeniedException
+        if e.cause.kind_of? org.apache.hadoop.ipc.RemoteException and e.cause.unwrapRemoteException().kind_of?
org.apache.hadoop.hbase.security.AccessDeniedException
+          @admin.getTableNames(regex)
+        else
+          # Not an access control failure, re-raise
+          raise e
+        end
+      end
     end
 
     #----------------------------------------------------------------------------------------------



Mime
View raw message