HBASE-2313 Nit-pick about hbase-2279 shell fixup, if you do get with non-existant column family, throws lots of exceptions
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@923894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0f9ecf657a
commit
dfc23200bd
|
@ -436,6 +436,9 @@ Release 0.21.0 - Unreleased
|
|||
HBASE-2314 [shell] Support for getting counters (Alexey Kovyrin via Stack)
|
||||
HBASE-2324 Refactoring of TableRecordReader (mapred / mapreduce) for reuse
|
||||
outside the scope of InputSplit / RecordReader (Kay Kay via Stack)
|
||||
HBASE-2313 Nit-pick about hbase-2279 shell fixup, if you do get with
|
||||
non-existant column family, throws lots of exceptions
|
||||
(Alexey Kovyrin via Stack)
|
||||
|
||||
NEW FEATURES
|
||||
HBASE-1961 HBase EC2 scripts
|
||||
|
|
17
bin/hirb.rb
17
bin/hirb.rb
|
@ -112,6 +112,23 @@ def tools
|
|||
@shell.help_group('tools')
|
||||
end
|
||||
|
||||
# Debugging method
|
||||
def debug
|
||||
if @shell.debug
|
||||
@shell.debug = false
|
||||
conf.back_trace_limit = 0
|
||||
else
|
||||
@shell.debug = true
|
||||
conf.back_trace_limit = 100
|
||||
end
|
||||
debug?
|
||||
end
|
||||
|
||||
def debug?
|
||||
puts "Debug mode is #{@shell.debug ? 'ON' : 'OFF'}\n\n"
|
||||
nil
|
||||
end
|
||||
|
||||
# Include hbase constants
|
||||
include HBaseConstants
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ module Hbase
|
|||
else
|
||||
self.configuration = org.apache.hadoop.hbase.HBaseConfiguration.create
|
||||
# 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", 1)
|
||||
configuration.setInt("ipc.client.connect.max.retries", 3)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -47,6 +47,9 @@ module Shell
|
|||
attr_accessor :hbase
|
||||
attr_accessor :formatter
|
||||
|
||||
@debug = false
|
||||
attr_accessor :debug
|
||||
|
||||
def initialize(hbase, formatter)
|
||||
self.hbase = hbase
|
||||
self.formatter = formatter
|
||||
|
@ -65,6 +68,7 @@ module Shell
|
|||
where.send :instance_eval, <<-EOF
|
||||
def #{cmd}(*args)
|
||||
@shell.command('#{cmd}', *args)
|
||||
puts
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
@ -75,13 +79,14 @@ module Shell
|
|||
end
|
||||
|
||||
def command(command, *args)
|
||||
command_instance(command).command_safe(*args)
|
||||
command_instance(command).command_safe(self.debug, *args)
|
||||
end
|
||||
|
||||
def print_banner
|
||||
puts "HBase Shell; enter 'help<RETURN>' for list of supported commands."
|
||||
puts 'Type "exit<RETURN>" to leave the HBase Shell'
|
||||
command('version')
|
||||
puts
|
||||
end
|
||||
|
||||
def help_command(command)
|
||||
|
|
|
@ -7,11 +7,12 @@ module Shell
|
|||
self.shell = shell
|
||||
end
|
||||
|
||||
def command_safe(*args)
|
||||
command(*args)
|
||||
rescue ArgumentError => e
|
||||
def command_safe(debug, *args)
|
||||
translate_hbase_exceptions(*args) { command(*args) }
|
||||
rescue => e
|
||||
puts
|
||||
puts "ERROR: #{e}"
|
||||
puts "Backtrace: #{e.backtrace.join("\n ")}" if debug
|
||||
puts
|
||||
puts "Here is some help for this command:"
|
||||
puts help
|
||||
|
@ -40,6 +41,17 @@ module Shell
|
|||
formatter.header
|
||||
formatter.footer(now)
|
||||
end
|
||||
|
||||
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}!"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue