You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ra...@apache.org on 2014/04/14 21:50:27 UTC

svn commit: r1587297 - in /hbase/branches/0.94/src/main: java/org/apache/hadoop/hbase/client/HBaseAdmin.java ruby/shell/commands.rb

Author: rajeshbabu
Date: Mon Apr 14 19:50:27 2014
New Revision: 1587297

URL: http://svn.apache.org/r1587297
Log:
HBASE-10533 commands.rb is giving wrong error messages on exceptions(rajeshbabu)

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.94/src/main/ruby/shell/commands.rb

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1587297&r1=1587296&r2=1587297&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Mon Apr 14 19:50:27 2014
@@ -2262,7 +2262,7 @@ public class HBaseAdmin implements Abort
   public void cloneSnapshot(final String snapshotName, final String tableName)
       throws IOException, TableExistsException, RestoreSnapshotException, InterruptedException {
     if (tableExists(tableName)) {
-      throw new TableExistsException("Table '" + tableName + " already exists");
+      throw new TableExistsException(tableName);
     }
     internalRestoreSnapshot(snapshotName, tableName);
     waitUntilTableIsEnabled(Bytes.toBytes(tableName));

Modified: hbase/branches/0.94/src/main/ruby/shell/commands.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/ruby/shell/commands.rb?rev=1587297&r1=1587296&r2=1587297&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/ruby/shell/commands.rb (original)
+++ hbase/branches/0.94/src/main/ruby/shell/commands.rb Mon Apr 14 19:50:27 2014
@@ -72,13 +72,37 @@ module Shell
 
       def translate_hbase_exceptions(*args)
         yield
-      rescue org.apache.hadoop.hbase.TableNotFoundException
-        raise "Unknown table #{args.first}!"
-      rescue org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException
-        valid_cols = table(args.first).get_all_columns.map { |c| c + '*' }
-        raise "Unknown column family! Valid column names: #{valid_cols.join(", ")}"
-      rescue org.apache.hadoop.hbase.TableExistsException
-        raise "Table already exists: #{args.first}!"
+      rescue => e
+        raise e unless e.respond_to?(:cause) && e.cause != nil
+        
+        # Get the special java exception which will be handled
+        cause = e.cause
+        if cause.kind_of?(org.apache.hadoop.hbase.TableNotFoundException) then
+          str = java.lang.String.new("#{cause}")
+          raise "Unknown table #{str}!"
+        end
+        if cause.kind_of?(org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException) then
+          exceptions = cause.getCauses
+          exceptions.each do |exception|
+            if exception.kind_of?(org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException) then
+              valid_cols = table(args.first).get_all_columns.map { |c| c + '*' }
+              raise "Unknown column family! Valid column names: #{valid_cols.join(", ")}"
+            end
+          end
+        end
+        if cause.kind_of?(org.apache.hadoop.hbase.TableExistsException) then
+          str = java.lang.String.new("#{cause}")
+          strs = str.split("\n")
+          if strs.size > 0 then
+            s = strs[0].split(' ');
+            if(s.size > 1)
+              raise "Table already exists: #{s[1]}!"
+            end
+              raise "Table already exists: #{strs[0]}!"
+          end
+        end
+        # Throw the other exception which hasn't been handled above       
+        raise e
       end
     end
   end