You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2014/12/15 20:44:20 UTC

hbase git commit: HBASE-12675 Use interface methods in shell scripts (solomon duskis)

Repository: hbase
Updated Branches:
  refs/heads/master 3a652ba41 -> 2cab24ab9


HBASE-12675 Use interface methods in shell scripts (solomon duskis)


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

Branch: refs/heads/master
Commit: 2cab24ab9ad25b02e93ad595bedd4550d8eea5d2
Parents: 3a652ba
Author: stack <st...@apache.org>
Authored: Mon Dec 15 11:44:05 2014 -0800
Committer: stack <st...@apache.org>
Committed: Mon Dec 15 11:44:05 2014 -0800

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase/admin.rb    | 15 ++++++++-------
 hbase-shell/src/main/ruby/hbase/security.rb |  2 +-
 hbase-shell/src/main/ruby/hbase/table.rb    |  8 +++-----
 3 files changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2cab24ab/hbase-shell/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index e5c312b..6b00cb9 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -23,6 +23,7 @@ java_import org.apache.hadoop.hbase.util.Pair
 java_import org.apache.hadoop.hbase.util.RegionSplitter
 java_import org.apache.hadoop.hbase.util.Bytes
 java_import org.apache.hadoop.hbase.ServerName
+java_import org.apache.hadoop.hbase.TableName
 java_import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos::SnapshotDescription
 
 # Wrapper for org.apache.hadoop.hbase.client.HBaseAdmin
@@ -43,7 +44,7 @@ module Hbase
     #----------------------------------------------------------------------------------------------
     # Returns a list of tables in hbase
     def list(regex = ".*")
-      @admin.listTableNames(regex).map { |t| t.getNameAsString }
+      @admin.listTables(regex).map { |t| t.getNameAsString }
     end
 
     #----------------------------------------------------------------------------------------------
@@ -346,17 +347,17 @@ module Hbase
     #----------------------------------------------------------------------------------------------
     # Returns table's structure description
     def describe(table_name)
-      @admin.getTableDescriptor(table_name.to_java_bytes).to_s
+      @admin.getTableDescriptor(TableName.valueOf(table_name)).to_s
     end
 
     def get_column_families(table_name)
-      @admin.getTableDescriptor(table_name.to_java_bytes).getColumnFamilies()
+      @admin.getTableDescriptor(TableName.valueOf(table_name)).getColumnFamilies()
     end
 
     #----------------------------------------------------------------------------------------------
     # Truncates table (deletes all records by recreating the table)
     def truncate(table_name, conf = @conf)
-      table_description = @admin.getTableDescriptor(table_name.to_java_bytes)
+      table_description = @admin.getTableDescriptor(TableName.valueOf(table_name))
       raise ArgumentError, "Table #{table_name} is not enabled. Enable it first.'" unless enabled?(table_name)
       yield 'Disabling table...' if block_given?
       @admin.disableTable(table_name)
@@ -446,7 +447,7 @@ module Hbase
       raise(ArgumentError, "There should be at least one argument but the table name") if args.empty?
 
       # Get table descriptor
-      htd = @admin.getTableDescriptor(table_name.to_java_bytes)
+      htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
 
       # Process all args
       args.each do |arg|
@@ -478,7 +479,7 @@ module Hbase
           end
 
           # We bypass descriptor when adding column families; refresh it to apply other args correctly.
-          htd = @admin.getTableDescriptor(table_name.to_java_bytes)
+          htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
           next
         end
 
@@ -513,7 +514,7 @@ module Hbase
 
           if method == "delete"
             # We bypass descriptor when deleting column families; refresh it to apply other args correctly.
-            htd = @admin.getTableDescriptor(table_name.to_java_bytes)
+            htd = @admin.getTableDescriptor(TableName.valueOf(table_name))
           end
           next
         end

http://git-wip-us.apache.org/repos/asf/hbase/blob/2cab24ab/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 a0d6e91..5262f45 100644
--- a/hbase-shell/src/main/ruby/hbase/security.rb
+++ b/hbase-shell/src/main/ruby/hbase/security.rb
@@ -62,7 +62,7 @@ module Hbase
             raise(ArgumentError, "Can't find a table: #{table_name}") unless exists?(table_name)
 
             tableName = org.apache.hadoop.hbase.TableName.valueOf(table_name.to_java_bytes)
-            htd = @admin.getTableDescriptor(tablebytes)
+            htd = @admin.getTableDescriptor(tableName)
 
             if (family != nil)
              raise(ArgumentError, "Can't find a family: #{family}") unless htd.hasFamily(family.to_java_bytes)

http://git-wip-us.apache.org/repos/asf/hbase/blob/2cab24ab/hbase-shell/src/main/ruby/hbase/table.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb
index d53a82e..b408649 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -115,11 +115,11 @@ EOF
       if @@thread_pool then
         @connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
           configuration, @@thread_pool)
-        @table = @connection.getTable(table_name)
+        @table = @connection.getTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
       else
         @connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
           configuration)
-        @table = @connection.getTable(table_name)
+        @table = @connection.getTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
         @@thread_pool = @table.getPool()
       end
       
@@ -612,9 +612,7 @@ EOF
 
     # Checks if current table is one of the 'meta' tables
     def is_meta_table?
-      tn = @table.table_name
-      org.apache.hadoop.hbase.util.Bytes.equals(tn,
-          org.apache.hadoop.hbase.TableName::META_TABLE_NAME.getName)
+      org.apache.hadoop.hbase.TableName::META_TABLE_NAME.equals(@table.getName())
     end
 
     # Returns family and (when has it) qualifier for a column name