hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshb...@apache.org
Subject svn commit: r1587297 - in /hbase/branches/0.94/src/main: java/org/apache/hadoop/hbase/client/HBaseAdmin.java ruby/shell/commands.rb
Date Mon, 14 Apr 2014 19:50:27 GMT
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



Mime
View raw message