diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index a39b6175b0c..a567596be38 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -81,8 +81,9 @@ module Shell self.interactive = interactive end - def hbase_admin - @hbase_admin ||= hbase.admin() + # Returns Admin class from admin.rb + def admin + @admin ||= hbase.admin() end def hbase_taskmonitor @@ -139,7 +140,7 @@ module Shell # method_name - name of the method on the command to call. Defaults to just 'command' # args - to be passed to the named method def internal_command(command, method_name= :command, *args) - command_instance(command).command_safe(self.debug,method_name, *args) + command_instance(command).command_safe(self.debug, method_name, *args) end def print_banner diff --git a/hbase-shell/src/main/ruby/shell/commands.rb b/hbase-shell/src/main/ruby/shell/commands.rb index d580f5e7952..225b9d40a2e 100644 --- a/hbase-shell/src/main/ruby/shell/commands.rb +++ b/hbase-shell/src/main/ruby/shell/commands.rb @@ -29,9 +29,12 @@ module Shell # cmd - command name to execute # args - arguments to pass to the command def command_safe(debug, cmd = :command, *args) + # Commands can overwrite start_time to skip time used in some kind of setup. + # See count.rb for example. + @start_time = Time.now # send is internal ruby method to call 'cmd' with *args #(everything is a message, so this is just the formal semantics to support that idiom) - translate_hbase_exceptions(*args) { send(cmd,*args) } + translate_hbase_exceptions(*args) { send(cmd, *args) } rescue => e rootCause = e while rootCause != nil && rootCause.respond_to?(:cause) && rootCause.cause != nil @@ -48,13 +51,16 @@ module Shell else raise rootCause end + ensure + # If end_time is not already set by the command, use current time. + @end_time ||= Time.now + formatter.output_str("Took %.4f seconds" % [@end_time - @start_time]) end # Convenience functions to get different admins - # Returns HBase::Admin ruby class. def admin - @shell.hbase_admin + @shell.admin end def taskmonitor @@ -87,21 +93,6 @@ module Shell @formatter ||= ::Shell::Formatter::Console.new end - def format_simple_command - now = Time.now - yield - formatter.header - formatter.footer(now) - end - - def format_and_return_simple_command - now = Time.now - ret = yield - formatter.header - formatter.footer(now) - return ret - end - def translate_hbase_exceptions(*args) yield rescue => e diff --git a/hbase-shell/src/main/ruby/shell/commands/abort_procedure.rb b/hbase-shell/src/main/ruby/shell/commands/abort_procedure.rb index 6f77ab7059c..e69e1339c4a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/abort_procedure.rb +++ b/hbase-shell/src/main/ruby/shell/commands/abort_procedure.rb @@ -40,11 +40,7 @@ EOF end def command(proc_id, may_interrupt_if_running=nil) - format_simple_command do - formatter.row([ - admin.abort_procedure?(proc_id, may_interrupt_if_running).to_s - ]) - end + formatter.row([admin.abort_procedure?(proc_id, may_interrupt_if_running).to_s]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/add_labels.rb b/hbase-shell/src/main/ruby/shell/commands/add_labels.rb index 65a1140f240..7bde5fb1c50 100644 --- a/hbase-shell/src/main/ruby/shell/commands/add_labels.rb +++ b/hbase-shell/src/main/ruby/shell/commands/add_labels.rb @@ -31,9 +31,7 @@ EOF end def command(*args) - format_simple_command do - visibility_labels_admin.add_labels(args) - end + visibility_labels_admin.add_labels(args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/add_peer.rb b/hbase-shell/src/main/ruby/shell/commands/add_peer.rb index 0fcdd3df3d9..b8e8bb26e81 100644 --- a/hbase-shell/src/main/ruby/shell/commands/add_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/add_peer.rb @@ -58,9 +58,7 @@ EOF end def command(id, args = {}, peer_tableCFs = nil) - format_simple_command do - replication_admin.add_peer(id, args, peer_tableCFs) - end + replication_admin.add_peer(id, args, peer_tableCFs) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb index 2c3aa6f872b..91b3e2e4cdb 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb @@ -92,9 +92,7 @@ EOF end def command(table, *args) - format_simple_command do - admin.alter(table, true, *args) - end + admin.alter(table, true, *args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/alter_async.rb b/hbase-shell/src/main/ruby/shell/commands/alter_async.rb index bddff010a28..e0f6debb2aa 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter_async.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter_async.rb @@ -56,9 +56,7 @@ EOF end def command(table, *args) - format_simple_command do - admin.alter(table, false, *args) - end + admin.alter(table, false, *args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb index a16e10d8ffa..0051c7f11ef 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb @@ -35,9 +35,7 @@ EOF end def command(namespace, *args) - format_simple_command do - admin.alter_namespace(namespace, *args) - end + admin.alter_namespace(namespace, *args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/append.rb b/hbase-shell/src/main/ruby/shell/commands/append.rb index a0ef36d28e0..93a43174365 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append.rb @@ -35,14 +35,14 @@ t to table 't1', the corresponding command would be: EOF end - def command(table, row, column, value, args={}) - append(table(table), row, column, value, args) + def command(table_name, row, column, value, args={}) + table = table(table_name) + @start_time = Time.now + append(table, row, column, value, args) end def append(table, row, column, value, args={}) - format_simple_command do - table._append_internal(row, column, value, args) - end + table._append_internal(row, column, value, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb index 3919b203170..3fe5befe06c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append_peer_tableCFs.rb @@ -32,9 +32,7 @@ EOF end def command(id, table_cfs) - format_simple_command do - replication_admin.append_peer_tableCFs(id, table_cfs) - end + replication_admin.append_peer_tableCFs(id, table_cfs) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/assign.rb b/hbase-shell/src/main/ruby/shell/commands/assign.rb index 448a5460b4e..1220bf1e060 100644 --- a/hbase-shell/src/main/ruby/shell/commands/assign.rb +++ b/hbase-shell/src/main/ruby/shell/commands/assign.rb @@ -32,9 +32,7 @@ EOF end def command(region_name) - format_simple_command do - admin.assign(region_name) - end + admin.assign(region_name) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb b/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb index 4d7778daa41..107d26748fa 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb @@ -31,11 +31,7 @@ EOF end def command(enableDisable) - format_simple_command do - formatter.row([ - admin.balance_switch(enableDisable)? "true" : "false" - ]) - end + formatter.row([admin.balance_switch(enableDisable)? "true" : "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/balancer.rb b/hbase-shell/src/main/ruby/shell/commands/balancer.rb index ee53ca000f4..a7490a51c65 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balancer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balancer.rb @@ -38,15 +38,13 @@ EOF end def command(force=nil) - format_simple_command do - formatter.row([ - if force.nil? - admin.balancer("false")? "true": "false" - elsif force == "force" - admin.balancer("true")? "true": "false" - end - ]) + force_balancer = 'false' + if force == 'force' + force_balancer = 'true' + elsif !force.nil? + raise ArgumentError, "Invalid argument #{force}." end + formatter.row([admin.balancer(force_balancer)? "true": "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb index 3b2f5c64fe5..6a75ab54fe7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb @@ -30,11 +30,7 @@ EOF end def command() - format_simple_command do - formatter.row([ - admin.balancer_enabled?.to_s - ]) - end + formatter.row([admin.balancer_enabled?.to_s]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb index b310c3a7ab0..fdeb67e857f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb @@ -29,11 +29,7 @@ EOF end def command() - format_simple_command do - formatter.row([ - admin.catalogjanitor_enabled()? "true" : "false" - ]) - end + formatter.row([admin.catalogjanitor_enabled()? "true" : "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb index 03426cb4f14..638a18f4d51 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb @@ -28,9 +28,7 @@ Catalog janitor command to run the (garbage collection) scan from command line. EOF end def command() - format_simple_command do - admin.catalogjanitor_run() - end + admin.catalogjanitor_run() end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb index fce1925eecb..d2d8e58696c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb @@ -30,11 +30,7 @@ EOF end def command(enableDisable) - format_simple_command do - formatter.row([ - admin.catalogjanitor_switch(enableDisable)? "true" : "false" - ]) - end + formatter.row([admin.catalogjanitor_switch(enableDisable)? "true" : "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb b/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb index 8553fa64713..be56d5d1095 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb @@ -31,9 +31,7 @@ EOF end def command(user, *args) - format_simple_command do - visibility_labels_admin.clear_auths(user, args) - end + visibility_labels_admin.clear_auths(user, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb index 0498c8e3e4f..c57e87f41e4 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb @@ -32,9 +32,7 @@ EOF end def command(snapshot_name, table) - format_simple_command do - admin.clone_snapshot(snapshot_name, table) - end + admin.clone_snapshot(snapshot_name, table) end def handle_exceptions(cause, *args) diff --git a/hbase-shell/src/main/ruby/shell/commands/close_region.rb b/hbase-shell/src/main/ruby/shell/commands/close_region.rb index 9e2900c31be..368a2507022 100644 --- a/hbase-shell/src/main/ruby/shell/commands/close_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/close_region.rb @@ -52,9 +52,7 @@ EOF end def command(region_name, server = nil) - format_simple_command do - admin.close_region(region_name, server) - end + admin.close_region(region_name, server) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/compact.rb b/hbase-shell/src/main/ruby/shell/commands/compact.rb index adeffa2d034..d59e3b30605 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compact.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compact.rb @@ -39,9 +39,7 @@ module Shell end def command(table_or_region_name, family = nil) - format_simple_command do - admin.compact(table_or_region_name, family) - end + admin.compact(table_or_region_name, family) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb index 0ecdd21113f..588b6fe1caa 100644 --- a/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/compact_rs.rb @@ -34,9 +34,7 @@ module Shell end def command(regionserver, major = false) - format_simple_command do - admin.compact_regionserver(regionserver, major) - end + admin.compactRegionserver(regionserver, major) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/count.rb b/hbase-shell/src/main/ruby/shell/commands/count.rb index 225005ee36e..36250a6202c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/count.rb +++ b/hbase-shell/src/main/ruby/shell/commands/count.rb @@ -61,12 +61,12 @@ EOF }.merge(params) # Call the counter method - now = Time.now + @start_time = Time.now formatter.header count = table._count_internal(params['INTERVAL'].to_i, params['CACHE'].to_i) do |cnt, row| formatter.row([ "Current count: #{cnt}, row: #{row}" ]) end - formatter.footer(now, count) + formatter.footer(count) return count end end diff --git a/hbase-shell/src/main/ruby/shell/commands/create.rb b/hbase-shell/src/main/ruby/shell/commands/create.rb index a5a125e15b1..4e35b4ed6d9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/create.rb +++ b/hbase-shell/src/main/ruby/shell/commands/create.rb @@ -62,10 +62,9 @@ EOF end def command(table, *args) - format_simple_command do - ret = admin.create(table, *args) - end - #and then return the table you just created + admin.create(table, *args) + @end_time = Time.now + #and then return the table just created table(table) end end diff --git a/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb index adb6897b719..d478fc1665d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb @@ -32,9 +32,7 @@ EOF end def command(namespace, *args) - format_simple_command do - admin.create_namespace(namespace, *args) - end + admin.create_namespace(namespace, *args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/delete.rb b/hbase-shell/src/main/ruby/shell/commands/delete.rb index dcb83414f62..bce66255317 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete.rb @@ -40,16 +40,15 @@ t to table 't1', the corresponding command would be: EOF end - def command(table, row, column, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + def command(table, row, column, + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) delete(table(table), row, column, timestamp, args) end - def delete(table, row, column, - timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) - format_simple_command do - table._delete_internal(row, column, timestamp, args) - end + def delete(table, row, column, + timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) + @start_time = Time.now + table._delete_internal(row, column, timestamp, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb index bc072597bb2..5a77f7398ab 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_all_snapshot.rb @@ -41,9 +41,9 @@ EOF answer = gets.chomp unless count == 0 puts "No snapshots matched the regex #{regex.to_s}" if count == 0 return unless answer =~ /y.*/i - format_simple_command do - admin.delete_all_snapshot(regex) - end + @start_time = Time.now + admin.delete_all_snapshot(regex) + @end_time = Time.now list = admin.list_snapshot(regex) leftOverSnapshotCount = list.size successfullyDeleted = count - leftOverSnapshotCount diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb index b8c3791a540..48059b0d3e0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb @@ -28,9 +28,7 @@ EOF end def command(snapshot_name) - format_simple_command do - admin.delete_snapshot(snapshot_name) - end + admin.delete_snapshot(snapshot_name) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb index dc4e0a235f0..89936f18cdd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_table_snapshots.rb @@ -51,16 +51,15 @@ EOF puts "No snapshots matched the table name regular expression #{tableNameregex.to_s} and the snapshot name regular expression #{snapshotNameRegex.to_s}" if count == 0 return unless answer =~ /y.*/i - format_simple_command do - list.each do |deleteSnapshot| - begin - admin.delete_snapshot(deleteSnapshot.getName) - puts "Successfully deleted snapshot: #{deleteSnapshot.getName}" - puts "\n" - rescue RuntimeError - puts "Failed to delete snapshot: #{deleteSnapshot.getName}, due to below exception,\n" + $! - puts "\n" - end + @start_time = Time.now + list.each do |deleteSnapshot| + begin + admin.delete_snapshot(deleteSnapshot.getName) + puts "Successfully deleted snapshot: #{deleteSnapshot.getName}" + puts "\n" + rescue RuntimeError + puts "Failed to delete snapshot: #{deleteSnapshot.getName}, due to below exception,\n" + $! + puts "\n" end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index e6118c9144b..2965403d882 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -48,9 +48,8 @@ EOF def deleteall(table, row, column = nil, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}) - format_simple_command do - table._deleteall_internal(row, column, timestamp, args) - end + @start_time = Time.now + table._deleteall_internal(row, column, timestamp, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/describe.rb b/hbase-shell/src/main/ruby/shell/commands/describe.rb index bfa16cdc2da..37938a7c89a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe.rb @@ -33,8 +33,6 @@ EOF end def command(table) - now = Time.now - column_families = admin.get_column_families(table) formatter.header(["Table " + table.to_s + " is " + if admin.enabled?(table) then "ENABLED" else "DISABLED" end]) @@ -43,7 +41,7 @@ EOF column_families.each do |column_family| formatter.row([ column_family.to_s ], true) end - formatter.footer(now) + formatter.footer() end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb index cf135da5584..ebd9bd2a593 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb @@ -28,13 +28,10 @@ EOF end def command(namespace) - now = Time.now - desc = admin.describe_namespace(namespace) formatter.header([ "DESCRIPTION" ], [ 64 ]) formatter.row([ desc ], true, [ 64 ]) - formatter.footer(now) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/disable.rb b/hbase-shell/src/main/ruby/shell/commands/disable.rb index 79bcd864f7f..66950020085 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable.rb @@ -29,9 +29,7 @@ EOF end def command(table) - format_simple_command do - admin.disable(table) - end + admin.disable(table) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb b/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb index 416545b21fb..c193f13864a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb @@ -32,9 +32,7 @@ EOF end def command(id) - format_simple_command do - replication_admin.disable_peer(id) - end + replication_admin.disable_peer(id) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/disable_table_replication.rb b/hbase-shell/src/main/ruby/shell/commands/disable_table_replication.rb index 5bf96679493..a020d81a30e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_table_replication.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_table_replication.rb @@ -30,10 +30,8 @@ EOF end def command(table_name) - format_simple_command do - replication_admin.disable_tablerep(table_name) - end - puts "The replication swith of table '#{table_name}' successfully disabled" + replication_admin.disable_tablerep(table_name) + puts "Replication of table '#{table_name}' successfully disabled." end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/drop.rb b/hbase-shell/src/main/ruby/shell/commands/drop.rb index fc7b1344686..3f7332c59cc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/drop.rb +++ b/hbase-shell/src/main/ruby/shell/commands/drop.rb @@ -29,9 +29,7 @@ EOF end def command(table) - format_simple_command do - admin.drop(table) - end + admin.drop(table) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb index b030d279c77..392f24789b9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb @@ -27,9 +27,7 @@ EOF end def command(namespace) - format_simple_command do - admin.drop_namespace(namespace) - end + admin.drop_namespace(namespace) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/enable.rb b/hbase-shell/src/main/ruby/shell/commands/enable.rb index deeb70cce25..5d21219c85b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable.rb @@ -29,9 +29,7 @@ EOF end def command(table) - format_simple_command do - admin.enable(table) - end + admin.enable(table) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb b/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb index 55136ffb7fb..5f1a7273737 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb @@ -32,9 +32,7 @@ EOF end def command(id) - format_simple_command do - replication_admin.enable_peer(id) - end + replication_admin.enable_peer(id) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/enable_table_replication.rb b/hbase-shell/src/main/ruby/shell/commands/enable_table_replication.rb index 15e3133a895..e4e2fc1fbbe 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_table_replication.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_table_replication.rb @@ -30,10 +30,8 @@ EOF end def command(table_name) - format_simple_command do - replication_admin.enable_tablerep(table_name) - end - puts "The replication swith of table '#{table_name}' successfully enabled" + replication_admin.enable_tablerep(table_name) + puts "The replication of table '#{table_name}' successfully enabled" end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/exists.rb b/hbase-shell/src/main/ruby/shell/commands/exists.rb index bacf6c94c44..7a64813e901 100644 --- a/hbase-shell/src/main/ruby/shell/commands/exists.rb +++ b/hbase-shell/src/main/ruby/shell/commands/exists.rb @@ -29,11 +29,9 @@ EOF end def command(table) - format_simple_command do - formatter.row([ + formatter.row([ "Table #{table} " + (admin.exists?(table.to_s) ? "does exist" : "does not exist") ]) - end end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/flush.rb b/hbase-shell/src/main/ruby/shell/commands/flush.rb index 2aefec52e9d..13963e19d1c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/flush.rb +++ b/hbase-shell/src/main/ruby/shell/commands/flush.rb @@ -32,9 +32,7 @@ EOF end def command(table_or_region_name) - format_simple_command do - admin.flush(table_or_region_name) - end + admin.flush(table_or_region_name) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/get.rb b/hbase-shell/src/main/ruby/shell/commands/get.rb index b8bfd5204ca..8191c22cea5 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get.rb @@ -81,14 +81,14 @@ EOF end def get(table, row, *args) - now = Time.now + @start_time = Time.now formatter.header(["COLUMN", "CELL"]) count, is_stale = table._get_internal(row, *args) do |column, value| formatter.row([ column, value ]) end - formatter.footer(now, count, is_stale) + formatter.footer(count, is_stale) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/get_auths.rb b/hbase-shell/src/main/ruby/shell/commands/get_auths.rb index 1b758ef9495..04b486b8e2c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_auths.rb @@ -31,11 +31,9 @@ EOF end def command(user) - format_simple_command do - list = visibility_labels_admin.get_auths(user) - list.each do |auths| - formatter.row([org.apache.hadoop.hbase.util.Bytes::toStringBinary(auths.toByteArray)]) - end + list = visibility_labels_admin.get_auths(user) + list.each do |auths| + formatter.row([org.apache.hadoop.hbase.util.Bytes::toStringBinary(auths.toByteArray)]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb b/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb index ee02229c468..3da6bdfee75 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_peer_config.rb @@ -25,10 +25,9 @@ module Shell end def command(id) - peer_config = replication_admin.get_peer_config(id) - format_simple_command do - format_peer_config(peer_config) - end + peer_config = replication_admin.get_peer_config(id) + @start_time = Time.now + format_peer_config(peer_config) end def format_peer_config(peer_config) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_table.rb b/hbase-shell/src/main/ruby/shell/commands/get_table.rb index 43e7c1af708..2270f43f958 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_table.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_table.rb @@ -38,9 +38,7 @@ EOF end def command(table, *args) - format_and_return_simple_command do - table(table) - end + table(table) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/grant.rb b/hbase-shell/src/main/ruby/shell/commands/grant.rb index 788002647d6..12feb58eb7f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/grant.rb +++ b/hbase-shell/src/main/ruby/shell/commands/grant.rb @@ -74,9 +74,8 @@ EOF end end end - format_simple_command do - security_admin.grant(user, permissions, table_name, family, qualifier) - end + @start_time = Time.now + security_admin.grant(user, permissions, table_name, family, qualifier) elsif args[1].kind_of?(Hash) @@ -92,7 +91,7 @@ EOF raise(ArgumentError, "Scanner specification is not a Hash") unless scan.kind_of?(Hash) t = table(table_name) - now = Time.now + @start_time = Time.now scanner = t._get_scanner(scan) count = 0 iter = scanner.iterator @@ -106,7 +105,7 @@ EOF end count += 1 end - formatter.footer(now, count) + formatter.footer(count) else raise(ArgumentError, "Second argument should be a String or Hash") diff --git a/hbase-shell/src/main/ruby/shell/commands/incr.rb b/hbase-shell/src/main/ruby/shell/commands/incr.rb index d223a45aafe..318fac3e722 100644 --- a/hbase-shell/src/main/ruby/shell/commands/incr.rb +++ b/hbase-shell/src/main/ruby/shell/commands/incr.rb @@ -49,13 +49,11 @@ EOF end def incr(table, row, column, value = nil, args={}) - format_simple_command do - if cnt = table._incr_internal(row, column, value, args) - puts "COUNTER VALUE = #{cnt}" - else - puts "No counter found at specified coordinates" - end - end + if cnt = table._incr_internal(row, column, value, args) + puts "COUNTER VALUE = #{cnt}" + else + puts "No counter found at specified coordinates" + end end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb b/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb index 6da7046ba79..6a914e36929 100644 --- a/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb @@ -29,12 +29,8 @@ EOF end def command(table) - format_simple_command do - formatter.row([ - admin.disabled?(table)? "true" : "false" - ]) - end - end + formatter.row([admin.disabled?(table)? "true" : "false"]) + end end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb index 960ade75724..d8fb2ab576a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb @@ -29,11 +29,7 @@ EOF end def command(table) - format_simple_command do - formatter.row([ - admin.enabled?(table)? "true" : "false" - ]) - end + formatter.row([admin.enabled?(table)? "true" : "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list.rb b/hbase-shell/src/main/ruby/shell/commands/list.rb index dce0ae2acdc..f7a09878f24 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list.rb @@ -33,7 +33,6 @@ EOF end def command(regex = ".*") - now = Time.now formatter.header([ "TABLE" ]) list = admin.list(regex) @@ -41,7 +40,7 @@ EOF formatter.row([ table ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) return list end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_labels.rb b/hbase-shell/src/main/ruby/shell/commands/list_labels.rb index 6c7f99137b7..6b730b2c03a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_labels.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_labels.rb @@ -32,11 +32,9 @@ EOF end def command(regex = ".*") - format_simple_command do - list = visibility_labels_admin.list_labels(regex) - list.each do |label| - formatter.row([org.apache.hadoop.hbase.util.Bytes::toStringBinary(label.toByteArray)]) - end + list = visibility_labels_admin.list_labels(regex) + list.each do |label| + formatter.row([org.apache.hadoop.hbase.util.Bytes::toStringBinary(label.toByteArray)]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb b/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb index 5d25604afa7..63aeac1de96 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb @@ -31,7 +31,6 @@ EOF end def command(regex = ".*") - now = Time.now formatter.header([ "NAMESPACE" ]) list = admin.list_namespace(regex) @@ -39,7 +38,7 @@ EOF formatter.row([ table ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_namespace_tables.rb b/hbase-shell/src/main/ruby/shell/commands/list_namespace_tables.rb index 29e18123e6b..9db090edf55 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_namespace_tables.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_namespace_tables.rb @@ -30,7 +30,6 @@ EOF end def command(namespace) - now = Time.now formatter.header([ "TABLE" ]) list = admin.list_namespace_tables(namespace) @@ -38,7 +37,7 @@ EOF formatter.row([ table ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb b/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb index fc6e4a78740..153e0ce33bb 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_peer_configs.rb @@ -25,16 +25,14 @@ module Shell end def command - format_simple_command do - peer_configs = replication_admin.list_peer_configs - unless peer_configs.nil? - peer_configs.each do |peer_config_entry| - peer_id = peer_config_entry[0] - peer_config = peer_config_entry[1] - formatter.row(["PeerId", peer_id]) - GetPeerConfig.new(@shell).format_peer_config(peer_config) - formatter.row([" "]) - end + peer_configs = replication_admin.list_peer_configs + unless peer_configs.nil? + peer_configs.each do |peer_config_entry| + peer_id = peer_config_entry[0] + peer_config = peer_config_entry[1] + formatter.row(["PeerId", peer_id]) + GetPeerConfig.new(@shell).format_peer_config(peer_config) + formatter.row([" "]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_peers.rb b/hbase-shell/src/main/ruby/shell/commands/list_peers.rb index cc1be044169..c5c3397bb89 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_peers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_peers.rb @@ -30,7 +30,6 @@ EOF end def command() - now = Time.now peers = replication_admin.list_peers formatter.header(["PEER_ID", "CLUSTER_KEY", "STATE", "TABLE_CFS"]) @@ -41,7 +40,7 @@ EOF formatter.row([ e.key, e.value, state, tableCFs ]) end - formatter.footer(now) + formatter.footer() end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb b/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb index f407547f34c..83e08c172d2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb @@ -29,7 +29,6 @@ EOF end def command() - now = Time.now formatter.header([ "Id", "Name", "State", "Start_Time", "Last_Update" ]) list = admin.list_procedures() @@ -39,7 +38,7 @@ EOF formatter.row([ proc.getProcId, proc.getProcName, proc.getProcState, start_time, last_update ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb b/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb index 682bb7197c2..604d833374f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb @@ -37,7 +37,6 @@ EOF end def command(args = {}) - now = Time.now formatter.header(["OWNER", "QUOTAS"]) #actually do the scanning @@ -45,7 +44,7 @@ EOF formatter.row([ row, cells ]) end - formatter.footer(now, count) + formatter.footer(count) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb b/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb index 0db1d83aeb9..142adfc7a46 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb @@ -31,8 +31,6 @@ EOF end def command(regex = ".*") - now = Time.now - formatter.header([ "TABLE:COLUMNFAMILY", "ReplicationType" ], [ 32 ]) list = replication_admin.list_replicated_tables(regex) list.each do |e| @@ -43,7 +41,7 @@ EOF end formatter.row([e.get(org.apache.hadoop.hbase.client.replication.ReplicationAdmin::TNAME) + ":" + e.get(org.apache.hadoop.hbase.client.replication.ReplicationAdmin::CFNAME), replicateType], true, [32]) end - formatter.footer(now) + formatter.footer() end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb index 4e68802f8dd..bc917375a86 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb @@ -34,7 +34,6 @@ EOF end def command(regex = ".*") - now = Time.now formatter.header([ "SNAPSHOT", "TABLE + CREATION TIME"]) list = admin.list_snapshot(regex) @@ -43,7 +42,7 @@ EOF formatter.row([ snapshot.getName, snapshot.getTable + " (" + creation_time + ")" ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) return list.map { |s| s.getName() } end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_table_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/list_table_snapshots.rb index 3a32e9e3ea7..1efcc1776c1 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_table_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_table_snapshots.rb @@ -39,7 +39,6 @@ EOF end def command(tableNameRegex, snapshotNameRegex = ".*") - now = Time.now formatter.header([ "SNAPSHOT", "TABLE + CREATION TIME"]) list = admin.list_table_snapshots(tableNameRegex, snapshotNameRegex) @@ -48,7 +47,7 @@ EOF formatter.row([ snapshot.getName, snapshot.getTable + " (" + creation_time + ")" ]) end - formatter.footer(now, list.size) + formatter.footer(list.size) return list.map { |s| s.getName() } end end diff --git a/hbase-shell/src/main/ruby/shell/commands/locate_region.rb b/hbase-shell/src/main/ruby/shell/commands/locate_region.rb index b1e8c7bf485..a2815d62ba9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/locate_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/locate_region.rb @@ -30,14 +30,12 @@ EOF end def command(table, row_key) - now = Time.now - region_location = admin.locate_region(table, row_key) hri = region_location.getRegionInfo() formatter.header([ "HOST", "REGION" ]) formatter.row([region_location.getHostnamePort(), hri.toString()]) - formatter.footer(now, 1) + formatter.footer(1) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/major_compact.rb b/hbase-shell/src/main/ruby/shell/commands/major_compact.rb index 825748336cf..f42af6765ca 100644 --- a/hbase-shell/src/main/ruby/shell/commands/major_compact.rb +++ b/hbase-shell/src/main/ruby/shell/commands/major_compact.rb @@ -40,9 +40,7 @@ module Shell end def command(table_or_region_name, family = nil) - format_simple_command do - admin.major_compact(table_or_region_name, family) - end + admin.major_compact(table_or_region_name, family) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/merge_region.rb b/hbase-shell/src/main/ruby/shell/commands/merge_region.rb index 6afa2e5b503..63f7159e968 100644 --- a/hbase-shell/src/main/ruby/shell/commands/merge_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/merge_region.rb @@ -40,9 +40,7 @@ EOF end def command(encoded_region_a_name, encoded_region_b_name, force = 'false') - format_simple_command do - admin.merge_region(encoded_region_a_name, encoded_region_b_name, force) - end + admin.merge_region(encoded_region_a_name, encoded_region_b_name, force) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/move.rb b/hbase-shell/src/main/ruby/shell/commands/move.rb index e6b28288e3f..24816f3aa62 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move.rb @@ -38,9 +38,7 @@ EOF end def command(encoded_region_name, server_name = nil) - format_simple_command do - admin.move(encoded_region_name, server_name) - end + admin.move(encoded_region_name, server_name) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/normalize.rb b/hbase-shell/src/main/ruby/shell/commands/normalize.rb index 7e6302c8514..0a612273f4d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalize.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalize.rb @@ -33,11 +33,7 @@ EOF end def command() - format_simple_command do - formatter.row([ - admin.normalize()? "true": "false" - ]) - end + formatter.row([admin.normalize()? "true": "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb index 1121b25eb05..d39b7772d92 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb @@ -30,11 +30,7 @@ EOF end def command() - format_simple_command do - formatter.row([ - admin.normalizer_enabled?.to_s - ]) - end + formatter.row([admin.normalizer_enabled?.to_s]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb b/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb index 6d959c4977a..7a12b71d9bc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb @@ -32,11 +32,7 @@ EOF end def command(enableDisable) - format_simple_command do - formatter.row([ - admin.normalizer_switch(enableDisable)? "true" : "false" - ]) - end + formatter.row([admin.normalizer_switch(enableDisable)? "true" : "false"]) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/put.rb b/hbase-shell/src/main/ruby/shell/commands/put.rb index 2b47a4d5c6e..39f9feab332 100644 --- a/hbase-shell/src/main/ruby/shell/commands/put.rb +++ b/hbase-shell/src/main/ruby/shell/commands/put.rb @@ -45,9 +45,8 @@ EOF end def put(table, row, column, value, timestamp = nil, args = {}) - format_simple_command do - table._put_internal(row, column, value, timestamp, args) - end + @start_time = Time.now + table._put_internal(row, column, value, timestamp, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb b/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb index 5ae5786fc4a..bc9d6ab984e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb @@ -30,9 +30,7 @@ EOF end def command(id) - format_simple_command do - replication_admin.remove_peer(id) - end + replication_admin.remove_peer(id) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/remove_peer_tableCFs.rb index 5b15b529651..c1bd5d0bcf2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer_tableCFs.rb @@ -33,9 +33,7 @@ EOF end def command(id, table_cfs) - format_simple_command do - replication_admin.remove_peer_tableCFs(id, table_cfs) - end + replication_admin.remove_peer_tableCFs(id, table_cfs) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb index 4d531711bca..2471e1bfb86 100644 --- a/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb @@ -32,9 +32,7 @@ EOF end def command(snapshot_name) - format_simple_command do - admin.restore_snapshot(snapshot_name) - end + admin.restore_snapshot(snapshot_name) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/revoke.rb b/hbase-shell/src/main/ruby/shell/commands/revoke.rb index 4a0d5ff62e1..bcf60e9f964 100644 --- a/hbase-shell/src/main/ruby/shell/commands/revoke.rb +++ b/hbase-shell/src/main/ruby/shell/commands/revoke.rb @@ -39,9 +39,7 @@ EOF end def command(user, table_name=nil, family=nil, qualifier=nil) - format_simple_command do - security_admin.revoke(user, table_name, family, qualifier) - end + security_admin.revoke(user, table_name, family, qualifier) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/scan.rb b/hbase-shell/src/main/ruby/shell/commands/scan.rb index 106eccf662c..e7b5d82795b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/scan.rb +++ b/hbase-shell/src/main/ruby/shell/commands/scan.rb @@ -104,16 +104,17 @@ EOF #internal command that actually does the scanning def scan(table, args = {}) - now = Time.now formatter.header(["ROW", "COLUMN+CELL"]) scan = table._hash_to_scan(args) #actually do the scanning + @start_time = Time.now count, is_stale = table._scan_internal(args, scan) do |row, cells| formatter.row([ row, cells ]) end + @end_time = Time.now - formatter.footer(now, count, is_stale) + formatter.footer(count, is_stale) # if scan metrics were enabled, print them after the results if (scan != nil && scan.isScanMetricsEnabled()) formatter.scan_metrics(scan.getScanMetrics(), args["METRICS"]) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_auths.rb b/hbase-shell/src/main/ruby/shell/commands/set_auths.rb index 4a52eb0ef7d..5663ec384f7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_auths.rb @@ -31,9 +31,7 @@ EOF end def command(user, *args) - format_simple_command do - visibility_labels_admin.set_auths(user, args) - end + visibility_labels_admin.set_auths(user, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb index 3a88dbb7412..b901cf02070 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb @@ -38,9 +38,7 @@ module Shell end def command(id, peer_table_cfs = nil) - format_simple_command do - replication_admin.set_peer_tableCFs(id, peer_table_cfs) - end + replication_admin.set_peer_tableCFs(id, peer_table_cfs) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb index 59779fb138a..962d8cd8c87 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb @@ -51,7 +51,7 @@ EOF def command(table, visibility, scan) t = table(table) - now = Time.now + @start_time = Time.now scanner = t._get_scanner(scan) count = 0 iter = scanner.iterator @@ -65,7 +65,7 @@ EOF end count += 1 end - formatter.footer(now, count) + formatter.footer(count) end end diff --git a/hbase-shell/src/main/ruby/shell/commands/show_filters.rb b/hbase-shell/src/main/ruby/shell/commands/show_filters.rb index cdbd9ed9b59..5ff0be4828d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/show_filters.rb +++ b/hbase-shell/src/main/ruby/shell/commands/show_filters.rb @@ -36,7 +36,6 @@ EOF end def command( ) - now = Time.now parseFilter = ParseFilter.new supportedFilters = parseFilter.getSupportedFilters diff --git a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb index 15bf298e043..fd37d07291b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb @@ -29,9 +29,7 @@ EOF end def command(table, snapshot_name, *args) - format_simple_command do - admin.snapshot(table, snapshot_name, *args) - end + admin.snapshot(table, snapshot_name, *args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/split.rb b/hbase-shell/src/main/ruby/shell/commands/split.rb index 9dc424ff687..9e6ec6a55cd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/split.rb +++ b/hbase-shell/src/main/ruby/shell/commands/split.rb @@ -34,9 +34,7 @@ EOF end def command(table_or_region_name, split_point = nil) - format_simple_command do - admin.split(table_or_region_name, split_point) - end + admin.split(table_or_region_name, split_point) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb index 7da7564ab6f..5a138718c3c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb @@ -30,11 +30,9 @@ EOF end def command(switch_type) - format_simple_command do - formatter.row( - [admin.splitormerge_enabled(switch_type) ? 'true' : 'false'] - ) - end + formatter.row( + [admin.splitormerge_enabled(switch_type) ? 'true' : 'false'] + ) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb b/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb index f4c285800da..73dc82dbb02 100644 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb @@ -32,11 +32,9 @@ EOF end def command(switch_type, enabled) - format_simple_command do - formatter.row( - [admin.splitormerge_switch(switch_type, enabled) ? 'true' : 'false'] - ) - end + formatter.row( + [admin.splitormerge_switch(switch_type, enabled) ? 'true' : 'false'] + ) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/trace.rb b/hbase-shell/src/main/ruby/shell/commands/trace.rb index 5e0093092f8..d8389798309 100644 --- a/hbase-shell/src/main/ruby/shell/commands/trace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/trace.rb @@ -48,9 +48,7 @@ EOF end def command(startstop="status", spanname="HBaseShell") - format_and_return_simple_command do - trace(startstop, spanname) - end + trace(startstop, spanname) end def trace(startstop, spanname) diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate.rb b/hbase-shell/src/main/ruby/shell/commands/truncate.rb index b7812fbe3dd..3f888c6abe2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate.rb @@ -27,10 +27,8 @@ EOF end def command(table) - format_simple_command do - puts "Truncating '#{table}' table (it may take a while):" - admin.truncate(table) { |log| puts " - #{log}" } - end + puts "Truncating '#{table}' table (it may take a while):" + admin.truncate(table) { |log| puts " - #{log}" } end end diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb index 918b23289a9..fcce5e51038 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb @@ -27,10 +27,8 @@ EOF end def command(table) - format_simple_command do - puts "Truncating '#{table}' table (it may take a while):" - admin.truncate_preserve(table) { |log| puts " - #{log}" } - end + puts "Truncating '#{table}' table (it may take a while):" + admin.truncate_preserve(table) { |log| puts " - #{log}" } end end diff --git a/hbase-shell/src/main/ruby/shell/commands/unassign.rb b/hbase-shell/src/main/ruby/shell/commands/unassign.rb index 5eea71f6e08..b69971fbafc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/unassign.rb +++ b/hbase-shell/src/main/ruby/shell/commands/unassign.rb @@ -36,9 +36,7 @@ EOF end def command(region_name, force = 'false') - format_simple_command do - admin.unassign(region_name, force) - end + admin.unassign(region_name, force) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/update_all_config.rb b/hbase-shell/src/main/ruby/shell/commands/update_all_config.rb index 05295b7996a..cb6852f662f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/update_all_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/update_all_config.rb @@ -30,9 +30,7 @@ EOF end def command() - format_simple_command do - admin.update_all_config() - end + admin.update_all_config() end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/update_config.rb b/hbase-shell/src/main/ruby/shell/commands/update_config.rb index 9f65fddd25d..3617bb3e24c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/update_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/update_config.rb @@ -31,9 +31,7 @@ EOF end def command(serverName) - format_simple_command do - admin.update_config(serverName) - end + admin.update_config(serverName) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/update_peer_config.rb b/hbase-shell/src/main/ruby/shell/commands/update_peer_config.rb index bcecb91c517..e6f1c9e6f7c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/update_peer_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/update_peer_config.rb @@ -40,9 +40,7 @@ To update TABLE_CFs, see the append_peer_tableCFs and remove_peer_tableCFs comma end def command(id, args = {}) - format_simple_command do - replication_admin.update_peer_config(id, args) - end + replication_admin.update_peer_config(id, args) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/user_permission.rb b/hbase-shell/src/main/ruby/shell/commands/user_permission.rb index 71b98f370a8..4b5d3ffa378 100644 --- a/hbase-shell/src/main/ruby/shell/commands/user_permission.rb +++ b/hbase-shell/src/main/ruby/shell/commands/user_permission.rb @@ -40,16 +40,14 @@ EOF end def command(table_regex=nil) - #format_simple_command do #admin.user_permission(table_regex) - now = Time.now formatter.header(["User", "Namespace,Table,Family,Qualifier:Permission"]) count = security_admin.user_permission(table_regex) do |user, permission| formatter.row([ user, permission]) end - formatter.footer(now, count) + formatter.footer(count) end end end diff --git a/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb b/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb index 0fe1870af23..a94e9e1056e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb +++ b/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb @@ -30,11 +30,10 @@ EOF end def command(server_name) - format_simple_command do - admin.wal_roll(server_name) - end + admin.wal_roll(server_name) end end + #TODO remove old HLog version class HlogRoll < WalRoll end diff --git a/hbase-shell/src/main/ruby/shell/formatter.rb b/hbase-shell/src/main/ruby/shell/formatter.rb index 6e598fb9f82..2f800f6ebc6 100644 --- a/hbase-shell/src/main/ruby/shell/formatter.rb +++ b/hbase-shell/src/main/ruby/shell/formatter.rb @@ -64,7 +64,7 @@ module Shell # Print a string if args.is_a?(String) - output(args) + output_str(args) @out.puts return end @@ -162,7 +162,7 @@ module Shell return str end - def output(str) + def output_str(str) output(@max_width, str) end @@ -177,15 +177,12 @@ module Shell end end - def footer(start_time = nil, row_count = nil, is_stale = false) - return unless start_time + def footer(row_count = nil, is_stale = false) row_count ||= @row_count # Only output elapsed time and row count if startTime passed - @out.print("%d row(s) in %.4f seconds" % [row_count, Time.now - start_time]) + @out.puts("%d row(s)" % [row_count]) if is_stale == true @out.puts(" (possible stale results) ") - else - @out.puts("") end end end diff --git a/hbase-shell/src/test/ruby/shell/formatter_test.rb b/hbase-shell/src/test/ruby/shell/formatter_test.rb index 70104793192..540dd09db05 100644 --- a/hbase-shell/src/test/ruby/shell/formatter_test.rb +++ b/hbase-shell/src/test/ruby/shell/formatter_test.rb @@ -63,6 +63,6 @@ class ShellFormatterTest < Test::Unit::TestCase end define_test "Froematter#footer should work" do - formatter.footer(Time.now - 5) + formatter.footer() end end diff --git a/hbase-shell/src/test/ruby/shell/shell_test.rb b/hbase-shell/src/test/ruby/shell/shell_test.rb index 689a18bd55b..6bf619c04b2 100644 --- a/hbase-shell/src/test/ruby/shell/shell_test.rb +++ b/hbase-shell/src/test/ruby/shell/shell_test.rb @@ -26,12 +26,12 @@ class ShellTest < Test::Unit::TestCase @shell = Shell::Shell.new(@hbase) end - define_test "Shell::Shell#hbase_admin should return an admin instance" do - assert_kind_of(Hbase::Admin, @shell.hbase_admin) + define_test "Shell::Shell#admin should return an admin instance" do + assert_kind_of(Hbase::Admin, @shell.admin) end - define_test "Shell::Shell#hbase_admin should cache admin instances" do - assert_same(@shell.hbase_admin, @shell.hbase_admin) + define_test "Shell::Shell#admin should cache admin instances" do + assert_same(@shell.admin, @shell.admin) end #------------------------------------------------------------------------------- @@ -44,6 +44,10 @@ class ShellTest < Test::Unit::TestCase assert_not_same(@shell.hbase_table('hbase:meta'), @shell.hbase_table('hbase:meta')) end + define_test "Shell::Shell#hbase attribute is a HBase instance" do + assert_kind_of(Hbase::Hbase, @shell.hbase) + end + #------------------------------------------------------------------------------- define_test "Shell::Shell#export_commands should export command methods to specified object" do diff --git a/hbase-shell/src/test/ruby/test_helper.rb b/hbase-shell/src/test/ruby/test_helper.rb index 179ee5bed48..21b8c21de8f 100644 --- a/hbase-shell/src/test/ruby/test_helper.rb +++ b/hbase-shell/src/test/ruby/test_helper.rb @@ -55,7 +55,7 @@ module Hbase end def admin - @shell.hbase_admin + @shell.admin end def taskmonitor