Repository: hbase Updated Branches: refs/heads/master 90fee695b -> 2115d4b50
http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_regions.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb index f2d4b41..5feb926 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -21,8 +21,7 @@ module Shell module Commands class ListRegions < Command def help - - return<<EOF + return <<EOF List all regions for a particular table as an array and also filter them by server name (optional) as prefix and maximum locality (optional). By default, it will return all the regions for the table with any locality. The command displays server name, region name, start key, end key, size of the region in MB, number of requests @@ -39,37 +38,37 @@ module Shell hbase> list_regions 'table_name', '', ['SERVER_NAME', 'start_key'] EOF - return + nil end def command(table_name, options = nil, cols = nil) if options.nil? options = {} - elsif not options.is_a? Hash + elsif !options.is_a? Hash # When options isn't a hash, assume it's the server name # and create the hash internally - options = {SERVER_NAME => options} + options = { SERVER_NAME => options } end - size_hash = Hash.new + size_hash = {} if cols.nil? - size_hash = { "SERVER_NAME" => 12, "REGION_NAME" => 12, "START_KEY" => 10, "END_KEY" => 10, "SIZE" => 5, "REQ" => 5, "LOCALITY" => 10 } + size_hash = { 'SERVER_NAME' => 12, 'REGION_NAME' => 12, 'START_KEY' => 10, 'END_KEY' => 10, 'SIZE' => 5, 'REQ' => 5, 'LOCALITY' => 10 } elsif cols.is_a?(Array) cols.each do |col| - if col.upcase.eql?("SERVER_NAME") - size_hash.store("SERVER_NAME", 12) - elsif col.upcase.eql?("REGION_NAME") - size_hash.store("REGION_NAME", 12) - elsif col.upcase.eql?("START_KEY") - size_hash.store("START_KEY", 10) - elsif col.upcase.eql?("END_KEY") - size_hash.store("END_KEY", 10) - elsif col.upcase.eql?("SIZE") - size_hash.store("SIZE", 5) - elsif col.upcase.eql?("REQ") - size_hash.store("REQ", 5) - elsif col.upcase.eql?("LOCALITY") - size_hash.store("LOCALITY", 10) + if col.casecmp('SERVER_NAME').zero? + size_hash.store('SERVER_NAME', 12) + elsif col.casecmp('REGION_NAME').zero? + size_hash.store('REGION_NAME', 12) + elsif col.casecmp('START_KEY').zero? + size_hash.store('START_KEY', 10) + elsif col.casecmp('END_KEY').zero? + size_hash.store('END_KEY', 10) + elsif col.casecmp('SIZE').zero? + size_hash.store('SIZE', 5) + elsif col.casecmp('REQ').zero? + size_hash.store('REQ', 5) + elsif col.casecmp('LOCALITY').zero? + size_hash.store('LOCALITY', 10) else raise "#{col} is not a valid column. Possible values are SERVER_NAME, REGION_NAME, START_KEY, END_KEY, SIZE, REQ, LOCALITY." end @@ -78,12 +77,12 @@ EOF raise "#{cols} must be an array of strings. Possible values are SERVER_NAME, REGION_NAME, START_KEY, END_KEY, SIZE, REQ, LOCALITY." end - admin_instance = admin.instance_variable_get("@admin") - conn_instance = admin_instance.getConnection() - cluster_status = admin_instance.getClusterStatus() + admin_instance = admin.instance_variable_get('@admin') + conn_instance = admin_instance.getConnection + cluster_status = admin_instance.getClusterStatus hregion_locator_instance = conn_instance.getRegionLocator(TableName.valueOf(table_name)) - hregion_locator_list = hregion_locator_instance.getAllRegionLocations().to_a - results = Array.new + hregion_locator_list = hregion_locator_instance.getAllRegionLocations.to_a + results = [] desired_server_name = options[SERVER_NAME] begin @@ -92,7 +91,7 @@ EOF # A locality threshold of "1.0" would be all regions (cannot have greater than 1 locality) # Regions which have a `dataLocality` less-than-or-equal to this value are accepted locality_threshold = 1.0 - if options.has_key? LOCALITY_THRESHOLD + if options.key? LOCALITY_THRESHOLD value = options[LOCALITY_THRESHOLD] # Value validation. Must be a Float, and must be between [0, 1.0] raise "#{LOCALITY_THRESHOLD} must be a float value" unless value.is_a? Float @@ -101,88 +100,86 @@ EOF end regions.each do |hregion| - hregion_info = hregion.getRegionInfo() - server_name = hregion.getServerName() - region_load_map = cluster_status.getLoad(server_name).getRegionsLoad() - region_load = region_load_map.get(hregion_info.getRegionName()) + hregion_info = hregion.getRegionInfo + server_name = hregion.getServerName + region_load_map = cluster_status.getLoad(server_name).getRegionsLoad + region_load = region_load_map.get(hregion_info.getRegionName) # Ignore regions which exceed our locality threshold - if accept_region_for_locality? region_load.getDataLocality(), locality_threshold - result_hash = Hash.new - - if size_hash.key?("SERVER_NAME") - result_hash.store("SERVER_NAME", server_name.toString().strip) - size_hash["SERVER_NAME"] = [size_hash["SERVER_NAME"], server_name.toString().strip.length].max - end - - if size_hash.key?("REGION_NAME") - result_hash.store("REGION_NAME", hregion_info.getRegionNameAsString().strip) - size_hash["REGION_NAME"] = [size_hash["REGION_NAME"], hregion_info.getRegionNameAsString().length].max - end - - if size_hash.key?("START_KEY") - startKey = Bytes.toStringBinary(hregion_info.getStartKey()).strip - result_hash.store("START_KEY", startKey) - size_hash["START_KEY"] = [size_hash["START_KEY"], startKey.length].max - end - - if size_hash.key?("END_KEY") - endKey = Bytes.toStringBinary(hregion_info.getEndKey()).strip - result_hash.store("END_KEY", endKey) - size_hash["END_KEY"] = [size_hash["END_KEY"], endKey.length].max - end - - if size_hash.key?("SIZE") - region_store_file_size = region_load.getStorefileSizeMB().to_s.strip - result_hash.store("SIZE", region_store_file_size) - size_hash["SIZE"] = [size_hash["SIZE"], region_store_file_size.length].max - end - - if size_hash.key?("REQ") - region_requests = region_load.getRequestsCount().to_s.strip - result_hash.store("REQ", region_requests) - size_hash["REQ"] = [size_hash["REQ"], region_requests.length].max - end - - if size_hash.key?("LOCALITY") - locality = region_load.getDataLocality().to_s.strip - result_hash.store("LOCALITY", locality) - size_hash["LOCALITY"] = [size_hash["LOCALITY"], locality.length].max - end - - results << result_hash + next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold + result_hash = {} + + if size_hash.key?('SERVER_NAME') + result_hash.store('SERVER_NAME', server_name.toString.strip) + size_hash['SERVER_NAME'] = [size_hash['SERVER_NAME'], server_name.toString.strip.length].max + end + + if size_hash.key?('REGION_NAME') + result_hash.store('REGION_NAME', hregion_info.getRegionNameAsString.strip) + size_hash['REGION_NAME'] = [size_hash['REGION_NAME'], hregion_info.getRegionNameAsString.length].max + end + + if size_hash.key?('START_KEY') + startKey = Bytes.toStringBinary(hregion_info.getStartKey).strip + result_hash.store('START_KEY', startKey) + size_hash['START_KEY'] = [size_hash['START_KEY'], startKey.length].max + end + + if size_hash.key?('END_KEY') + endKey = Bytes.toStringBinary(hregion_info.getEndKey).strip + result_hash.store('END_KEY', endKey) + size_hash['END_KEY'] = [size_hash['END_KEY'], endKey.length].max end + + if size_hash.key?('SIZE') + region_store_file_size = region_load.getStorefileSizeMB.to_s.strip + result_hash.store('SIZE', region_store_file_size) + size_hash['SIZE'] = [size_hash['SIZE'], region_store_file_size.length].max + end + + if size_hash.key?('REQ') + region_requests = region_load.getRequestsCount.to_s.strip + result_hash.store('REQ', region_requests) + size_hash['REQ'] = [size_hash['REQ'], region_requests.length].max + end + + if size_hash.key?('LOCALITY') + locality = region_load.getDataLocality.to_s.strip + result_hash.store('LOCALITY', locality) + size_hash['LOCALITY'] = [size_hash['LOCALITY'], locality.length].max + end + + results << result_hash end ensure - hregion_locator_instance.close() + hregion_locator_instance.close end @end_time = Time.now - size_hash.each do | param, length | + size_hash.each do |param, length| printf(" %#{length}s |", param) end printf("\n") - size_hash.each do | param, length | - str = "-" * length + size_hash.each do |_param, length| + str = '-' * length printf(" %#{length}s |", str) end printf("\n") - results.each do | result | - size_hash.each do | param, length | + results.each do |result| + size_hash.each do |param, length| printf(" %#{length}s |", result[param]) end printf("\n") end printf(" %d rows\n", results.size) - end def valid_locality_threshold?(value) - value >= 0 and value <= 1.0 + value >= 0 && value <= 1.0 end def get_regions_for_table_and_server(table_name, conn, server_name) @@ -191,16 +188,16 @@ EOF def get_regions_for_server(regions_for_table, server_name) regions_for_table.select do |hregion| - accept_server_name? server_name, hregion.getServerName().toString() + accept_server_name? server_name, hregion.getServerName.toString end end def get_regions_for_table(table_name, conn) - conn.getRegionLocator(TableName.valueOf(table_name)).getAllRegionLocations().to_a + conn.getRegionLocator(TableName.valueOf(table_name)).getAllRegionLocations.to_a end def accept_server_name?(desired_server_name, actual_server_name) - desired_server_name.nil? or actual_server_name.start_with? desired_server_name + desired_server_name.nil? || actual_server_name.start_with?(desired_server_name) end def accept_region_for_locality?(actual_locality, locality_threshold) http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_replicated_tables.rb ---------------------------------------------------------------------- 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 4200cae..1fc6e76 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 @@ -20,9 +20,9 @@ module Shell module Commands - class ListReplicatedTables< Command + class ListReplicatedTables < Command def help - return <<-EOF + <<-EOF List all the tables and column families replicated from this cluster hbase> list_replicated_tables @@ -30,25 +30,25 @@ List all the tables and column families replicated from this cluster EOF end - def command(regex = ".*") - formatter.header([ "TABLE:COLUMNFAMILY", "ReplicationType" ], [ 32 ]) + def command(regex = '.*') + formatter.header(['TABLE:COLUMNFAMILY', 'ReplicationType'], [32]) list = replication_admin.list_replicated_tables(regex) list.each do |e| - map = e.getColumnFamilyMap() + map = e.getColumnFamilyMap map.each do |cf| if cf[1] == org.apache.hadoop.hbase.HConstants::REPLICATION_SCOPE_LOCAL - replicateType = "LOCAL" + replicateType = 'LOCAL' elsif cf[1] == org.apache.hadoop.hbase.HConstants::REPLICATION_SCOPE_GLOBAL - replicateType = "GLOBAL" + replicateType = 'GLOBAL' elsif cf[1] == org.apache.hadoop.hbase.HConstants::REPLICATION_SCOPE_SERIAL - replicateType = "SERIAL" + replicateType = 'SERIAL' else - replicateType = "UNKNOWN" + replicateType = 'UNKNOWN' end - formatter.row([e.getTable().getNameAsString() + ":" + cf[0], replicateType], true, [32]) + formatter.row([e.getTable.getNameAsString + ':' + cf[0], replicateType], true, [32]) end end - formatter.footer() + formatter.footer end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb b/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb index 7a07b53..ef22aa9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb @@ -19,7 +19,7 @@ module Shell module Commands class ListRsgroups < Command def help - return <<-EOF + <<-EOF List all RegionServer groups. Optional regular expression parameter can be used to filter the output. http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_security_capabilities.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/list_security_capabilities.rb b/hbase-shell/src/main/ruby/shell/commands/list_security_capabilities.rb index 922ad11..873a1f5 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_security_capabilities.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_security_capabilities.rb @@ -19,7 +19,7 @@ module Shell module Commands class ListSecurityCapabilities < Command def help - return <<-EOF + <<-EOF List supported security capabilities Example: @@ -27,20 +27,18 @@ Example: EOF end - def command() - begin - list = admin.get_security_capabilities - list.each do |s| - puts s.getName - end - return list.map { |s| s.getName() } - rescue Exception => e - if e.to_s.include? "UnsupportedOperationException" - puts "ERROR: Master does not support getSecurityCapabilities" - return [] - end - raise e + def command + list = admin.get_security_capabilities + list.each do |s| + puts s.getName end + return list.map(&:getName) + rescue Exception => e + if e.to_s.include? 'UnsupportedOperationException' + puts 'ERROR: Master does not support getSecurityCapabilities' + return [] + end + raise e end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_snapshot_sizes.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/list_snapshot_sizes.rb b/hbase-shell/src/main/ruby/shell/commands/list_snapshot_sizes.rb index 4ab8db9..c00007c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_snapshot_sizes.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_snapshot_sizes.rb @@ -21,17 +21,17 @@ module Shell module Commands class ListSnapshotSizes < Command def help - return <<-EOF + <<-EOF Lists the size of every HBase snapshot given the space quota size computation algorithms. An HBase snapshot only "owns" the size of a file when the table from which the snapshot was created no longer refers to that file. EOF end - def command(args = {}) - formatter.header(["SNAPSHOT", "SIZE"]) + def command(_args = {}) + formatter.header(%w[SNAPSHOT SIZE]) count = 0 - quotas_admin.list_snapshot_sizes().each do |snapshot,size| + quotas_admin.list_snapshot_sizes.each do |snapshot, size| formatter.row([snapshot.to_s, size.to_s]) count += 1 end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb ---------------------------------------------------------------------- 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 bc91737..1b3b8f2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb @@ -22,7 +22,7 @@ module Shell module Commands class ListSnapshots < Command def help - return <<-EOF + <<-EOF List all snapshots taken (by printing the names and relative information). Optional regular expression parameter could be used to filter the output by snapshot name. @@ -33,17 +33,17 @@ Examples: EOF end - def command(regex = ".*") - formatter.header([ "SNAPSHOT", "TABLE + CREATION TIME"]) + def command(regex = '.*') + formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME']) list = admin.list_snapshot(regex) list.each do |snapshot| - creation_time = Time.at(snapshot.getCreationTime() / 1000).to_s - formatter.row([ snapshot.getName, snapshot.getTable + " (" + creation_time + ")" ]) + creation_time = Time.at(snapshot.getCreationTime / 1000).to_s + formatter.row([snapshot.getName, snapshot.getTable + ' (' + creation_time + ')']) end formatter.footer(list.size) - return list.map { |s| s.getName() } + list.map(&:getName) end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/list_table_snapshots.rb ---------------------------------------------------------------------- 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 1efcc17..558fda8 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 @@ -22,7 +22,7 @@ module Shell module Commands class ListTableSnapshots < Command def help - return <<-EOF + <<-EOF List all completed snapshots matching the table name regular expression and the snapshot name regular expression (by printing the names and relative information). Optional snapshot name regular expression parameter could be used to filter the output @@ -38,17 +38,17 @@ Examples: EOF end - def command(tableNameRegex, snapshotNameRegex = ".*") - formatter.header([ "SNAPSHOT", "TABLE + CREATION TIME"]) + def command(tableNameRegex, snapshotNameRegex = '.*') + formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME']) list = admin.list_table_snapshots(tableNameRegex, snapshotNameRegex) list.each do |snapshot| - creation_time = Time.at(snapshot.getCreationTime() / 1000).to_s - formatter.row([ snapshot.getName, snapshot.getTable + " (" + creation_time + ")" ]) + creation_time = Time.at(snapshot.getCreationTime / 1000).to_s + formatter.row([snapshot.getName, snapshot.getTable + ' (' + creation_time + ')']) end formatter.footer(list.size) - return list.map { |s| s.getName() } + list.map(&:getName) end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/locate_region.rb ---------------------------------------------------------------------- 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 e2487c1..9afbbec 100644 --- a/hbase-shell/src/main/ruby/shell/commands/locate_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/locate_region.rb @@ -22,7 +22,7 @@ module Shell module Commands class LocateRegion < Command def help - return <<-EOF + <<-EOF Locate the region given a table name and a row-key hbase> locate_region 'tableName', 'key0' @@ -31,10 +31,10 @@ EOF def command(table, row_key) region_location = admin.locate_region(table, row_key) - hri = region_location.getRegionInfo() + hri = region_location.getRegionInfo - formatter.header([ "HOST", "REGION" ]) - formatter.row([region_location.getHostnamePort(), hri.toString()]) + formatter.header(%w[HOST REGION]) + formatter.row([region_location.getHostnamePort, hri.toString]) formatter.footer(1) region_location end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/major_compact.rb ---------------------------------------------------------------------- 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 9b0573c..9ff26c1 100644 --- a/hbase-shell/src/main/ruby/shell/commands/major_compact.rb +++ b/hbase-shell/src/main/ruby/shell/commands/major_compact.rb @@ -21,7 +21,7 @@ module Shell module Commands class MajorCompact < Command def help - return <<-EOF + <<-EOF Run major compaction on passed table or pass a region row to major compact an individual region. To compact a single column family within a region specify the region name @@ -43,7 +43,7 @@ module Shell EOF end - def command(table_or_region_name, family = nil, type = "NORMAL") + def command(table_or_region_name, family = nil, type = 'NORMAL') admin.major_compact(table_or_region_name, family, type) end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/merge_region.rb ---------------------------------------------------------------------- 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 63f7159..9c66770 100644 --- a/hbase-shell/src/main/ruby/shell/commands/merge_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/merge_region.rb @@ -21,7 +21,7 @@ module Shell module Commands class MergeRegion < Command def help - return <<-EOF + <<-EOF Merge two regions. Passing 'true' as the optional third parameter will force a merge ('force' merges regardless else merge will fail unless passed adjacent regions. 'force' is for expert use only). http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/move.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/move.rb b/hbase-shell/src/main/ruby/shell/commands/move.rb index 24816f3..3bb2ebc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move.rb @@ -21,7 +21,7 @@ module Shell module Commands class Move < Command def help - return <<-EOF + <<-EOF Move a region. Optionally specify target regionserver else we choose one at random. NOTE: You pass the encoded region name, not the region name so this command is a little different to the others. The encoded region name http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/move_servers_rsgroup.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/move_servers_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_servers_rsgroup.rb index 61fcd02..e2d8923 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_servers_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_servers_rsgroup.rb @@ -19,7 +19,7 @@ module Shell module Commands class MoveServersRsgroup < Command def help - return <<-EOF + <<-EOF Reassign RegionServers from one group to another. Example: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/move_servers_tables_rsgroup.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/move_servers_tables_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_servers_tables_rsgroup.rb index 5337141..1789a35 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_servers_tables_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_servers_tables_rsgroup.rb @@ -19,7 +19,7 @@ module Shell module Commands class MoveServersTablesRsgroup < Command def help - return <<-EOF + <<-EOF Reassign RegionServers and Tables from one group to another. Example: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/move_tables_rsgroup.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/move_tables_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_tables_rsgroup.rb index c6853ea..ff644d1 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_tables_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_tables_rsgroup.rb @@ -19,7 +19,7 @@ module Shell module Commands class MoveTablesRsgroup < Command def help - return <<-EOF + <<-EOF Reassign tables from one RegionServer group to another. Example: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/normalize.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/normalize.rb b/hbase-shell/src/main/ruby/shell/commands/normalize.rb index 0a61227..0d97ec8 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalize.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalize.rb @@ -21,7 +21,7 @@ module Shell module Commands class Normalize < Command def help - return <<-EOF + <<-EOF Trigger region normalizer for all tables which have NORMALIZATION_ENABLED flag set. Returns true if normalizer ran successfully, false otherwise. Note that this command has no effect if region normalizer is disabled (make sure it's turned on using 'normalizer_switch' command). @@ -32,10 +32,9 @@ Trigger region normalizer for all tables which have NORMALIZATION_ENABLED flag s EOF end - def command() - formatter.row([admin.normalize()? "true": "false"]) + def command + formatter.row([admin.normalize ? 'true' : 'false']) end end end end - http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb ---------------------------------------------------------------------- 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 d39b777..aed476e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb @@ -21,7 +21,7 @@ module Shell module Commands class NormalizerEnabled < Command def help - return <<-EOF + <<-EOF Query the state of region normalizer. Examples: @@ -29,7 +29,7 @@ Examples: EOF end - def command() + def command formatter.row([admin.normalizer_enabled?.to_s]) end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb ---------------------------------------------------------------------- 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 7a12b71..03d8d5a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb @@ -21,7 +21,7 @@ module Shell module Commands class NormalizerSwitch < Command def help - return <<-EOF + <<-EOF Enable/Disable region normalizer. Returns previous normalizer state. When normalizer is enabled, it handles all tables with 'NORMALIZATION_ENABLED' => true. Examples: @@ -32,7 +32,7 @@ EOF end def command(enableDisable) - formatter.row([admin.normalizer_switch(enableDisable)? "true" : "false"]) + formatter.row([admin.normalizer_switch(enableDisable) ? 'true' : 'false']) end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/processlist.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/processlist.rb b/hbase-shell/src/main/ruby/shell/commands/processlist.rb index 5715f4b..1a69ba7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/processlist.rb +++ b/hbase-shell/src/main/ruby/shell/commands/processlist.rb @@ -22,7 +22,7 @@ module Shell module Commands class Processlist < Command def help - return <<-EOF + <<-EOF Show regionserver task list. hbase> processlist @@ -32,34 +32,31 @@ Show regionserver task list. hbase> processlist 'rpc' hbase> processlist 'operation' hbase> processlist 'all','host187.example.com' - hbase> processlist 'all','host187.example.com,16020' + hbase> processlist 'all','host187.example.com,16020' hbase> processlist 'all','host187.example.com,16020,1289493121758' EOF end def command(*args) - - if ['all','general','handler','rpc','operation'].include? args[0] + if %w[all general handler rpc operation].include? args[0] # if the first argument is a valid filter specifier, use it as such filter = args[0] - hosts = args[1,args.length] + hosts = args[1, args.length] else # otherwise, treat all arguments as host addresses by default filter = 'general' hosts = args end - + hosts = admin.getServerNames(hosts) - if hosts == nil - puts "No regionservers available." + if hosts.nil? + puts 'No regionservers available.' else - taskmonitor.tasks(filter,hosts) + taskmonitor.tasks(filter, hosts) end - end - end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/put.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/put.rb b/hbase-shell/src/main/ruby/shell/commands/put.rb index 39f9fea..118902a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/put.rb +++ b/hbase-shell/src/main/ruby/shell/commands/put.rb @@ -21,7 +21,7 @@ module Shell module Commands class Put < Command def help - return <<-EOF + <<-EOF Put a cell 'value' at specified table/row/column and optionally timestamp coordinates. To put a cell value into table 'ns1:t1' or 't1' at row 'r1' under column 'c1' marked with the time 'ts1', do: @@ -40,7 +40,7 @@ t to table 't1', the corresponding command would be: EOF end - def command(table, row, column, value, timestamp=nil, args = {}) + def command(table, row, column, value, timestamp = nil, args = {}) put table(table), row, column, value, timestamp, args end @@ -52,5 +52,5 @@ EOF end end -#Add the method table.put that calls Put.put -::Hbase::Table.add_shell_command("put") +# Add the method table.put that calls Put.put +::Hbase::Table.add_shell_command('put') http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb ---------------------------------------------------------------------- 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 bc9d6ab..26da408 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb @@ -19,9 +19,9 @@ module Shell module Commands - class RemovePeer< Command + class RemovePeer < Command def help - return <<-EOF + <<-EOF Stops the specified replication stream and deletes all the meta information kept about it. Examples: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb index 0b668e5..79b56d9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer_namespaces.rb @@ -20,9 +20,9 @@ module Shell module Commands - class RemovePeerNamespaces< Command + class RemovePeerNamespaces < Command def help - return <<-EOF + <<-EOF Remove some namespaces from the namespaces config for the specified peer. Examples: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/remove_peer_tableCFs.rb ---------------------------------------------------------------------- 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 adfb85d..d50b405 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 @@ -21,7 +21,7 @@ module Shell module Commands class RemovePeerTableCFs < Command def help - return <<-EOF + <<-EOF Remove a table / table-cf from the table-cfs config for the specified peer Examples: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb index f200ff8..9d39aac 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb @@ -19,7 +19,7 @@ module Shell module Commands class RemoveRsgroup < Command def help - return <<-EOF + <<-EOF Remove a RegionServer group. hbase> remove_rsgroup 'my_group' http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb ---------------------------------------------------------------------- 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 85a30a1..be6ee3c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb @@ -20,7 +20,7 @@ module Shell module Commands class RestoreSnapshot < Command def help - return <<-EOF + <<-EOF Restore a specified snapshot. The restore will replace the content of the original table, bringing back the content to the snapshot state. @@ -36,7 +36,7 @@ EOF end def command(snapshot_name, args = {}) - raise(ArgumentError, "Arguments should be a Hash") unless args.kind_of?(Hash) + raise(ArgumentError, 'Arguments should be a Hash') unless args.is_a?(Hash) restore_acl = args.delete(RESTORE_ACL) || false admin.restore_snapshot(snapshot_name, restore_acl) end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/revoke.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/revoke.rb b/hbase-shell/src/main/ruby/shell/commands/revoke.rb index bcf60e9..3f4963d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/revoke.rb +++ b/hbase-shell/src/main/ruby/shell/commands/revoke.rb @@ -20,12 +20,12 @@ module Shell module Commands class Revoke < Command def help - return <<-EOF + <<-EOF Revoke a user's access rights. Syntax : revoke <user> [, <@namespace> [, <table> [, <column family> [, <column qualifier>]]]] -Note: Groups and users access are revoked in the same way, but groups are prefixed with an '@' - character. In the same way, tables and namespaces are specified, but namespaces are +Note: Groups and users access are revoked in the same way, but groups are prefixed with an '@' + character. In the same way, tables and namespaces are specified, but namespaces are prefixed with an '@' character. For example: @@ -38,7 +38,7 @@ For example: EOF end - def command(user, table_name=nil, family=nil, qualifier=nil) + def command(user, table_name = nil, family = nil, qualifier = nil) security_admin.revoke(user, table_name, family, qualifier) end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/scan.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/scan.rb b/hbase-shell/src/main/ruby/shell/commands/scan.rb index dda9899..96382f3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/scan.rb +++ b/hbase-shell/src/main/ruby/shell/commands/scan.rb @@ -21,7 +21,7 @@ module Shell module Commands class Scan < Command def help - return <<-EOF + <<-EOF Scan a table; pass table name and optionally a dictionary of scanner specifications. Scanner specifications may include one or more of: TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, ROWPREFIXFILTER, TIMESTAMP, @@ -38,7 +38,7 @@ Filter Language document attached to the HBASE-4176 JIRA If you wish to see metrics regarding the execution of the scan, the ALL_METRICS boolean should be set to true. Alternatively, if you would -prefer to see only a subset of the metrics, the METRICS array can be +prefer to see only a subset of the metrics, the METRICS array can be defined to include the names of only the metrics you care about. Some examples: @@ -56,7 +56,7 @@ Some examples: hbase> scan 't1', {FILTER => org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)} hbase> scan 't1', {CONSISTENCY => 'TIMELINE'} -For setting the Operation Attributes +For setting the Operation Attributes hbase> scan 't1', { COLUMNS => ['c1', 'c2'], ATTRIBUTES => {'mykey' => 'myvalue'}} hbase> scan 't1', { COLUMNS => ['c1', 'c2'], AUTHORIZATIONS => ['PRIVATE','SECRET']} For experts, there is an additional option -- CACHE_BLOCKS -- which @@ -74,14 +74,14 @@ Disabled by default. Example: Besides the default 'toStringBinary' format, 'scan' supports custom formatting by column. A user can define a FORMATTER by adding it to the column name in -the scan specification. The FORMATTER can be stipulated: +the scan specification. The FORMATTER can be stipulated: 1. either as a org.apache.hadoop.hbase.util.Bytes method name (e.g, toInt, toString) 2. or as a custom class followed by method name: e.g. 'c(MyFormatterClass).format'. -Example formatting cf:qualifier1 and cf:qualifier2 both as Integers: +Example formatting cf:qualifier1 and cf:qualifier2 both as Integers: hbase> scan 't1', {COLUMNS => ['cf:qualifier1:toInt', - 'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] } + 'cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt'] } Note that you can specify a FORMATTER by column only (cf:qualifier). You can set a formatter for all columns (including, all key parts) using the "FORMATTER" @@ -107,27 +107,27 @@ EOF scan(table(table), args) end - #internal command that actually does the scanning + # internal command that actually does the scanning def scan(table, args = {}) - formatter.header(["ROW", "COLUMN+CELL"]) + formatter.header(['ROW', 'COLUMN+CELL']) scan = table._hash_to_scan(args) - #actually do the scanning + # actually do the scanning @start_time = Time.now count, is_stale = table._scan_internal(args, scan) do |row, cells| - formatter.row([ row, cells ]) + formatter.row([row, cells]) end @end_time = Time.now 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"]) + if !scan.nil? && scan.isScanMetricsEnabled + formatter.scan_metrics(scan.getScanMetrics, args['METRICS']) end end end end end -#Add the method table.scan that calls Scan.scan -::Hbase::Table.add_shell_command("scan") +# Add the method table.scan that calls Scan.scan +::Hbase::Table.add_shell_command('scan') http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_auths.rb ---------------------------------------------------------------------- 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 5663ec3..ddd04aa 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_auths.rb @@ -19,7 +19,7 @@ module Shell module Commands class SetAuths < Command def help - return <<-EOF + <<-EOF Add a set of visibility labels for a user or group Syntax : set_auths 'user',[label1, label2] http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_peer_bandwidth.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_bandwidth.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_bandwidth.rb index d9495af..e932b93 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_bandwidth.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_bandwidth.rb @@ -20,9 +20,9 @@ module Shell module Commands - class SetPeerBandwidth< Command + class SetPeerBandwidth < Command def help - return <<-EOF + <<-EOF Set the replication source per node bandwidth for the specified peer. Examples: http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb index 75b3d11..6d14c1c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_namespaces.rb @@ -20,9 +20,9 @@ module Shell module Commands - class SetPeerNamespaces< Command + class SetPeerNamespaces < Command def help - return <<-EOF + <<-EOF Set the replicable namespaces config for the specified peer. Set a namespace in the peer config means that all tables in this http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_peer_tableCFs.rb ---------------------------------------------------------------------- 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 4d3c3ec..6da2f11 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 @@ -20,9 +20,9 @@ module Shell module Commands - class SetPeerTableCFs< Command + class SetPeerTableCFs < Command def help - return <<-EOF + <<-EOF Set the replicable table-cf config for the specified peer. Can't set a table to table-cfs config if it's namespace already was in http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_quota.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/set_quota.rb b/hbase-shell/src/main/ruby/shell/commands/set_quota.rb index 06ed0ba..ed593b6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_quota.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_quota.rb @@ -21,7 +21,7 @@ module Shell module Commands class SetQuota < Command def help - return <<-EOF + <<-EOF Set a quota for a user, table, or namespace. Syntax : set_quota TYPE => <type>, <args> @@ -87,33 +87,33 @@ EOF end def command(args = {}) - if args.has_key?(TYPE) + if args.key?(TYPE) qtype = args.delete(TYPE) case qtype - when THROTTLE - if args[LIMIT].eql? NONE - args.delete(LIMIT) - quotas_admin.unthrottle(args) - else - quotas_admin.throttle(args) - end - when SPACE - if args[LIMIT].eql? NONE - args.delete(LIMIT) - # Table/Namespace argument is verified in remove_space_limit - quotas_admin.remove_space_limit(args) - else - raise(ArgumentError, 'Expected a LIMIT to be provided') unless args.key?(LIMIT) - raise(ArgumentError, 'Expected a POLICY to be provided') unless args.key?(POLICY) - quotas_admin.limit_space(args) - end + when THROTTLE + if args[LIMIT].eql? NONE + args.delete(LIMIT) + quotas_admin.unthrottle(args) else - raise "Invalid TYPE argument. got " + qtype + quotas_admin.throttle(args) + end + when SPACE + if args[LIMIT].eql? NONE + args.delete(LIMIT) + # Table/Namespace argument is verified in remove_space_limit + quotas_admin.remove_space_limit(args) + else + raise(ArgumentError, 'Expected a LIMIT to be provided') unless args.key?(LIMIT) + raise(ArgumentError, 'Expected a POLICY to be provided') unless args.key?(POLICY) + quotas_admin.limit_space(args) + end + else + raise 'Invalid TYPE argument. got ' + qtype end - elsif args.has_key?(GLOBAL_BYPASS) + elsif args.key?(GLOBAL_BYPASS) quotas_admin.set_global_bypass(args.delete(GLOBAL_BYPASS), args) else - raise "Expected TYPE argument" + raise 'Expected TYPE argument' end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb ---------------------------------------------------------------------- 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 058ccf2..5c57d9c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb @@ -19,7 +19,7 @@ module Shell module Commands class SetVisibility < Command def help - return <<-EOF + <<-EOF Set the visibility expression on one or more existing cells. Pass table name, visibility expression, and a dictionary containing @@ -67,7 +67,6 @@ EOF end formatter.footer(count) end - end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/show_filters.rb ---------------------------------------------------------------------- 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 5ff0be4..0017ed0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/show_filters.rb +++ b/hbase-shell/src/main/ruby/shell/commands/show_filters.rb @@ -23,7 +23,7 @@ module Shell module Commands class ShowFilters < Command def help - return <<-EOF + <<-EOF Show all the filters in hbase. Example: hbase> show_filters @@ -35,7 +35,7 @@ Show all the filters in hbase. Example: EOF end - def command( ) + def command parseFilter = ParseFilter.new supportedFilters = parseFilter.getSupportedFilters http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb index b6b6956..0f3e78d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/show_peer_tableCFs.rb @@ -20,9 +20,9 @@ module Shell module Commands - class ShowPeerTableCFs< Command + class ShowPeerTableCFs < Command def help - return <<-EOF + <<-EOF Show replicable table-cf config for the specified peer. hbase> show_peer_tableCFs http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/snapshot.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb index fd37d07..c591e12 100644 --- a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb @@ -20,7 +20,7 @@ module Shell module Commands class Snapshot < Command def help - return <<-EOF + <<-EOF Take a snapshot of specified table. Examples: hbase> snapshot 'sourceTable', 'snapshotName' http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/split.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/split.rb b/hbase-shell/src/main/ruby/shell/commands/split.rb index 9e6ec6a..c7a1e29 100644 --- a/hbase-shell/src/main/ruby/shell/commands/split.rb +++ b/hbase-shell/src/main/ruby/shell/commands/split.rb @@ -21,9 +21,9 @@ module Shell module Commands class Split < Command def help - return <<-EOF -Split entire table or pass a region to split individual region. With the -second parameter, you can specify an explicit split key for the region. + <<-EOF +Split entire table or pass a region to split individual region. With the +second parameter, you can specify an explicit split key for the region. Examples: split 'tableName' split 'namespace:tableName' http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/status.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/status.rb b/hbase-shell/src/main/ruby/shell/commands/status.rb index b22b272..af71f6c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/status.rb +++ b/hbase-shell/src/main/ruby/shell/commands/status.rb @@ -21,7 +21,7 @@ module Shell module Commands class Status < Command def help - return <<-EOF + <<-EOF Show cluster status. Can be 'summary', 'simple', 'detailed', or 'replication'. The default is 'summary'. Examples: @@ -35,7 +35,7 @@ default is 'summary'. Examples: EOF end - def command(format = 'summary',type = 'both') + def command(format = 'summary', type = 'both') admin.status(format, type) end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/table_help.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/table_help.rb b/hbase-shell/src/main/ruby/shell/commands/table_help.rb index e5a1858..0ffed75 100644 --- a/hbase-shell/src/main/ruby/shell/commands/table_help.rb +++ b/hbase-shell/src/main/ruby/shell/commands/table_help.rb @@ -20,10 +20,10 @@ module Shell module Commands class TableHelp < Command def help - return Hbase::Table.help + Hbase::Table.help end - #just print the help + # just print the help def command # call the shell to get the nice formatting there @shell.help_command 'table_help' http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/trace.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/trace.rb b/hbase-shell/src/main/ruby/shell/commands/trace.rb index d838979..5ecd28c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/trace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/trace.rb @@ -24,7 +24,7 @@ module Shell module Commands class Trace < Command def help - return <<-EOF + <<-EOF Start or Stop tracing using HTrace. Always returns true if tracing is running, otherwise false. If the first argument is 'start', new span is started. @@ -47,28 +47,25 @@ Examples: EOF end - def command(startstop="status", spanname="HBaseShell") + def command(startstop = 'status', spanname = 'HBaseShell') trace(startstop, spanname) end def trace(startstop, spanname) @@receiver ||= SpanReceiverHost.getInstance(@shell.hbase.configuration) - if startstop == "start" - if not tracing? + if startstop == 'start' + unless tracing? @@tracescope = HTrace.startSpan(spanname, Sampler.ALWAYS) end - elsif startstop == "stop" - if tracing? - @@tracescope.close() - end + elsif startstop == 'stop' + @@tracescope.close if tracing? end tracing? end - def tracing?() - HTrace.isTracing() + def tracing? + HTrace.isTracing end - end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/truncate.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate.rb b/hbase-shell/src/main/ruby/shell/commands/truncate.rb index aff51ac..8c9f30e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate.rb @@ -21,7 +21,7 @@ module Shell module Commands class Truncate < Command def help - return <<-EOF + <<-EOF Disables, drops and recreates the specified table. EOF end @@ -29,7 +29,6 @@ EOF def command(table) admin.truncate(table) end - end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb ---------------------------------------------------------------------- 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 8bb3131..59be7d6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb @@ -21,7 +21,7 @@ module Shell module Commands class TruncatePreserve < Command def help - return <<-EOF + <<-EOF Disables, drops and recreates the specified table while still maintaing the previous region boundaries. EOF end @@ -29,7 +29,6 @@ EOF def command(table) admin.truncate_preserve(table) end - end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/unassign.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/unassign.rb b/hbase-shell/src/main/ruby/shell/commands/unassign.rb index b69971f..e13e72e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/unassign.rb +++ b/hbase-shell/src/main/ruby/shell/commands/unassign.rb @@ -21,7 +21,7 @@ module Shell module Commands class Unassign < Command def help - return <<-EOF + <<-EOF Unassign a region. Unassign will close region in current location and then reopen it again. Pass 'true' to force the unassignment ('force' will clear all in-memory state in master before the reassign. If results in http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/update_all_config.rb ---------------------------------------------------------------------- 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 cb6852f..4ad9674 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 @@ -21,7 +21,7 @@ module Shell module Commands class UpdateAllConfig < Command def help - return <<-EOF + <<-EOF Reload a subset of configuration on all servers in the cluster. See http://hbase.apache.org/book.html?dyn_config for more details. Here is how you would run the command in the hbase shell: @@ -29,8 +29,8 @@ you would run the command in the hbase shell: EOF end - def command() - admin.update_all_config() + def command + admin.update_all_config end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/update_config.rb ---------------------------------------------------------------------- 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 3617bb3..2ed262b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/update_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/update_config.rb @@ -21,7 +21,7 @@ module Shell module Commands class UpdateConfig < Command def help - return <<-EOF + <<-EOF Reload a subset of configuration on server 'servername' where servername is host, port plus startcode. For example: host187.example.com,60020,1289493121758 See http://hbase.apache.org/book.html?dyn_config for more details. Here is how http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/update_peer_config.rb ---------------------------------------------------------------------- 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 c09acc2..cdded82 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 @@ -19,9 +19,9 @@ module Shell module Commands - class UpdatePeerConfig< Command + class UpdatePeerConfig < Command def help - return <<-EOF + <<-EOF A peer can either be another HBase cluster or a custom replication endpoint. In either case an id must be specified to identify the peer. This command does not interrupt processing on an enabled replication peer. http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/user_permission.rb ---------------------------------------------------------------------- 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 4b5d3ff..ba40c6c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/user_permission.rb +++ b/hbase-shell/src/main/ruby/shell/commands/user_permission.rb @@ -20,7 +20,7 @@ module Shell module Commands class UserPermission < Command def help - return <<-EOF + <<-EOF Show all permissions for the particular user. Syntax : user_permission <table> @@ -39,12 +39,12 @@ For example: EOF end - def command(table_regex=nil) - #admin.user_permission(table_regex) - formatter.header(["User", "Namespace,Table,Family,Qualifier:Permission"]) + def command(table_regex = nil) + # admin.user_permission(table_regex) + formatter.header(['User', 'Namespace,Table,Family,Qualifier:Permission']) count = security_admin.user_permission(table_regex) do |user, permission| - formatter.row([ user, permission]) + formatter.row([user, permission]) end formatter.footer(count) http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/version.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/version.rb b/hbase-shell/src/main/ruby/shell/commands/version.rb index 63e9712..788501a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/version.rb +++ b/hbase-shell/src/main/ruby/shell/commands/version.rb @@ -21,16 +21,16 @@ module Shell module Commands class Version < Command def help - return <<-EOF + <<-EOF Output this HBase version EOF end def command # Output version. - puts "#{org.apache.hadoop.hbase.util.VersionInfo.getVersion()}, " + - "r#{org.apache.hadoop.hbase.util.VersionInfo.getRevision()}, " + - "#{org.apache.hadoop.hbase.util.VersionInfo.getDate()}" + puts "#{org.apache.hadoop.hbase.util.VersionInfo.getVersion}, " \ + "r#{org.apache.hadoop.hbase.util.VersionInfo.getRevision}, " \ + "#{org.apache.hadoop.hbase.util.VersionInfo.getDate}" end end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb ---------------------------------------------------------------------- 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 a94e9e1..8ee1abc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb +++ b/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb @@ -20,7 +20,7 @@ module Shell module Commands class WalRoll < Command def help - return <<-EOF + <<-EOF Roll the log writer. That is, start writing log messages to a new file. The name of the regionserver should be given as the parameter. A 'server_name' is the host, port plus startcode of a regionserver. For @@ -34,7 +34,7 @@ EOF end end - #TODO remove old HLog version + # TODO: remove old HLog version class HlogRoll < WalRoll end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/whoami.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/whoami.rb b/hbase-shell/src/main/ruby/shell/commands/whoami.rb index 3b6b32d..aac4e3b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/whoami.rb +++ b/hbase-shell/src/main/ruby/shell/commands/whoami.rb @@ -20,7 +20,7 @@ module Shell module Commands class Whoami < Command def help - return <<-EOF + <<-EOF Show the current hbase user. Syntax : whoami For example: @@ -29,11 +29,11 @@ For example: EOF end - def command() - user = org.apache.hadoop.hbase.security.User.getCurrent() - puts "#{user.toString()}" - groups = user.getGroupNames().to_a - if not groups.nil? and groups.length > 0 + def command + user = org.apache.hadoop.hbase.security.User.getCurrent + puts user.toString.to_s + groups = user.getGroupNames.to_a + if !groups.nil? && !groups.empty? puts " groups: #{groups.join(', ')}" end end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb b/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb index c0b509a..fe89014 100644 --- a/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb +++ b/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb @@ -21,7 +21,7 @@ module Shell module Commands class ZkDump < Command def help - return <<-EOF + <<-EOF Dump status of HBase cluster as seen by ZooKeeper. EOF end http://git-wip-us.apache.org/repos/asf/hbase/blob/2115d4b5/hbase-shell/src/main/ruby/shell/formatter.rb ---------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/shell/formatter.rb b/hbase-shell/src/main/ruby/shell/formatter.rb index fb481e0..30402f3 100644 --- a/hbase-shell/src/main/ruby/shell/formatter.rb +++ b/hbase-shell/src/main/ruby/shell/formatter.rb @@ -30,11 +30,11 @@ module Shell obj.instance_of?(IO) || obj.instance_of?(StringIO) || obj == Kernel end - def refresh_width() + def refresh_width @max_width = 0 if $stdout.tty? begin - @max_width = Java::jline.TerminalFactory.get.getWidth + @max_width = Java.jline.TerminalFactory.get.getWidth rescue NameError => e # nocommit debug log and ignore end @@ -44,7 +44,7 @@ module Shell # Takes an output stream and a print width. def initialize(opts = {}) options = { - :output_stream => Kernel, + output_stream: Kernel }.merge(opts) @out = options[:output_stream] @@ -57,7 +57,7 @@ module Shell def header(args = [], widths = []) refresh_width - row(args, false, widths) if args.length > 0 + row(args, false, widths) unless args.empty? @row_count = 0 end @@ -85,20 +85,20 @@ module Shell if @max_width == 0 col1width = col2width = 0 else - col1width = (not widths or widths.length == 0) ? @max_width / 4 : @max_width * widths[0] / 100 - col2width = (not widths or widths.length < 2) ? @max_width - col1width - 2 : @max_width * widths[1] / 100 - 2 + col1width = !widths || widths.empty? ? @max_width / 4 : @max_width * widths[0] / 100 + col2width = !widths || widths.length < 2 ? @max_width - col1width - 2 : @max_width * widths[1] / 100 - 2 end splits1 = split(col1width, dump(args[0])) splits2 = split(col2width, dump(args[1])) - biggest = (splits2.length > splits1.length)? splits2.length: splits1.length + biggest = splits2.length > splits1.length ? splits2.length : splits1.length index = 0 while index < biggest # Inset by one space if inset is set. - @out.print(" ") if inset + @out.print(' ') if inset output(col1width, splits1[index]) # Add extra space so second column lines up w/ second column output - @out.print(" ") unless inset - @out.print(" ") + @out.print(' ') unless inset + @out.print(' ') output(col2width, splits2[index]) index += 1 @out.puts @@ -108,7 +108,7 @@ module Shell print ' ' first = true for e in args - @out.print " " unless first + @out.print ' ' unless first first = false @out.print e end @@ -120,41 +120,40 @@ module Shell # Output the scan metrics. Can be filtered to output only those metrics whose keys exists # in the metric_filter def scan_metrics(scan_metrics = nil, metric_filter = []) - return if scan_metrics == nil - raise(ArgumentError, \ - "Argument should be org.apache.hadoop.hbase.client.metrics.ScanMetrics") \ - unless scan_metrics.kind_of?(org.apache.hadoop.hbase.client.metrics.ScanMetrics) + return if scan_metrics.nil? + unless scan_metrics.is_a?(org.apache.hadoop.hbase.client.metrics.ScanMetrics) + raise(ArgumentError, \ + 'Argument should be org.apache.hadoop.hbase.client.metrics.ScanMetrics') + end # prefix output with empty line @out.puts # save row count to restore after printing metrics # (metrics should not count towards row count) saved_row_count = @row_count - iter = scan_metrics.getMetricsMap().entrySet().iterator() - metric_hash = Hash.new() + iter = scan_metrics.getMetricsMap.entrySet.iterator + metric_hash = {} # put keys in hash so they can be sorted easily while iter.hasNext metric = iter.next metric_hash[metric.getKey.to_s] = metric.getValue.to_s end # print in alphabetical order - row(["METRIC", "VALUE"], false) + row(%w[METRIC VALUE], false) metric_hash.sort.map do |key, value| - if (not metric_filter or metric_filter.length == 0 or metric_filter.include?(key)) + if !metric_filter || metric_filter.empty? || metric_filter.include?(key) row([key, value]) end end @row_count = saved_row_count - return + nil end def split(width, str) - if width == 0 - return [str] - end + return [str] if width == 0 result = [] index = 0 - while index < str.length do + while index < str.length result << str.slice(index, width) index += width end @@ -162,9 +161,9 @@ module Shell end def dump(str) - return if str.instance_of?(Fixnum) + return if str.instance_of?(Integer) # Remove double-quotes added by 'dump'. - return str + str end def output_str(str) @@ -177,10 +176,8 @@ module Shell end def output(width, str) - if str == nil - str = '' - end - if not width or width == str.length + str = '' if str.nil? + if !width || width == str.length @out.print(str) else @out.printf('%-*s', width, str) @@ -190,14 +187,11 @@ module Shell def footer(row_count = nil, is_stale = false) row_count ||= @row_count # Only output elapsed time and row count if startTime passed - @out.puts("%d row(s)" % [row_count]) - if is_stale == true - @out.puts(" (possible stale results) ") - end + @out.puts(format('%d row(s)', row_count)) + @out.puts(' (possible stale results) ') if is_stale == true end end - class Console < Base end @@ -210,4 +204,3 @@ module Shell end end end -
