hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-12495 Use interfaces in the shell scripts (solomon duskis)
Date Mon, 24 Nov 2014 20:19:42 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 3cd1d7ab0 -> a4a3ffd56


HBASE-12495 Use interfaces in the shell scripts (solomon duskis)

Conflicts:
	hbase-shell/src/main/ruby/hbase/quotas.rb


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

Branch: refs/heads/branch-1
Commit: a4a3ffd56094de5fe2a661f7c3f59dff2c9d2b28
Parents: 3cd1d7a
Author: stack <stack@apache.org>
Authored: Mon Nov 24 12:18:25 2014 -0800
Committer: stack <stack@apache.org>
Committed: Mon Nov 24 12:19:32 2014 -0800

----------------------------------------------------------------------
 hbase-shell/src/main/ruby/hbase.rb              |  4 ++--
 hbase-shell/src/main/ruby/hbase/admin.rb        | 18 ++++++++---------
 hbase-shell/src/main/ruby/hbase/security.rb     |  7 ++++---
 hbase-shell/src/main/ruby/hbase/table.rb        | 21 ++++++++++++++++++--
 .../src/main/ruby/hbase/visibility_labels.rb    |  3 +++
 .../apache/hadoop/hbase/client/TestShell.java   |  3 +++
 6 files changed, 40 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/hbase-shell/src/main/ruby/hbase.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase.rb b/hbase-shell/src/main/ruby/hbase.rb
index ca26137..121fd53 100644
--- a/hbase-shell/src/main/ruby/hbase.rb
+++ b/hbase-shell/src/main/ruby/hbase.rb
@@ -18,8 +18,8 @@
 #
 
 # HBase ruby classes.
-# Has wrapper classes for org.apache.hadoop.hbase.client.HBaseAdmin
-# and for org.apache.hadoop.hbase.client.HTable.  Classes take
+# Has wrapper classes for org.apache.hadoop.hbase.client.Admin
+# and for org.apache.hadoop.hbase.client.Table.  Classes take
 # Formatters on construction and outputs any results using
 # Formatter methods.  These classes are only really for use by
 # the hirb.rb HBase Shell script; they don't make much sense elsewhere.

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/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 b08b5eb..96f2852 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -32,7 +32,9 @@ module Hbase
     include HBaseConstants
 
     def initialize(configuration, formatter)
-      @admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration)
+      # @admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration)
+      @conn = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(configuration)
+      @admin = @conn.getAdmin()
       connection = @admin.getConnection()
       @conf = configuration
       @zk_wrapper = org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.new(configuration,
@@ -181,7 +183,7 @@ module Hbase
       tableExists(table_name)
       raise ArgumentError, "Table #{table_name} is enabled. Disable it first.'" if enabled?(table_name)
 
-      @admin.deleteTable(table_name)
+      @admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
     end
 
     #----------------------------------------------------------------------------------------------
@@ -351,8 +353,7 @@ module Hbase
     #----------------------------------------------------------------------------------------------
     # Truncates table (deletes all records by recreating the table)
     def truncate(table_name, conf = @conf)
-      h_table = org.apache.hadoop.hbase.client.HTable.new(conf, table_name)
-      table_description = h_table.getTableDescriptor()
+      table_description = @admin.getTableDescriptor(table_name.to_java_bytes)
       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)
@@ -367,7 +368,7 @@ module Hbase
         if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
           # Handle the compatibility case, where the truncate method doesn't exists on the
Master
           yield 'Dropping table...' if block_given?
-          @admin.deleteTable(table_name)
+          @admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
 
           yield 'Creating table...' if block_given?
           @admin.createTable(table_description)
@@ -380,7 +381,7 @@ module Hbase
     #----------------------------------------------------------------------------------------------
     # Truncates table while maintaing region boundaries (deletes all records by recreating
the table)
     def truncate_preserve(table_name, conf = @conf)
-      h_table = org.apache.hadoop.hbase.client.HTable.new(conf, table_name)
+      h_table = @connection.getTable(table_name)
       splits = h_table.getRegionLocations().keys().map{|i| Bytes.toString(i.getStartKey)}.delete_if{|k|
k == ""}.to_java :String
       splits = org.apache.hadoop.hbase.util.Bytes.toByteArrays(splits)
       table_description = h_table.getTableDescriptor()
@@ -397,7 +398,7 @@ module Hbase
         if rootCause.kind_of?(org.apache.hadoop.hbase.DoNotRetryIOException) then
           # Handle the compatibility case, where the truncate method doesn't exists on the
Master
           yield 'Dropping table...' if block_given?
-          @admin.deleteTable(table_name)
+          @admin.deleteTable(org.apache.hadoop.hbase.TableName.valueOf(table_name))
 
           yield 'Creating table with region boundaries...' if block_given?
           @admin.createTable(table_description, splits)
@@ -712,8 +713,7 @@ module Hbase
     # Enables/disables a region by name
     def online(region_name, on_off)
       # Open meta table
-      meta = org.apache.hadoop.hbase.client.HTable.new(
-          org.apache.hadoop.hbase.TableName::META_TABLE_NAME)
+      meta = connection.getTable(org.apache.hadoop.hbase.TableName::META_TABLE_NAME)
 
       # Read region info
       # FIXME: fail gracefully if can't find the region

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/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 154c5ca..1bd025c 100644
--- a/hbase-shell/src/main/ruby/hbase/security.rb
+++ b/hbase-shell/src/main/ruby/hbase/security.rb
@@ -26,7 +26,8 @@ module Hbase
 
     def initialize(configuration, formatter)
       @config = configuration
-      @admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration)
+      @connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(@config)
+      @admin = @connection.getAdmin()
       @formatter = formatter
     end
 
@@ -37,7 +38,7 @@ module Hbase
       # TODO: need to validate user name
 
       begin
-        meta_table = org.apache.hadoop.hbase.client.HTable.new(@config,
+        meta_table = @connection.getTable(
           org.apache.hadoop.hbase.security.access.AccessControlLists::ACL_TABLE_NAME)
         service = meta_table.coprocessorService(
           org.apache.hadoop.hbase.HConstants::EMPTY_START_ROW)
@@ -101,7 +102,7 @@ module Hbase
       # TODO: need to validate user name
 
       begin
-        meta_table = org.apache.hadoop.hbase.client.HTable.new(@config,
+        meta_table = @connection.getTable(
           org.apache.hadoop.hbase.security.access.AccessControlLists::ACL_TABLE_NAME)
         service = meta_table.coprocessorService(
           org.apache.hadoop.hbase.HConstants::EMPTY_START_ROW)

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/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 a83c56a..f5d7568 100644
--- a/hbase-shell/src/main/ruby/hbase/table.rb
+++ b/hbase-shell/src/main/ruby/hbase/table.rb
@@ -19,7 +19,7 @@
 
 include Java
 
-# Wrapper for org.apache.hadoop.hbase.client.HTable
+# Wrapper for org.apache.hadoop.hbase.client.Table
 
 module Hbase
   class Table
@@ -112,12 +112,29 @@ EOF
     attr_reader :name
 
     def initialize(configuration, table_name, shell)
+      # Commenting out the HTable.new() calls and uncommenting the @connection approach causes
+      # Zookeepr exceptions.  Interestingly, there were changes in admin.rb to convert 
+      # HBaseAdmin.new() calls to ConnectionFactory.createConnection().getAdmin().  Either
change
+      # of ConnectionFactory.createConnection().getTable() or
+      # ConnectionFactory.createConnection().getAdmin() by itself doesn't cause the Zookeper

+      # exception.  Somehow the combination of the two causes the issue.
+
+      # TODO: Uncomment the createConnection approach after the underlying problem is fixed.
+ 
       if @@thread_pool then
-        @table = org.apache.hadoop.hbase.client.HTable.new(configuration, table_name.to_java_bytes,
@@thread_pool)
+        @table = org.apache.hadoop.hbase.client.HTable.new(configuration, table_name.to_java_bytes,
+          @@thread_pool)
+        # @connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
+        #  configuration, @@thread_pool)
+        # @table = @connection.getTable(table_name)
       else
+        # @connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(
+        #  configuration)
+        # @table = @connection.getTable(table_name)
         @table = org.apache.hadoop.hbase.client.HTable.new(configuration, table_name)
         @@thread_pool = @table.getPool()
       end
+      
       @name = table_name
       @shell = shell
       @converters = Hash.new()

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/hbase-shell/src/main/ruby/hbase/visibility_labels.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/visibility_labels.rb b/hbase-shell/src/main/ruby/hbase/visibility_labels.rb
index 73e1d9e..ca33ada 100644
--- a/hbase-shell/src/main/ruby/hbase/visibility_labels.rb
+++ b/hbase-shell/src/main/ruby/hbase/visibility_labels.rb
@@ -27,6 +27,9 @@ module Hbase
     def initialize(configuration, formatter)
       @config = configuration
       @formatter = formatter
+      
+      # @connection = org.apache.hadoop.hbase.client.ConnectionFactory(configuration)
+      # @admin = @connection.getAdmin()
       @admin = org.apache.hadoop.hbase.client.HBaseAdmin.new(configuration)
     end
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a4a3ffd5/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
----------------------------------------------------------------------
diff --git a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
index 43fe3f8..5ba0a8f 100644
--- a/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
+++ b/hbase-shell/src/test/java/org/apache/hadoop/hbase/client/TestShell.java
@@ -65,6 +65,9 @@ public class TestShell {
     loadPaths.add("src/test/ruby");
     jruby.getProvider().setLoadPaths(loadPaths);
     jruby.put("$TEST_CLUSTER", TEST_UTIL);
+    System.setProperty("jruby.jit.logging.verbose", "true");
+    System.setProperty("jruby.jit.logging", "true");
+    System.setProperty("jruby.native.verbose", "true");
   }
 
   @AfterClass


Mime
View raw message