HBASE-12495 Use interfaces in the shell scripts (solomon duskis)
Conflicts: hbase-shell/src/main/ruby/hbase/quotas.rb
This commit is contained in:
parent
3cd1d7ab0c
commit
a4a3ffd560
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue