HBASE-15845 Changes:

- Renaming hbase.rb to hbase_constants.rb because there are two hbase.rb files right now which is confusing.
- Remove omnipresence of formatter object since it is kind of a use-and-throw class. Commands should create
  an instance, use it to format the output and discard it.
- Some refactoring

Change-Id: If9ea9873904e0a39d199a6aa10e23864b86a2f09
This commit is contained in:
Apekshit 2015-12-28 14:50:50 -08:00 committed by Apekshit Sharma
parent f0c159b5fe
commit bdb46f01b9
25 changed files with 109 additions and 142 deletions

View File

@ -115,7 +115,7 @@ org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(log_level)
org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(log_level) org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(log_level)
# Require HBase now after setting log levels # Require HBase now after setting log levels
require 'hbase' require 'hbase_constants'
# Load hbase shell # Load hbase shell
require 'shell' require 'shell'
@ -123,15 +123,11 @@ require 'shell'
# Require formatter # Require formatter
require 'shell/formatter' require 'shell/formatter'
# Presume console format.
# Formatter takes an :output_stream parameter, if you don't want STDOUT.
@formatter = Shell::Formatter::Console.new
# Setup the HBase module. Create a configuration. # Setup the HBase module. Create a configuration.
@hbase = Hbase::Hbase.new @hbase = Hbase::Hbase.new
# Setup console # Setup console
@shell = Shell::Shell.new(@hbase, @formatter, interactive) @shell = Shell::Shell.new(@hbase, interactive)
@shell.debug = @shell_debug @shell.debug = @shell_debug
# Add commands to this namespace # Add commands to this namespace

View File

@ -31,10 +31,10 @@ module Hbase
class Admin class Admin
include HBaseConstants include HBaseConstants
def initialize(admin, formatter) def initialize(connection)
@admin = admin @connection = connection
@connection = @admin.getConnection() # Java Admin instance
@formatter = formatter @admin = @connection.getAdmin
end end
def close def close
@ -308,12 +308,6 @@ module Hbase
org.apache.hadoop.hbase.zookeeper.ZKUtil::dump(@zk_wrapper) org.apache.hadoop.hbase.zookeeper.ZKUtil::dump(@zk_wrapper)
end end
#----------------------------------------------------------------------------------------------
# Parse arguments and update HTableDescriptor accordingly
def parse_htd_args(htd, arg)
htd.setNormalizationEnabled(JBoolean.valueOf(arg.delete(NORMALIZATION_ENABLED))) if arg[NORMALIZATION_ENABLED]
end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------
# Creates a table # Creates a table
def create(table_name, *args) def create(table_name, *args)
@ -392,24 +386,7 @@ module Hbase
end end
# Done with splits; apply formerly-table_att parameters. # Done with splits; apply formerly-table_att parameters.
htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER] update_htd_from_arg(htd, arg)
htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE]
htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY]
htd.setCompactionEnabled(JBoolean.valueOf(arg[COMPACTION_ENABLED])) if arg[COMPACTION_ENABLED]
htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE]
# DEFERRED_LOG_FLUSH is deprecated and was replaced by DURABILITY. To keep backward compatible, it still exists.
# However, it has to be set before DURABILITY so that DURABILITY could overwrite if both args are set
if arg.include?(DEFERRED_LOG_FLUSH)
if arg.delete(DEFERRED_LOG_FLUSH).to_s.upcase == "TRUE"
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("ASYNC_WAL"))
else
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("SYNC_WAL"))
end
end
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY))) if arg[DURABILITY]
parse_htd_args(htd, arg)
set_user_metadata(htd, arg.delete(METADATA)) if arg[METADATA]
set_descriptor_config(htd, arg.delete(CONFIGURATION)) if arg[CONFIGURATION]
arg.each_key do |ignored_key| arg.each_key do |ignored_key|
puts("An argument ignored (unknown or overridden): %s" % [ ignored_key ]) puts("An argument ignored (unknown or overridden): %s" % [ ignored_key ])
@ -653,26 +630,7 @@ module Hbase
end end
# 3) Some args for the table, optionally with METHOD => table_att (deprecated) # 3) Some args for the table, optionally with METHOD => table_att (deprecated)
raise(ArgumentError, "NAME argument in an unexpected place") if name update_htd_from_arg(htd, arg)
htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER]
htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE]
htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY]
htd.setCompactionEnabled(JBoolean.valueOf(arg[COMPACTION_ENABLED])) if arg[COMPACTION_ENABLED]
parse_htd_args(htd, arg)
htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE]
# DEFERRED_LOG_FLUSH is deprecated and was replaced by DURABILITY. To keep backward compatible, it still exists.
# However, it has to be set before DURABILITY so that DURABILITY could overwrite if both args are set
if arg.include?(DEFERRED_LOG_FLUSH)
if arg.delete(DEFERRED_LOG_FLUSH).to_s.upcase == "TRUE"
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("ASYNC_WAL"))
else
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("SYNC_WAL"))
end
end
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY))) if arg[DURABILITY]
htd.setRegionReplication(JInteger.valueOf(arg.delete(REGION_REPLICATION))) if arg[REGION_REPLICATION]
set_user_metadata(htd, arg.delete(METADATA)) if arg[METADATA]
set_descriptor_config(htd, arg.delete(CONFIGURATION)) if arg[CONFIGURATION]
# set a coprocessor attribute # set a coprocessor attribute
valid_coproc_keys = [] valid_coproc_keys = []
@ -1186,5 +1144,29 @@ module Hbase
def list_procedures() def list_procedures()
@admin.listProcedures() @admin.listProcedures()
end end
# Parse arguments and update HTableDescriptor accordingly
def update_htd_from_arg(htd, arg)
htd.setOwnerString(arg.delete(OWNER)) if arg[OWNER]
htd.setMaxFileSize(JLong.valueOf(arg.delete(MAX_FILESIZE))) if arg[MAX_FILESIZE]
htd.setReadOnly(JBoolean.valueOf(arg.delete(READONLY))) if arg[READONLY]
htd.setCompactionEnabled(JBoolean.valueOf(arg[COMPACTION_ENABLED])) if arg[COMPACTION_ENABLED]
htd.setNormalizationEnabled(
JBoolean.valueOf(arg[NORMALIZATION_ENABLED])) if arg[NORMALIZATION_ENABLED]
htd.setMemStoreFlushSize(JLong.valueOf(arg.delete(MEMSTORE_FLUSHSIZE))) if arg[MEMSTORE_FLUSHSIZE]
# DEFERRED_LOG_FLUSH is deprecated and was replaced by DURABILITY. To keep backward compatible, it still exists.
# However, it has to be set before DURABILITY so that DURABILITY could overwrite if both args are set
if arg.include?(DEFERRED_LOG_FLUSH)
if arg.delete(DEFERRED_LOG_FLUSH).to_s.upcase == "TRUE"
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("ASYNC_WAL"))
else
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf("SYNC_WAL"))
end
end
htd.setDurability(org.apache.hadoop.hbase.client.Durability.valueOf(arg.delete(DURABILITY))) if arg[DURABILITY]
htd.setRegionReplication(JInteger.valueOf(arg.delete(REGION_REPLICATION))) if arg[REGION_REPLICATION]
set_user_metadata(htd, arg.delete(METADATA)) if arg[METADATA]
set_descriptor_config(htd, arg.delete(CONFIGURATION)) if arg[CONFIGURATION]
end
end end
end end

View File

@ -18,6 +18,8 @@
# #
include Java include Java
java_import org.apache.hadoop.hbase.client.ConnectionFactory
java_import org.apache.hadoop.hbase.HBaseConfiguration
require 'hbase/admin' require 'hbase/admin'
require 'hbase/table' require 'hbase/table'
@ -35,25 +37,25 @@ module Hbase
if config if config
self.configuration = config self.configuration = config
else else
self.configuration = org.apache.hadoop.hbase.HBaseConfiguration.create self.configuration = HBaseConfiguration.create
# Turn off retries in hbase and ipc. Human doesn't want to wait on N retries. # Turn off retries in hbase and ipc. Human doesn't want to wait on N retries.
configuration.setInt("hbase.client.retries.number", 7) configuration.setInt("hbase.client.retries.number", 7)
configuration.setInt("hbase.ipc.client.connect.max.retries", 3) configuration.setInt("hbase.ipc.client.connect.max.retries", 3)
end end
@connection = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection( @connection = ConnectionFactory.createConnection(self.configuration)
self.configuration)
end end
def admin(formatter) # Returns ruby's Admin class from admin.rb
::Hbase::Admin.new(@connection.getAdmin, formatter) def admin()
::Hbase::Admin.new(@connection)
end end
def rsgroup_admin(formatter) def rsgroup_admin()
::Hbase::RSGroupAdmin.new(@connection, formatter) ::Hbase::RSGroupAdmin.new(@connection)
end end
def taskmonitor(formatter) def taskmonitor()
::Hbase::TaskMonitor.new(configuration, formatter) ::Hbase::TaskMonitor.new(configuration)
end end
# Create new one each time # Create new one each time
@ -61,20 +63,20 @@ module Hbase
::Hbase::Table.new(@connection.getTable(TableName.valueOf(table)), shell) ::Hbase::Table.new(@connection.getTable(TableName.valueOf(table)), shell)
end end
def replication_admin(formatter) def replication_admin()
::Hbase::RepAdmin.new(configuration, formatter) ::Hbase::RepAdmin.new(configuration)
end end
def security_admin(formatter) def security_admin()
::Hbase::SecurityAdmin.new(@connection.getAdmin, formatter) ::Hbase::SecurityAdmin.new(@connection.getAdmin)
end end
def visibility_labels_admin(formatter) def visibility_labels_admin()
::Hbase::VisibilityLabelsAdmin.new(@connection.getAdmin, formatter) ::Hbase::VisibilityLabelsAdmin.new(@connection.getAdmin)
end end
def quotas_admin(formatter) def quotas_admin()
::Hbase::QuotasAdmin.new(@connection.getAdmin, formatter) ::Hbase::QuotasAdmin.new(@connection.getAdmin)
end end
def shutdown def shutdown

View File

@ -36,9 +36,8 @@ end
module Hbase module Hbase
class QuotasAdmin class QuotasAdmin
def initialize(admin, formatter) def initialize(admin)
@admin = admin @admin = admin
@formatter = formatter
end end
def close def close

View File

@ -31,10 +31,9 @@ module Hbase
class RepAdmin class RepAdmin
include HBaseConstants include HBaseConstants
def initialize(configuration, formatter) def initialize(configuration)
@replication_admin = ReplicationAdmin.new(configuration) @replication_admin = ReplicationAdmin.new(configuration)
@configuration = configuration @configuration = configuration
@formatter = formatter
end end
#---------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------

View File

@ -28,9 +28,8 @@ module Hbase
class RSGroupAdmin class RSGroupAdmin
include HBaseConstants include HBaseConstants
def initialize(connection, formatter) def initialize(connection)
@admin = org.apache.hadoop.hbase.rsgroup.RSGroupAdmin.newClient(connection) @admin = org.apache.hadoop.hbase.rsgroup.RSGroupAdmin.newClient(connection)
@formatter = formatter
end end
def close def close

View File

@ -24,10 +24,9 @@ module Hbase
class SecurityAdmin class SecurityAdmin
include HBaseConstants include HBaseConstants
def initialize(admin, formatter) def initialize(admin)
@admin = admin @admin = admin
@connection = @admin.getConnection() @connection = @admin.getConnection()
@formatter = formatter
end end
def close def close

View File

@ -296,7 +296,7 @@ EOF
# Parse arguments # Parse arguments
# #
unless args.kind_of?(Hash) unless args.kind_of?(Hash)
raise ArgumentError, "Failed parse of of #{args.inspect}, #{args.class}" raise ArgumentError, "Failed parse of #{args.inspect}, #{args.class}"
end end
# Get maxlength parameter if passed # Get maxlength parameter if passed

View File

@ -71,9 +71,8 @@ module Hbase
end end
def initialize(configuration, formatter) def initialize(configuration)
@conf = configuration @conf = configuration
@formatter = formatter
@conn = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(@conf) @conn = org.apache.hadoop.hbase.client.ConnectionFactory.createConnection(@conf)
@admin = @conn.getAdmin() @admin = @conn.getAdmin()
end end

View File

@ -24,9 +24,8 @@ java_import org.apache.hadoop.hbase.util.Bytes
module Hbase module Hbase
class VisibilityLabelsAdmin class VisibilityLabelsAdmin
def initialize(admin, formatter) def initialize(admin)
@admin = admin @admin = admin
@formatter = formatter
@connection = @admin.getConnection() @connection = @admin.getConnection()
end end

View File

@ -70,25 +70,23 @@ module Shell
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class Shell class Shell
attr_accessor :hbase attr_accessor :hbase
attr_accessor :formatter
attr_accessor :interactive attr_accessor :interactive
alias interactive? interactive alias interactive? interactive
@debug = false @debug = false
attr_accessor :debug attr_accessor :debug
def initialize(hbase, formatter, interactive=true) def initialize(hbase, interactive=true)
self.hbase = hbase self.hbase = hbase
self.formatter = formatter
self.interactive = interactive self.interactive = interactive
end end
def hbase_admin def hbase_admin
@hbase_admin ||= hbase.admin(formatter) @hbase_admin ||= hbase.admin()
end end
def hbase_taskmonitor def hbase_taskmonitor
@hbase_taskmonitor ||= hbase.taskmonitor(formatter) @hbase_taskmonitor ||= hbase.taskmonitor()
end end
def hbase_table(name) def hbase_table(name)
@ -96,23 +94,23 @@ module Shell
end end
def hbase_replication_admin def hbase_replication_admin
@hbase_replication_admin ||= hbase.replication_admin(formatter) @hbase_replication_admin ||= hbase.replication_admin()
end end
def hbase_security_admin def hbase_security_admin
@hbase_security_admin ||= hbase.security_admin(formatter) @hbase_security_admin ||= hbase.security_admin()
end end
def hbase_visibility_labels_admin def hbase_visibility_labels_admin
@hbase_visibility_labels_admin ||= hbase.visibility_labels_admin(formatter) @hbase_visibility_labels_admin ||= hbase.visibility_labels_admin()
end end
def hbase_quotas_admin def hbase_quotas_admin
@hbase_quotas_admin ||= hbase.quotas_admin(formatter) @hbase_quotas_admin ||= hbase.quotas_admin()
end end
def hbase_rsgroup_admin def hbase_rsgroup_admin
@rsgroup_admin ||= hbase.rsgroup_admin(formatter) @rsgroup_admin ||= hbase.rsgroup_admin()
end end
def export_commands(where) def export_commands(where)
@ -149,8 +147,9 @@ module Shell
end end
def print_banner def print_banner
puts "HBase Shell; enter 'help<RETURN>' for list of supported commands." puts 'HBase Shell'
puts 'Type "exit<RETURN>" to leave the HBase Shell' puts 'Use "help" to get list of supported commands.'
puts 'Use "exit" to quit this interactive shell.'
print 'Version ' print 'Version '
command('version') command('version')
puts puts

View File

@ -26,7 +26,7 @@ module Shell
end end
#wrap an execution of cmd to catch hbase exceptions #wrap an execution of cmd to catch hbase exceptions
# cmd - command name to execture # cmd - command name to execute
# args - arguments to pass to the command # args - arguments to pass to the command
def command_safe(debug, cmd = :command, *args) def command_safe(debug, cmd = :command, *args)
# send is internal ruby method to call 'cmd' with *args # send is internal ruby method to call 'cmd' with *args
@ -50,6 +50,9 @@ module Shell
end end
end end
# Convenience functions to get different admins
# Returns HBase::Admin ruby class.
def admin def admin
@shell.hbase_admin @shell.hbase_admin
end end
@ -83,9 +86,9 @@ module Shell
end end
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# Creates formatter instance first time and then reuses it.
def formatter def formatter
@shell.formatter @formatter ||= ::Shell::Formatter::Console.new
end end
def format_simple_command def format_simple_command

View File

@ -18,9 +18,8 @@
# #
require 'shell' require 'shell'
require 'shell/formatter'
require 'stringio' require 'stringio'
require 'hbase' require 'hbase_constants'
require 'hbase/hbase' require 'hbase/hbase'
require 'hbase/table' require 'hbase/table'

View File

@ -17,12 +17,11 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
module Hbase module Hbase
class HbaseTest < Test::Unit::TestCase class HbaseTest < Test::Unit::TestCase
def setup def setup
@formatter = Shell::Formatter::Console.new()
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) @hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
end end
@ -31,19 +30,19 @@ module Hbase
end end
define_test "Hbase::Hbase#admin should create a new admin object when called the first time" do define_test "Hbase::Hbase#admin should create a new admin object when called the first time" do
assert_kind_of(::Hbase::Admin, @hbase.admin(@formatter)) assert_kind_of(::Hbase::Admin, @hbase.admin())
end end
define_test "Hbase::Hbase#admin should create a new admin object every call" do define_test "Hbase::Hbase#admin should create a new admin object every call" do
assert_not_same(@hbase.admin(@formatter), @hbase.admin(@formatter)) assert_not_same(@hbase.admin(), @hbase.admin())
end end
define_test "Hbase::Hbase#table should create a new table object when called the first time" do define_test "Hbase::Hbase#table should create a new table object when called the first time" do
assert_kind_of(::Hbase::Table, @hbase.table('hbase:meta', @formatter)) assert_kind_of(::Hbase::Table, @hbase.table('hbase:meta', @shell))
end end
define_test "Hbase::Hbase#table should create a new table object every call" do define_test "Hbase::Hbase#table should create a new table object every call" do
assert_not_same(@hbase.table('hbase:meta', @formatter), @hbase.table('hbase:meta', @formatter)) assert_not_same(@hbase.table('hbase:meta', @shell), @hbase.table('hbase:meta', @shell))
end end
end end
end end

View File

@ -18,8 +18,7 @@
# #
require 'shell' require 'shell'
require 'shell/formatter' require 'hbase_constants'
require 'hbase'
require 'hbase/hbase' require 'hbase/hbase'
require 'hbase/table' require 'hbase/table'

View File

@ -18,8 +18,7 @@
# #
require 'shell' require 'shell'
require 'shell/formatter' require 'hbase_constants'
require 'hbase'
require 'hbase/hbase' require 'hbase/hbase'
require 'hbase/table' require 'hbase/table'

View File

@ -17,7 +17,7 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
include HBaseConstants include HBaseConstants

View File

@ -17,7 +17,7 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
module Hbase module Hbase
class TaskMonitorTest < Test::Unit::TestCase class TaskMonitorTest < Test::Unit::TestCase

View File

@ -18,8 +18,7 @@
# #
require 'shell' require 'shell'
require 'shell/formatter' require 'hbase_constants'
require 'hbase'
require 'hbase/hbase' require 'hbase/hbase'
require 'hbase/table' require 'hbase/table'

View File

@ -17,7 +17,7 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
require 'hbase/table' require 'hbase/table'
require 'shell' require 'shell'

View File

@ -14,15 +14,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
require 'shell' require 'shell'
require 'shell/formatter'
class NonInteractiveTest < Test::Unit::TestCase class NonInteractiveTest < Test::Unit::TestCase
def setup def setup
@formatter = ::Shell::Formatter::Console.new()
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) @hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
@shell = Shell::Shell.new(@hbase, @formatter, false) @shell = Shell::Shell.new(@hbase, false)
end end
define_test "Shell::Shell noninteractive mode should throw" do define_test "Shell::Shell noninteractive mode should throw" do

View File

@ -17,16 +17,14 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
require 'shell' require 'shell'
require 'shell/formatter'
module Hbase module Hbase
class RSGroupShellTest < Test::Unit::TestCase class RSGroupShellTest < Test::Unit::TestCase
def setup def setup
@formatter = ::Shell::Formatter::Console.new
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) @hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
@shell = Shell::Shell.new(@hbase, @formatter) @shell = Shell::Shell.new(@hbase)
connection = $TEST_CLUSTER.getConnection connection = $TEST_CLUSTER.getConnection
@rsgroup_admin = @rsgroup_admin =
org.apache.hadoop.hbase.rsgroup.RSGroupAdmin.newClient(connection) org.apache.hadoop.hbase.rsgroup.RSGroupAdmin.newClient(connection)
@ -65,7 +63,7 @@ module Hbase
assert_equal(1, @rsgroup_admin.getRSGroupInfo(group_name).getTables.count) assert_equal(1, @rsgroup_admin.getRSGroupInfo(group_name).getTables.count)
count = 0 count = 0
@hbase.rsgroup_admin(@formatter).get_rsgroup(group_name) do |line| @hbase.rsgroup_admin().get_rsgroup(group_name) do |line|
case count case count
when 1 when 1
assert_equal(hostPortStr, line) assert_equal(hostPortStr, line)
@ -77,22 +75,22 @@ module Hbase
assert_equal(4, count) assert_equal(4, count)
assert_equal(2, assert_equal(2,
@hbase.rsgroup_admin(@formatter).list_rs_groups.count) @hbase.rsgroup_admin().list_rs_groups.count)
# just run it to verify jruby->java api binding # just run it to verify jruby->java api binding
@hbase.rsgroup_admin(@formatter).balance_rs_group(group_name) @hbase.rsgroup_admin().balance_rs_group(group_name)
end end
# we test exceptions that could be thrown by the ruby wrappers # we test exceptions that could be thrown by the ruby wrappers
define_test 'Test bogus arguments' do define_test 'Test bogus arguments' do
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
@hbase.rsgroup_admin(@formatter).get_rsgroup('foobar') @hbase.rsgroup_admin().get_rsgroup('foobar')
end end
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
@hbase.rsgroup_admin(@formatter).get_rsgroup_of_server('foobar:123') @hbase.rsgroup_admin().get_rsgroup_of_server('foobar:123')
end end
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
@hbase.rsgroup_admin(@formatter).get_rsgroup_of_table('foobar') @hbase.rsgroup_admin().get_rsgroup_of_table('foobar')
end end
end end
end end

View File

@ -17,15 +17,13 @@
# limitations under the License. # limitations under the License.
# #
require 'hbase' require 'hbase_constants'
require 'shell' require 'shell'
require 'shell/formatter'
class ShellTest < Test::Unit::TestCase class ShellTest < Test::Unit::TestCase
def setup def setup
@formatter = ::Shell::Formatter::Console.new()
@hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) @hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
@shell = Shell::Shell.new(@hbase, @formatter) @shell = Shell::Shell.new(@hbase)
end end
define_test "Shell::Shell#hbase_admin should return an admin instance" do define_test "Shell::Shell#hbase_admin should return an admin instance" do

View File

@ -37,15 +37,13 @@ end
module Hbase module Hbase
module TestHelpers module TestHelpers
require 'hbase' require 'hbase_constants'
require 'hbase/hbase' require 'hbase/hbase'
require 'shell' require 'shell'
require 'shell/formatter'
def setup_hbase def setup_hbase
formatter = ::Shell::Formatter::Console.new
hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration)
@shell = ::Shell::Shell.new(hbase, formatter) @shell = ::Shell::Shell.new(hbase)
end end
def shutdown def shutdown
@ -72,6 +70,10 @@ module Hbase
@shell.hbase_visibility_labels_admin @shell.hbase_visibility_labels_admin
end end
def quotas_admin
@shell.hbase_quotas_admin
end
def replication_admin def replication_admin
@shell.hbase_replication_admin @shell.hbase_replication_admin
end end