From b8ea75f17a08e59d6ffe606f38e0a2d9ccb907ec Mon Sep 17 00:00:00 2001 From: Sakthi Date: Sun, 3 Feb 2019 22:59:36 -0800 Subject: [PATCH] HBASE-21821: Address ruby static analysis for shell module [2nd pass] --- hbase-shell/src/main/ruby/hbase/admin.rb | 77 +++-- hbase-shell/src/main/ruby/hbase/quotas.rb | 23 +- .../src/main/ruby/hbase/replication_admin.rb | 46 +-- .../src/main/ruby/hbase/rsgroup_admin.rb | 8 +- hbase-shell/src/main/ruby/hbase/security.rb | 7 +- hbase-shell/src/main/ruby/hbase/table.rb | 23 +- .../src/main/ruby/hbase/taskmonitor.rb | 1 + .../src/main/ruby/hbase/visibility_labels.rb | 8 +- hbase-shell/src/main/ruby/hbase_constants.rb | 1 + hbase-shell/src/main/ruby/shell.rb | 4 +- hbase-shell/src/main/ruby/shell/commands.rb | 8 +- .../main/ruby/shell/commands/add_labels.rb | 2 +- .../src/main/ruby/shell/commands/add_peer.rb | 2 +- .../main/ruby/shell/commands/add_rsgroup.rb | 2 +- .../src/main/ruby/shell/commands/alter.rb | 2 +- .../main/ruby/shell/commands/alter_async.rb | 2 +- .../ruby/shell/commands/alter_namespace.rb | 2 +- .../main/ruby/shell/commands/alter_status.rb | 2 +- .../src/main/ruby/shell/commands/append.rb | 2 +- .../shell/commands/append_peer_namespaces.rb | 2 +- .../shell/commands/append_peer_tableCFs.rb | 2 +- .../src/main/ruby/shell/commands/assign.rb | 2 +- .../ruby/shell/commands/balance_rsgroup.rb | 2 +- .../ruby/shell/commands/balance_switch.rb | 2 +- .../src/main/ruby/shell/commands/balancer.rb | 2 +- .../ruby/shell/commands/balancer_enabled.rb | 2 +- .../shell/commands/catalogjanitor_enabled.rb | 2 +- .../ruby/shell/commands/catalogjanitor_run.rb | 2 +- .../shell/commands/catalogjanitor_switch.rb | 2 +- .../shell/commands/cleaner_chore_enabled.rb | 2 +- .../ruby/shell/commands/cleaner_chore_run.rb | 2 +- .../shell/commands/cleaner_chore_switch.rb | 2 +- .../main/ruby/shell/commands/clear_auths.rb | 2 +- .../ruby/shell/commands/clear_block_cache.rb | 2 +- .../ruby/shell/commands/clone_snapshot.rb | 3 +- .../main/ruby/shell/commands/close_region.rb | 4 +- .../src/main/ruby/shell/commands/count.rb | 2 +- .../src/main/ruby/shell/commands/create.rb | 2 +- .../ruby/shell/commands/create_namespace.rb | 2 +- .../commands/decommission_regionservers.rb | 2 +- .../src/main/ruby/shell/commands/delete.rb | 2 +- .../shell/commands/delete_all_snapshot.rb | 4 +- .../ruby/shell/commands/delete_snapshot.rb | 2 +- .../shell/commands/delete_table_snapshots.rb | 2 +- .../src/main/ruby/shell/commands/deleteall.rb | 2 +- .../src/main/ruby/shell/commands/describe.rb | 2 +- .../ruby/shell/commands/describe_namespace.rb | 2 +- .../src/main/ruby/shell/commands/disable.rb | 2 +- .../main/ruby/shell/commands/disable_all.rb | 3 +- .../main/ruby/shell/commands/disable_peer.rb | 2 +- .../shell/commands/disable_rpc_throttle.rb | 2 +- .../commands/disable_table_replication.rb | 2 +- .../src/main/ruby/shell/commands/drop.rb | 2 +- .../src/main/ruby/shell/commands/drop_all.rb | 3 +- .../ruby/shell/commands/drop_namespace.rb | 2 +- .../src/main/ruby/shell/commands/enable.rb | 2 +- .../main/ruby/shell/commands/enable_all.rb | 3 +- .../main/ruby/shell/commands/enable_peer.rb | 2 +- .../shell/commands/enable_rpc_throttle.rb | 2 +- .../commands/enable_table_replication.rb | 2 +- .../src/main/ruby/shell/commands/exists.rb | 2 +- .../src/main/ruby/shell/commands/flush.rb | 2 +- .../src/main/ruby/shell/commands/get.rb | 2 +- .../src/main/ruby/shell/commands/get_auths.rb | 2 +- .../main/ruby/shell/commands/get_counter.rb | 2 +- .../main/ruby/shell/commands/get_rsgroup.rb | 2 +- .../ruby/shell/commands/get_server_rsgroup.rb | 2 +- .../main/ruby/shell/commands/get_splits.rb | 2 +- .../src/main/ruby/shell/commands/get_table.rb | 2 +- .../ruby/shell/commands/get_table_rsgroup.rb | 2 +- .../src/main/ruby/shell/commands/grant.rb | 6 +- .../src/main/ruby/shell/commands/incr.rb | 2 +- .../main/ruby/shell/commands/is_disabled.rb | 2 +- .../main/ruby/shell/commands/is_enabled.rb | 2 +- .../shell/commands/is_in_maintenance_mode.rb | 2 +- .../src/main/ruby/shell/commands/list.rb | 2 +- .../list_decommissioned_regionservers.rb | 2 +- .../main/ruby/shell/commands/list_labels.rb | 2 +- .../main/ruby/shell/commands/list_locks.rb | 2 +- .../ruby/shell/commands/list_namespace.rb | 2 +- .../shell/commands/list_namespace_tables.rb | 2 +- .../main/ruby/shell/commands/list_peers.rb | 6 +- .../ruby/shell/commands/list_procedures.rb | 2 +- .../shell/commands/list_quota_snapshots.rb | 4 +- .../shell/commands/list_quota_table_sizes.rb | 2 +- .../main/ruby/shell/commands/list_quotas.rb | 2 +- .../main/ruby/shell/commands/list_regions.rb | 2 + .../shell/commands/list_replicated_tables.rb | 2 +- .../main/ruby/shell/commands/list_rsgroups.rb | 2 +- .../commands/list_security_capabilities.rb | 4 +- .../shell/commands/list_snapshot_sizes.rb | 2 +- .../ruby/shell/commands/list_snapshots.rb | 2 +- .../shell/commands/list_table_snapshots.rb | 2 +- .../main/ruby/shell/commands/locate_region.rb | 2 +- .../main/ruby/shell/commands/merge_region.rb | 2 +- .../src/main/ruby/shell/commands/move.rb | 2 +- .../shell/commands/move_namespaces_rsgroup.rb | 2 +- .../move_servers_namespaces_rsgroup.rb | 2 +- .../shell/commands/move_servers_rsgroup.rb | 2 +- .../commands/move_servers_tables_rsgroup.rb | 2 +- .../shell/commands/move_tables_rsgroup.rb | 2 +- .../src/main/ruby/shell/commands/normalize.rb | 2 +- .../ruby/shell/commands/normalizer_enabled.rb | 2 +- .../ruby/shell/commands/normalizer_switch.rb | 2 +- .../main/ruby/shell/commands/processlist.rb | 2 +- .../src/main/ruby/shell/commands/put.rb | 2 +- .../commands/recommission_regionserver.rb | 2 +- .../main/ruby/shell/commands/remove_peer.rb | 2 +- .../shell/commands/remove_peer_namespaces.rb | 2 +- .../shell/commands/remove_peer_tableCFs.rb | 2 +- .../ruby/shell/commands/remove_rsgroup.rb | 2 +- .../shell/commands/remove_servers_rsgroup.rb | 2 +- .../ruby/shell/commands/restore_snapshot.rb | 3 +- .../src/main/ruby/shell/commands/revoke.rb | 2 +- .../src/main/ruby/shell/commands/scan.rb | 2 +- .../src/main/ruby/shell/commands/set_auths.rb | 2 +- .../ruby/shell/commands/set_peer_bandwidth.rb | 2 +- .../commands/set_peer_exclude_namespaces.rb | 2 +- .../commands/set_peer_exclude_tableCFs.rb | 2 +- .../shell/commands/set_peer_namespaces.rb | 2 +- .../shell/commands/set_peer_replicate_all.rb | 2 +- .../ruby/shell/commands/set_peer_serial.rb | 2 +- .../ruby/shell/commands/set_peer_tableCFs.rb | 2 +- .../src/main/ruby/shell/commands/set_quota.rb | 3 +- .../ruby/shell/commands/set_visibility.rb | 2 +- .../main/ruby/shell/commands/show_filters.rb | 2 +- .../ruby/shell/commands/show_peer_tableCFs.rb | 2 +- .../src/main/ruby/shell/commands/snapshot.rb | 2 +- .../src/main/ruby/shell/commands/split.rb | 2 +- .../shell/commands/splitormerge_enabled.rb | 2 +- .../shell/commands/splitormerge_switch.rb | 2 +- .../src/main/ruby/shell/commands/status.rb | 2 +- .../main/ruby/shell/commands/stop_master.rb | 2 +- .../ruby/shell/commands/stop_regionserver.rb | 2 +- .../src/main/ruby/shell/commands/trace.rb | 8 +- .../transit_peer_sync_replication_state.rb | 2 +- .../src/main/ruby/shell/commands/truncate.rb | 2 +- .../ruby/shell/commands/truncate_preserve.rb | 2 +- .../src/main/ruby/shell/commands/unassign.rb | 2 +- .../ruby/shell/commands/update_all_config.rb | 2 +- .../main/ruby/shell/commands/update_config.rb | 2 +- .../ruby/shell/commands/user_permission.rb | 2 +- .../src/main/ruby/shell/commands/version.rb | 2 +- .../src/main/ruby/shell/commands/wal_roll.rb | 2 +- .../src/main/ruby/shell/commands/whoami.rb | 2 +- .../src/main/ruby/shell/commands/zk_dump.rb | 2 +- hbase-shell/src/main/ruby/shell/formatter.rb | 7 +- .../src/test/ruby/hbase/admin2_test.rb | 170 ++++----- hbase-shell/src/test/ruby/hbase/admin_test.rb | 232 ++++++------- hbase-shell/src/test/ruby/hbase/hbase_test.rb | 14 +- .../src/test/ruby/hbase/quotas_test.rb | 57 ++-- .../test/ruby/hbase/quotas_test_no_cluster.rb | 32 +- .../test/ruby/hbase/replication_admin_test.rb | 322 +++++++++--------- .../test/ruby/hbase/security_admin_test.rb | 37 +- hbase-shell/src/test/ruby/hbase/table_test.rb | 300 ++++++++-------- .../src/test/ruby/hbase/taskmonitor_test.rb | 8 +- .../ruby/hbase/test_connection_no_cluster.rb | 4 +- .../hbase/visibility_labels_admin_test.rb | 27 +- .../src/test/ruby/no_cluster_tests_runner.rb | 29 +- .../src/test/ruby/shell/converter_test.rb | 26 +- .../src/test/ruby/shell/formatter_test.rb | 28 +- .../src/test/ruby/shell/list_locks_test.rb | 100 +++--- .../test/ruby/shell/list_procedures_test.rb | 6 +- .../test/ruby/shell/noninteractive_test.rb | 4 +- .../src/test/ruby/shell/rsgroup_shell_test.rb | 8 +- hbase-shell/src/test/ruby/shell/shell_test.rb | 18 +- hbase-shell/src/test/ruby/test_helper.rb | 53 ++- hbase-shell/src/test/ruby/tests_runner.rb | 30 +- 168 files changed, 1047 insertions(+), 969 deletions(-) mode change 100644 => 100755 hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb mode change 100644 => 100755 hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb mode change 100644 => 100755 hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index 2a7e74300c771fc91915c7810f530d412fc0c95f..f9a055004fe31150dc3642252f8435586792c47c 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -295,6 +295,7 @@ module Hbase def enable(table_name) tableExists(table_name) return if enabled?(table_name) + @admin.enableTable(TableName.valueOf(table_name)) end @@ -310,6 +311,7 @@ module Hbase def disable(table_name) tableExists(table_name) return if disabled?(table_name) + @admin.disableTable(TableName.valueOf(table_name)) end @@ -417,6 +419,7 @@ module Hbase unless File.exist?(splits_file) raise(ArgumentError, "Splits file #{splits_file} doesn't exist") end + arg[SPLITS] = [] File.foreach(splits_file) do |line| arg[SPLITS].push(line.chomp) @@ -436,6 +439,7 @@ module Hbase raise(ArgumentError, 'Number of regions must be specified') unless arg.key?(NUMREGIONS) raise(ArgumentError, 'Split algorithm must be specified') unless arg.key?(SPLITALGO) raise(ArgumentError, 'Number of regions must be greater than 1') unless arg[NUMREGIONS] > 1 + num_regions = arg.delete(NUMREGIONS) split_algo = RegionSplitter.newSplitAlgoInstance(@conf, arg.delete(SPLITALGO)) splits = split_algo.split(JInteger.valueOf(num_regions)) @@ -513,15 +517,17 @@ module Hbase table_description = @admin.getTableDescriptor(table_name) raise ArgumentError, "Table #{table_name_str} is not enabled. Enable it first." unless enabled?(table_name_str) + puts 'Disabling table...' @admin.disableTable(table_name) begin puts 'Truncating table...' @admin.truncateTable(table_name, false) - rescue => e + rescue StandardError => e # Handle the compatibility case, where the truncate method doesn't exists on the Master raise e unless e.respond_to?(:cause) && !e.cause.nil? + rootCause = e.cause if rootCause.is_a?(org.apache.hadoop.hbase.DoNotRetryIOException) # Handle the compatibility case, where the truncate method doesn't exists on the Master @@ -561,10 +567,12 @@ module Hbase unless conf.getBoolean('hbase.client.truncatetable.support', true) raise UnsupportedMethodException, 'truncateTable' end + @admin.truncateTable(table_name, true) - rescue => e + rescue StandardError => e # Handle the compatibility case, where the truncate method doesn't exists on the Master raise e unless e.respond_to?(:cause) && !e.cause.nil? + rootCause = e.cause if rootCause.is_a?(org.apache.hadoop.hbase.DoNotRetryIOException) # Handle the compatibility case, where the truncate method doesn't exists on the Master @@ -661,39 +669,46 @@ module Hbase # Delete column family if method == 'delete' raise(ArgumentError, 'NAME parameter missing for delete method') unless name + htd.removeFamily(name.to_java_bytes) hasTableUpdate = true # Unset table attributes elsif method == 'table_att_unset' raise(ArgumentError, 'NAME parameter missing for table_att_unset method') unless name + if name.is_a?(Array) name.each do |key| if htd.getValue(key).nil? raise ArgumentError, "Could not find attribute: #{key}" end + htd.remove(key) end else if htd.getValue(name).nil? raise ArgumentError, "Could not find attribute: #{name}" end + htd.remove(name) end hasTableUpdate = true # Unset table configuration elsif method == 'table_conf_unset' raise(ArgumentError, 'NAME parameter missing for table_conf_unset method') unless name + if name.is_a?(Array) name.each do |key| if htd.getConfigurationValue(key).nil? raise ArgumentError, "Could not find configuration: #{key}" end + htd.removeConfiguration(key) end else if htd.getConfigurationValue(name).nil? raise ArgumentError, "Could not find configuration: #{name}" end + htd.removeConfiguration(name) end hasTableUpdate = true @@ -715,11 +730,13 @@ module Hbase # set a coprocessor attribute valid_coproc_keys = [] next unless arg.is_a?(Hash) + arg.each do |key, value| k = String.new(key) # prepare to strip k.strip! next unless k =~ /coprocessor/i + v = String.new(value) v.strip! # TODO: We should not require user to config the coprocessor with our inner format. @@ -757,13 +774,13 @@ module Hbase puts(format('version %s', status.getHBaseVersion)) # Put regions in transition first because usually empty puts(format('%d regionsInTransition', status.getRegionStatesInTransition.size)) - for v in status.getRegionStatesInTransition + status.getRegionStatesInTransition.each do |v| puts(format(' %s', v)) end master = status.getMaster puts(format('active master: %s:%d %d', master.getHostname, master.getPort, master.getStartcode)) puts(format('%d backup masters', status.getBackupMastersSize)) - for server in status.getBackupMasters + status.getBackupMasters.each do |server| puts(format(' %s:%d %d', server.getHostname, server.getPort, server.getStartcode)) end @@ -772,27 +789,28 @@ module Hbase puts(format('master coprocessors: %s', master_coprocs)) end puts(format('%d live servers', status.getServersSize)) - for server in status.getServers + status.getServers.each do |server| puts(format(' %s:%d %d', server.getHostname, server.getPort, server.getStartcode)) puts(format(' %s', status.getLoad(server).toString)) - for name, region in status.getLoad(server).getRegionsLoad + status.getLoad(server).getRegionsLoad.each do |_name, region| puts(format(' %s', region.getNameAsString.dump)) puts(format(' %s', region.toString)) end end puts(format('%d dead servers', status.getDeadServersSize)) - for server in status.getDeadServerNames + status.getDeadServerNames.each do |server| puts(format(' %s', server)) end elsif format == 'replication' puts(format('version %s', status.getHBaseVersion)) puts(format('%d live servers', status.getServersSize)) - for server in status.getServers + status.getServers.each do |server| sl = status.getLoad(server) rSinkString = ' SINK :' rSourceString = ' SOURCE:' rLoadSink = sl.getReplicationLoadSink next if rLoadSink.nil? + rSinkString << ' AgeOfLastAppliedOp=' + rLoadSink.getAgeOfLastAppliedOp.to_s rSinkString << ', TimeStampsOfLastAppliedOp=' + java.util.Date.new(rLoadSink.getTimeStampsOfLastAppliedOp).toString @@ -824,18 +842,18 @@ module Hbase master = status.getMaster puts(format('active master: %s:%d %d', master.getHostname, master.getPort, master.getStartcode)) puts(format('%d backup masters', status.getBackupMastersSize)) - for server in status.getBackupMasters + status.getBackupMasters.each do |server| puts(format(' %s:%d %d', server.getHostname, server.getPort, server.getStartcode)) end puts(format('%d live servers', status.getServersSize)) - for server in status.getServers + status.getServers.each do |server| puts(format(' %s:%d %d', server.getHostname, server.getPort, server.getStartcode)) puts(format(' %s', status.getLoad(server).toString)) load += status.getLoad(server).getNumberOfRequests regions += status.getLoad(server).getNumberOfRegions end puts(format('%d dead servers', status.getDeadServers)) - for server in status.getDeadServerNames + status.getDeadServerNames.each do |server| puts(format(' %s', server)) end puts(format('Aggregate load: %d, regions: %d', load, regions)) @@ -986,7 +1004,8 @@ module Hbase # Apply user metadata to table/column descriptor def set_user_metadata(descriptor, metadata) raise(ArgumentError, "#{METADATA} must be a Hash type") unless metadata.is_a?(Hash) - for k, v in metadata + + metadata.each do |k, v| v = v.to_s unless v.nil? descriptor.setValue(k, v) end @@ -1047,7 +1066,7 @@ module Hbase # Deletes the table snapshots matching the given regex def delete_table_snapshots(tableNameRegex, snapshotNameRegex = '.*') @admin.deleteTableSnapshots(Pattern.compile(tableNameRegex), - Pattern.compile(snapshotNameRegex)).to_a + Pattern.compile(snapshotNameRegex)).to_a end #---------------------------------------------------------------------------------------------- @@ -1060,7 +1079,7 @@ module Hbase # Returns a list of table snapshots def list_table_snapshots(tableNameRegex, snapshotNameRegex = '.*') @admin.listTableSnapshots(Pattern.compile(tableNameRegex), - Pattern.compile(snapshotNameRegex)).to_a + Pattern.compile(snapshotNameRegex)).to_a end #---------------------------------------------------------------------------------------------- @@ -1085,14 +1104,14 @@ module Hbase else name_list = server_name_string.split(',') - regionservers.each do|sn| + regionservers.each do |sn| if name_list[0] == sn.hostname && (name_list[1].nil? ? true : (name_list[1] == sn.port.to_s)) return sn end end end - return nil + nil end #---------------------------------------------------------------------------------------------- @@ -1103,9 +1122,7 @@ module Hbase if servers.empty? # if no servers were specified as arguments, get a list of all servers - if should_return_all_if_servers_empty - servernames = regionservers - end + servernames = regionservers if should_return_all_if_servers_empty else # Strings replace with ServerName objects in servers array i = 0 @@ -1135,7 +1152,8 @@ module Hbase # Apply config specific to a table/column to its descriptor def set_descriptor_config(descriptor, config) raise(ArgumentError, "#{CONFIGURATION} must be a Hash type") unless config.is_a?(Hash) - for k, v in config + + config.each do |k, v| v = v.to_s unless v.nil? descriptor.setConfiguration(k, v) end @@ -1196,7 +1214,8 @@ module Hbase unless arg.is_a?(Hash) raise(ArgumentError, "#{arg.class} of #{arg.inspect} is not of Hash or String type") end - for k, v in arg + + arg.each do |k, v| v = v.to_s unless v.nil? nsb.addConfiguration(k, v) end @@ -1213,6 +1232,7 @@ module Hbase nsd = @admin.getNamespaceDescriptor(namespace_name) raise(ArgumentError, 'Namespace does not exist') unless nsd + nsb = org.apache.hadoop.hbase.NamespaceDescriptor.create(nsd) # Flatten params array @@ -1223,12 +1243,13 @@ module Hbase unless arg.is_a?(Hash) raise(ArgumentError, "#{arg.class} of #{arg.inspect} is not of Hash type") end + method = arg[METHOD] if method == 'unset' nsb.removeConfiguration(arg[NAME]) elsif method == 'set' arg.delete(METHOD) - for k, v in arg + arg.each do |k, v| v = v.to_s unless v.nil? nsb.addConfiguration(k, v) @@ -1356,7 +1377,7 @@ module Hbase # Fail if host_or_servers is neither a string nor an array unless host_or_servers.is_a?(Array) || host_or_servers.is_a?(String) raise(ArgumentError, - "#{host_or_servers.class} of #{host_or_servers.inspect} is not of Array/String type") + "#{host_or_servers.class} of #{host_or_servers.inspect} is not of Array/String type") end # Fail if should_offload is neither a TrueClass/FalseClass nor a string @@ -1375,7 +1396,7 @@ module Hbase # Fail, if we can not find any server(s) corresponding to the passed host_or_servers if server_names.empty? raise(ArgumentError, - "Could not find any server(s) with specified name(s): #{host_or_servers}") + "Could not find any server(s) with specified name(s): #{host_or_servers}") end @admin.decommissionRegionServers(server_names, @@ -1388,18 +1409,18 @@ module Hbase # Fail if server_name_string is not a string unless server_name_string.is_a?(String) raise(ArgumentError, - "#{server_name_string.class} of #{server_name_string.inspect} is not of String type") + "#{server_name_string.class} of #{server_name_string.inspect} is not of String type") end # Fail if encoded_region_names is not an array unless encoded_region_names.is_a?(Array) raise(ArgumentError, - "#{encoded_region_names.class} of #{encoded_region_names.inspect} is not of Array type") + "#{encoded_region_names.class} of #{encoded_region_names.inspect} is not of Array type") end # Convert encoded_region_names from string to bytes (element-wise) region_names_in_bytes = encoded_region_names - .map {|region_name| region_name.to_java_bytes} + .map(&:to_java_bytes) .compact # Retrieve the server name corresponding to the passed server_name_string @@ -1408,7 +1429,7 @@ module Hbase # Fail if we can not find a server corresponding to the passed server_name_string if server_name.nil? raise(ArgumentError, - "Could not find any server with name #{server_name_string}") + "Could not find any server with name #{server_name_string}") end @admin.recommissionRegionServer(server_name, region_names_in_bytes) diff --git a/hbase-shell/src/main/ruby/hbase/quotas.rb b/hbase-shell/src/main/ruby/hbase/quotas.rb index 4023aedc1cbf2d949e8b5c9b4869de6aa32d6131..5296163f93016184cf2c34946025c9aaa4874aca 100644 --- a/hbase-shell/src/main/ruby/hbase/quotas.rb +++ b/hbase-shell/src/main/ruby/hbase/quotas.rb @@ -57,6 +57,7 @@ module Hbase def throttle(args) raise(ArgumentError, 'Arguments should be a Hash') unless args.is_a?(Hash) + type = args.fetch(THROTTLE_TYPE, REQUEST) args.delete(THROTTLE_TYPE) type, limit, time_unit = _parse_limit(args.delete(LIMIT), ThrottleType, type) @@ -65,22 +66,27 @@ module Hbase if args.key?(TABLE) table = TableName.valueOf(args.delete(TABLE)) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.throttleUser(user, table, type, limit, time_unit) elsif args.key?(NAMESPACE) namespace = args.delete(NAMESPACE) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.throttleUser(user, namespace, type, limit, time_unit) else raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.throttleUser(user, type, limit, time_unit) end elsif args.key?(TABLE) table = TableName.valueOf(args.delete(TABLE)) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.throttleTable(table, type, limit, time_unit) elsif args.key?(NAMESPACE) namespace = args.delete(NAMESPACE) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.throttleNamespace(namespace, type, limit, time_unit) elsif args.key?(REGIONSERVER) # TODO: Setting specified region server quota isn't supported currently and using 'all' for all RS @@ -93,31 +99,38 @@ module Hbase def unthrottle(args) raise(ArgumentError, 'Arguments should be a Hash') unless args.is_a?(Hash) + if args.key?(USER) user = args.delete(USER) if args.key?(TABLE) table = TableName.valueOf(args.delete(TABLE)) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.unthrottleUser(user, table) elsif args.key?(NAMESPACE) namespace = args.delete(NAMESPACE) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.unthrottleUser(user, namespace) else raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.unthrottleUser(user) end elsif args.key?(TABLE) table = TableName.valueOf(args.delete(TABLE)) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.unthrottleTable(table) elsif args.key?(NAMESPACE) namespace = args.delete(NAMESPACE) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.unthrottleNamespace(namespace) elsif args.key?(REGIONSERVER) regionServer = args.delete(REGIONSERVER) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + # TODO: Setting specified region server quota isn't supported currently and using 'all' for all RS settings = QuotaSettingsFactory.unthrottleRegionServer('all') else @@ -130,6 +143,7 @@ module Hbase # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity def limit_space(args) raise(ArgumentError, 'Argument should be a Hash') unless !args.nil? && args.is_a?(Hash) + # Let the user provide a raw number limit = if args[LIMIT].is_a?(Numeric) args[LIMIT] @@ -148,11 +162,13 @@ module Hbase if args.key?(NAMESPACE) raise(ArgumentError, 'Only one of TABLE or NAMESPACE can be specified.') end + settings = QuotaSettingsFactory.limitTableSpace(TableName.valueOf(args.delete(TABLE)), limit, policy) elsif args.key?(NAMESPACE) if args.key?(TABLE) raise(ArgumentError, 'Only one of TABLE or NAMESPACE can be specified.') end + settings = QuotaSettingsFactory.limitNamespaceSpace(args.delete(NAMESPACE), limit, policy) else raise(ArgumentError, 'One of TABLE or NAMESPACE must be specified.') @@ -165,16 +181,19 @@ module Hbase def remove_space_limit(args) raise(ArgumentError, 'Argument should be a Hash') unless !args.nil? && args.is_a?(Hash) + if args.key?(TABLE) if args.key?(NAMESPACE) raise(ArgumentError, 'Only one of TABLE or NAMESPACE can be specified.') end + table = TableName.valueOf(args.delete(TABLE)) settings = QuotaSettingsFactory.removeTableSpaceLimit(table) elsif args.key?(NAMESPACE) if args.key?(TABLE) raise(ArgumentError, 'Only one of TABLE or NAMESPACE can be specified.') end + settings = QuotaSettingsFactory.removeNamespaceSpaceLimit(args.delete(NAMESPACE)) else raise(ArgumentError, 'One of TABLE or NAMESPACE must be specified.') @@ -189,6 +208,7 @@ module Hbase def get_quota_snapshots(regionserver = nil) # Ask a regionserver if we were given one return get_rs_quota_snapshots(regionserver) if regionserver + # Otherwise, read from the quota table get_quota_snapshots_from_table end @@ -209,6 +229,7 @@ module Hbase if args.key?(USER) user = args.delete(USER) raise(ArgumentError, 'Unexpected arguments: ' + args.inspect) unless args.empty? + settings = QuotaSettingsFactory.bypassGlobals(user, bypass) else raise 'Expected USER' @@ -281,7 +302,7 @@ module Hbase # rubocop:disable Metrics/AbcSize, Metrics/MethodLength def _parse_limit(str_limit, type_cls, type) str_limit = str_limit.downcase - match = /^(\d+)(req|cu|[bkmgtp])\/(sec|min|hour|day)$/.match(str_limit) + match = %r{^(\d+)(req|cu|[bkmgtp])/(sec|min|hour|day)$}.match(str_limit) if match limit = match[1].to_i if match[2] == 'req' diff --git a/hbase-shell/src/main/ruby/hbase/replication_admin.rb b/hbase-shell/src/main/ruby/hbase/replication_admin.rb index c788835c6f522b7bf8ec23070541efa0419bf034..29b5d7ce2b8638a182f8d39740bd90e196af63c7 100644 --- a/hbase-shell/src/main/ruby/hbase/replication_admin.rb +++ b/hbase-shell/src/main/ruby/hbase/replication_admin.rb @@ -69,24 +69,18 @@ module Hbase serial = args.fetch(SERIAL, nil) # Create and populate a ReplicationPeerConfig - builder = ReplicationPeerConfig.newBuilder() + builder = ReplicationPeerConfig.newBuilder builder.set_cluster_key(cluster_key) unless endpoint_classname.nil? builder.set_replication_endpoint_impl(endpoint_classname) end - unless remote_wal_dir.nil? - builder.setRemoteWALDir(remote_wal_dir) - end + builder.setRemoteWALDir(remote_wal_dir) unless remote_wal_dir.nil? - unless serial.nil? - builder.setSerial(serial) - end + builder.setSerial(serial) unless serial.nil? - unless config.nil? - builder.putAllConfiguration(config) - end + builder.putAllConfiguration(config) unless config.nil? unless data.nil? # Convert Strings to Bytes for peer_data @@ -262,11 +256,11 @@ module Hbase unless namespaces.nil? rpc = get_peer_config(id) unless rpc.nil? - if rpc.getNamespaces.nil? - ns_set = java.util.HashSet.new - else - ns_set = java.util.HashSet.new(rpc.getNamespaces) - end + ns_set = if rpc.getNamespaces.nil? + java.util.HashSet.new + else + java.util.HashSet.new(rpc.getNamespaces) + end namespaces.each do |n| ns_set.add(n) end @@ -322,11 +316,11 @@ module Hbase unless namespaces.nil? rpc = get_peer_config(id) unless rpc.nil? - if rpc.getExcludeNamespaces.nil? - ns_set = java.util.HashSet.new - else - ns_set = java.util.HashSet.new(rpc.getExcludeNamespaces) - end + ns_set = if rpc.getExcludeNamespaces.nil? + java.util.HashSet.new + else + java.util.HashSet.new(rpc.getExcludeNamespaces) + end namespaces.each do |n| ns_set.add(n) end @@ -359,6 +353,7 @@ module Hbase def set_peer_replicate_all(id, replicate_all) rpc = get_peer_config(id) return if rpc.nil? + rpc.setReplicateAllUserTables(replicate_all) @admin.updateReplicationPeerConfig(id, rpc) end @@ -366,6 +361,7 @@ module Hbase def set_peer_serial(id, peer_serial) rpc = get_peer_config(id) return if rpc.nil? + rpc_builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig .newBuilder(rpc) new_rpc = rpc_builder.setSerial(peer_serial).build @@ -375,12 +371,14 @@ module Hbase # Set exclude namespaces config for the specified peer def set_peer_exclude_namespaces(id, exclude_namespaces) return if exclude_namespaces.nil? + exclude_ns_set = java.util.HashSet.new exclude_namespaces.each do |n| exclude_ns_set.add(n) end rpc = get_peer_config(id) return if rpc.nil? + rpc.setExcludeNamespaces(exclude_ns_set) @admin.updateReplicationPeerConfig(id, rpc) end @@ -389,6 +387,7 @@ module Hbase def show_peer_exclude_namespaces(peer_config) namespaces = peer_config.getExcludeNamespaces return nil if namespaces.nil? + namespaces = java.util.ArrayList.new(namespaces) java.util.Collections.sort(namespaces) '!' + namespaces.join(';') @@ -397,6 +396,7 @@ module Hbase # Set exclude tableCFs config for the specified peer def set_peer_exclude_tableCFs(id, exclude_tableCFs) return if exclude_tableCFs.nil? + # convert tableCFs to TableName map = java.util.HashMap.new exclude_tableCFs.each do |key, val| @@ -404,6 +404,7 @@ module Hbase end rpc = get_peer_config(id) return if rpc.nil? + rpc.setExcludeTableCFsMap(map) @admin.updateReplicationPeerConfig(id, rpc) end @@ -412,6 +413,7 @@ module Hbase def show_peer_exclude_tableCFs(peer_config) tableCFs = peer_config.getExcludeTableCFsMap return nil if tableCFs.nil? + '!' + ReplicationPeerConfigUtil.convertToString(tableCFs) end @@ -465,9 +467,7 @@ module Hbase replication_peer_config = get_peer_config(id) builder = org.apache.hadoop.hbase.replication.ReplicationPeerConfig .newBuilder(replication_peer_config) - unless config.nil? - builder.putAllConfiguration(config) - end + builder.putAllConfiguration(config) unless config.nil? unless data.nil? # Convert Strings to Bytes for peer_data diff --git a/hbase-shell/src/main/ruby/hbase/rsgroup_admin.rb b/hbase-shell/src/main/ruby/hbase/rsgroup_admin.rb index 4e32ea4447b4a65a3e0257ccaf6c7501637d1eb5..ad39abaf6704cd686d12927ab17f93566c219c83 100644 --- a/hbase-shell/src/main/ruby/hbase/rsgroup_admin.rb +++ b/hbase-shell/src/main/ruby/hbase/rsgroup_admin.rb @@ -46,6 +46,7 @@ module Hbase def get_rsgroup(group_name) group = @admin.getRSGroupInfo(group_name) raise(ArgumentError, 'Group does not exist: ' + group_name) if group.nil? + group end @@ -101,6 +102,7 @@ module Hbase org.apache.hadoop.hbase.net.Address.fromString(server) ) raise(ArgumentError, 'Server has no group: ' + server) if res.nil? + res end @@ -111,6 +113,7 @@ module Hbase org.apache.hadoop.hbase.TableName.valueOf(table) ) raise(ArgumentError, 'Table has no group: ' + table) if res.nil? + res end @@ -146,6 +149,7 @@ module Hbase error = "Can't find a namespace: " namespaces.each do |ns| raise(ArgumentError, "#{error}#{ns}") unless namespace_exists?(ns) + table_set.addAll(get_tables_by_namespace(ns)) end table_set @@ -163,9 +167,9 @@ module Hbase # Does Namespace exist def namespace_exists?(ns) - return !@hb_admin.getNamespaceDescriptor(ns).nil? + !@hb_admin.getNamespaceDescriptor(ns).nil? rescue org.apache.hadoop.hbase.NamespaceNotFoundException - return false + false end #-------------------------------------------------------------------------- diff --git a/hbase-shell/src/main/ruby/hbase/security.rb b/hbase-shell/src/main/ruby/hbase/security.rb index 52758989ddf3057c99560a0cecf104fa0c4af231..44633828ee1c3070fd860d00d74385eb28c2286c 100644 --- a/hbase-shell/src/main/ruby/hbase/security.rb +++ b/hbase-shell/src/main/ruby/hbase/security.rb @@ -185,9 +185,9 @@ module Hbase # Does Namespace exist def namespace_exists?(namespace_name) - return !@admin.getNamespaceDescriptor(namespace_name).nil? + !@admin.getNamespaceDescriptor(namespace_name).nil? rescue org.apache.hadoop.hbase.NamespaceNotFoundException => e - return false + false end # Make sure that security features are available @@ -198,11 +198,12 @@ module Hbase # We only need to look at AUTHORIZATION, the AccessController doesn't support # CELL_AUTHORIZATION without AUTHORIZATION also available. caps = @admin.getSecurityCapabilities - rescue + rescue StandardError # If we are unable to use getSecurityCapabilities, fall back with a check for # deployment of the ACL table raise(ArgumentError, 'DISABLED: Security features are not available') unless \ exists?(org.apache.hadoop.hbase.security.access.AccessControlLists::ACL_TABLE_NAME.getNameAsString) + return end raise(ArgumentError, 'DISABLED: Security features are not available') unless \ diff --git a/hbase-shell/src/main/ruby/hbase/table.rb b/hbase-shell/src/main/ruby/hbase/table.rb index 7a334a081436be1211f0ba9225cfcff1a76cbb21..beec48281ff884bc11436c7d5c887cca3ece6bc7 100644 --- a/hbase-shell/src/main/ruby/hbase/table.rb +++ b/hbase-shell/src/main/ruby/hbase/table.rb @@ -104,7 +104,7 @@ flush and drop just by typing: Note that after dropping a table, your reference to it becomes useless and further usage is undefined (and not recommended). -EOF + EOF end #--------------------------------------------------------------------------------------------- @@ -198,7 +198,7 @@ EOF def _deleterows_internal(row, column = nil, timestamp = org.apache.hadoop.hbase.HConstants::LATEST_TIMESTAMP, args = {}, all_version = true) - cache = row['CACHE'] ? row['CACHE'] : 100 + cache = row['CACHE'] || 100 prefix = row['ROWPREFIXFILTER'] # create scan to get table names using prefix @@ -304,6 +304,7 @@ EOF def _count_internal(interval = 1000, scan = nil) raise(ArgumentError, 'Scan argument should be org.apache.hadoop.hbase.client.Scan') \ unless scan.nil? || scan.is_a?(org.apache.hadoop.hbase.client.Scan) + # We can safely set scanner caching with the first key only filter if scan.nil? @@ -333,6 +334,7 @@ EOF row = iter.next count += 1 next unless block_given? && count % interval == 0 + # Allow command modules to visualize counting process yield(count, org.apache.hadoop.hbase.util.Bytes.toStringBinary(row.getRow)) @@ -376,11 +378,7 @@ EOF converter_class = args.delete(FORMATTER_CLASS) || 'org.apache.hadoop.hbase.util.Bytes' unless args.empty? columns = args[COLUMN] || args[COLUMNS] - vers = if args[VERSIONS] - args[VERSIONS] - else - 1 - end + vers = args[VERSIONS] || 1 if columns # Normalize types, convert string to an array of strings columns = [columns] if columns.is_a?(String) @@ -621,7 +619,8 @@ EOF # Apply OperationAttributes to puts/scans/gets def set_attributes(oprattr, attributes) raise(ArgumentError, 'Attributes must be a Hash type') unless attributes.is_a?(Hash) - for k, v in attributes + + attributes.each do |k, v| v = v.to_s unless v.nil? oprattr.setAttribute(k.to_s, v.to_java_bytes) end @@ -629,11 +628,12 @@ EOF def set_cell_permissions(op, permissions) raise(ArgumentError, 'Permissions must be a Hash type') unless permissions.is_a?(Hash) + map = java.util.HashMap.new permissions.each do |user, perms| map.put(user.to_s, org.apache.hadoop.hbase.security.access.Permission.new( perms.to_java_bytes - )) + )) end op.setACL(map) end @@ -648,6 +648,7 @@ EOF def set_authorizations(oprattr, authorizations) raise(ArgumentError, 'Authorizations must be a Array type') unless authorizations.is_a?(Array) + auths = [authorizations].flatten.compact oprattr.setAuthorizations( org.apache.hadoop.hbase.security.visibility.Authorizations.new( @@ -758,9 +759,9 @@ EOF def convert(column, kv, converter_class = 'org.apache.hadoop.hbase.util.Bytes', converter = 'toStringBinary') # use org.apache.hadoop.hbase.util.Bytes as the default class - converter_class = 'org.apache.hadoop.hbase.util.Bytes' unless converter_class + converter_class ||= 'org.apache.hadoop.hbase.util.Bytes' # use org.apache.hadoop.hbase.util.Bytes::toStringBinary as the default convertor - converter = 'toStringBinary' unless converter + converter ||= 'toStringBinary' if @converters.key?(column) # lookup the CONVERTER for certain column - "cf:qualifier" matches = /c\((.+)\)\.(.+)/.match(@converters[column]) diff --git a/hbase-shell/src/main/ruby/hbase/taskmonitor.rb b/hbase-shell/src/main/ruby/hbase/taskmonitor.rb index 15804864beca8305982588b448ec8359617d04b4..136a70645ae13936f4c94d9d2ac3f23988ebaba8 100644 --- a/hbase-shell/src/main/ruby/hbase/taskmonitor.rb +++ b/hbase-shell/src/main/ruby/hbase/taskmonitor.rb @@ -54,6 +54,7 @@ module Hbase def statustime # waiting IPC handlers often have statustime = -1, in this case return starttime return @statustime if @statustime > Time.at(-1) + @starttime end diff --git a/hbase-shell/src/main/ruby/hbase/visibility_labels.rb b/hbase-shell/src/main/ruby/hbase/visibility_labels.rb index e2ae2cad35cd7f73577dcfec44c3409f41fc128e..7c8e0937bdb157612f7000c5915ff2a25c9aa080 100644 --- a/hbase-shell/src/main/ruby/hbase/visibility_labels.rb +++ b/hbase-shell/src/main/ruby/hbase/visibility_labels.rb @@ -43,6 +43,7 @@ module Hbase if response.nil? raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') end + labelsWithException = '' list = response.getResultList list.each do |result| @@ -64,6 +65,7 @@ module Hbase if response.nil? raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') end + labelsWithException = '' list = response.getResultList list.each do |result| @@ -82,6 +84,7 @@ module Hbase if response.nil? raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') end + return response.getAuthList end end @@ -93,6 +96,7 @@ module Hbase if response.nil? raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') end + return response.getLabelList end end @@ -107,6 +111,7 @@ module Hbase if response.nil? raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') end + labelsWithException = '' list = response.getResultList list.each do |result| @@ -124,11 +129,12 @@ module Hbase begin # Try the getSecurityCapabilities API where supported. caps = @admin.getSecurityCapabilities - rescue + rescue StandardError # If we are unable to use getSecurityCapabilities, fall back with a check for # deployment of the labels table raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') unless \ exists?(VisibilityConstants::LABELS_TABLE_NAME) + return end raise(ArgumentError, 'DISABLED: Visibility labels feature is not available') unless \ diff --git a/hbase-shell/src/main/ruby/hbase_constants.rb b/hbase-shell/src/main/ruby/hbase_constants.rb index 98716853a1f50646eea6e5804ba37cb8d4866035..6a54f989536e58108a944e020efebf2274d4abef 100644 --- a/hbase-shell/src/main/ruby/hbase_constants.rb +++ b/hbase-shell/src/main/ruby/hbase_constants.rb @@ -100,6 +100,7 @@ module HBaseConstants constants.each do |c| next if c =~ /DEFAULT_.*/ || c != c.upcase next if eval("defined?(#{c})") + eval("#{c} = '#{c}'") end end diff --git a/hbase-shell/src/main/ruby/shell.rb b/hbase-shell/src/main/ruby/shell.rb index c22652d005660df8a5808feb668bb2233cb221b0..f395e90a0bd37d42e6dc60609aeb2b47faada1de 100644 --- a/hbase-shell/src/main/ruby/shell.rb +++ b/hbase-shell/src/main/ruby/shell.rb @@ -34,6 +34,7 @@ module Shell # Register command in the group raise ArgumentError, "Unknown group: #{group}" unless command_groups[group] + command_groups[group][:commands] << name # Load command @@ -44,7 +45,7 @@ module Shell aliases.each do |an_alias| commands[an_alias] = commands[name] end - rescue => e + rescue StandardError => e raise "Can't load hbase shell command: #{name}. Error: #{e}\n#{e.backtrace.join("\n")}" end end @@ -186,6 +187,7 @@ module Shell if command return help_command(command) if ::Shell.commands[command.to_s] return help_group(command) if ::Shell.command_groups[command.to_s] + puts "ERROR: Invalid command or command group name: #{command}" puts end diff --git a/hbase-shell/src/main/ruby/shell/commands.rb b/hbase-shell/src/main/ruby/shell/commands.rb index 4fdc8b544ab0830418d2a9e768679f30b987b729..f375c6964e1bd0e479ea51090cd35ffb68c8b115 100644 --- a/hbase-shell/src/main/ruby/shell/commands.rb +++ b/hbase-shell/src/main/ruby/shell/commands.rb @@ -47,7 +47,7 @@ module Shell # 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) } - rescue => e + rescue StandardError => e rootCause = e # JRuby9000 made RubyException respond to cause, ignore it for back compat @@ -120,7 +120,7 @@ module Shell # rubocop:disable Metrics/MethodLength, Metrics/PerceivedComplexity def translate_hbase_exceptions(*args) yield - rescue => cause + rescue StandardError => cause # let individual command handle exceptions first cause = cause.getCause if cause.is_a? java.io.UncheckedIOException handle_exceptions(cause, *args) if respond_to?(:handle_exceptions) @@ -128,6 +128,7 @@ module Shell if cause.is_a?(org.apache.hadoop.hbase.TableNotFoundException) strs = cause.to_s.split(' ') raise "Unknown table #{strs[0]}!" if strs.size == 1 + raise "Unknown table #{args.first}!" end if cause.is_a?(org.apache.hadoop.hbase.TableNotEnabledException) @@ -139,6 +140,7 @@ module Shell if cause.is_a?(org.apache.hadoop.hbase.UnknownRegionException) raise "Unknown region #{args.first}!" end + if cause.is_a?(org.apache.hadoop.hbase.NamespaceNotFoundException) s = /.*NamespaceNotFoundException: (?[^\n]+).*/.match(cause.message) raise "Unknown namespace #{s['namespace']}!" @@ -146,6 +148,7 @@ module Shell if cause.is_a?(org.apache.hadoop.hbase.snapshot.SnapshotDoesNotExistException) raise "Unknown snapshot #{args.first}!" end + if cause.is_a?(org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException) exceptions = cause.getCauses exceptions.each do |exception| @@ -158,6 +161,7 @@ module Shell if cause.is_a?(org.apache.hadoop.hbase.TableExistsException) strs = cause.to_s.split(' ') raise "Table already exists: #{strs[0]}!" if strs.size == 1 + raise "Table already exists: #{args.first}!" end # To be safe, here only AccessDeniedException is considered. In future 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 b021b927855e811cdfd05f178a21dfac952153da..b5c2f51cc3c3a093190b57db743fbded7ed5789d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/add_labels.rb +++ b/hbase-shell/src/main/ruby/shell/commands/add_labels.rb @@ -27,7 +27,7 @@ Syntax : add_labels [label1, label2] For example: hbase> add_labels ['SECRET','PRIVATE'] -EOF + EOF end def command(*args) 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 9be42ac5e9522743db98b4ab9ea627cdad71d618..5395d8ecd5c7a0b1fb116e1b9de2c0749f9dd54b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/add_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/add_peer.rb @@ -97,7 +97,7 @@ Examples: Note: The REMOTE_WAL_DIR is not allowed to change. -EOF + EOF end def command(id, args = {}, peer_tableCFs = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/add_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/add_rsgroup.rb index ab32d0569134f028e21559c66e28d12cd7633c2b..00cdf6048ca4d9fd5b91110c08048505a0f20af2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/add_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/add_rsgroup.rb @@ -29,7 +29,7 @@ Example: hbase> add_rsgroup 'my_group' -EOF + EOF end def command(group_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb index 5ba755120f901e4a84f1c8ed0e9cf9a01cff7097..096edfb90ec2156afef865ba6e1e2f3a3d1d30f2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb @@ -91,7 +91,7 @@ There could be more than one alteration in one command: hbase> alter 't1', { NAME => 'f1', VERSIONS => 3 }, { MAX_FILESIZE => '134217728' }, { METHOD => 'delete', NAME => 'f2' }, OWNER => 'johndoe', METADATA => { 'mykey' => 'myvalue' } -EOF + EOF end def command(table, *args) 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 824de1082b52aef026b1d948cd1b3e2dcfcd0d81..af89cb788ccc49defdbe8559ad7a1958327d5b41 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter_async.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter_async.rb @@ -52,7 +52,7 @@ There could be more than one alteration in one command: hbase> alter 't1', {NAME => 'f1'}, {NAME => 'f2', METHOD => 'delete'} To check if all the regions have been updated, use alter_status -EOF + EOF end def command(table, *args) 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 602ac6fb384d5d37ace98796e8cee7f9a5cd9fea..3f634e3b48eefe42c57ddbd7ff6618a14211c576 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter_namespace.rb @@ -31,7 +31,7 @@ To add/modify a property: To delete a property: hbase> alter_namespace 'ns1', {METHOD => 'unset', NAME=>'PROPERTY_NAME'} -EOF + EOF end def command(namespace, *args) diff --git a/hbase-shell/src/main/ruby/shell/commands/alter_status.rb b/hbase-shell/src/main/ruby/shell/commands/alter_status.rb index 828482585cb7a5d4ec0069506d88772134ebbd04..988bacd219eaa78a99fbedd0af1e0f04224023d2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter_status.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter_status.rb @@ -28,7 +28,7 @@ Pass table name. hbase> alter_status 't1' hbase> alter_status 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/append.rb b/hbase-shell/src/main/ruby/shell/commands/append.rb index a7273ca4edfe9bc3555e158202d1949aad75b2e1..c6b06804faed0dc3ba71f742a7d32c0b33deb86b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append.rb @@ -32,7 +32,7 @@ t to table 't1', the corresponding command would be: hbase> t.append 'r1', 'c1', 'value', ATTRIBUTES=>{'mykey'=>'myvalue'} hbase> t.append 'r1', 'c1', 'value', {VISIBILITY=>'PRIVATE|SECRET'} -EOF + EOF end def command(table_name, row, column, value, args = {}) diff --git a/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb index f48cd46b7efd1198f0320f645f1cee641abb6ecb..30d702d93bb8b5274f369d0e5e504354bf4232cc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/append_peer_namespaces.rb @@ -33,7 +33,7 @@ module Shell # append ns1,ns2 to be replicable for peer '2'. hbase> append_peer_namespaces '2', ["ns1", "ns2"] - EOF + EOF end def command(id, namespaces) 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 16b128832937875896d4c23552d597785fe93877..d09696b0ea8db9817a6253ea14294082620f6658 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 @@ -28,7 +28,7 @@ Examples: # append a table / table-cf to be replicable for a peer hbase> append_peer_tableCFs '2', { "ns1:table4" => ["cfA", "cfB"]} -EOF + EOF end def command(id, table_cfs) diff --git a/hbase-shell/src/main/ruby/shell/commands/assign.rb b/hbase-shell/src/main/ruby/shell/commands/assign.rb index da4fc69f68ffc93db7110557a7edfead1f85d94b..6cd3b6d20ea3e3fecdd40bae2681bf1336b05dc7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/assign.rb +++ b/hbase-shell/src/main/ruby/shell/commands/assign.rb @@ -28,7 +28,7 @@ Examples: hbase> assign 'REGIONNAME' hbase> assign 'ENCODED_REGIONNAME' -EOF + EOF end def command(region_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/balance_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/balance_rsgroup.rb index a223e055bbfbd9ba680c74b8c960b19eb84f72aa..c303a66a562110e806a1f79add67c89a1bdc3a57 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balance_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balance_rsgroup.rb @@ -26,7 +26,7 @@ Example: hbase> balance_rsgroup 'my_group' -EOF + EOF end def command(group_name) 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 332ac3b0559f7bf0739b8efa853fbdae7066691b..285ed1230dcbcfcd59359f1bf2d1bd6506102a78 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balance_switch.rb @@ -27,7 +27,7 @@ Examples: hbase> balance_switch true hbase> balance_switch false -EOF + EOF end def command(enableDisable) diff --git a/hbase-shell/src/main/ruby/shell/commands/balancer.rb b/hbase-shell/src/main/ruby/shell/commands/balancer.rb index 276a0a697435ca88a0d9850e48b35eb8ea828f0d..fbc328791ce00cf2c0628b23e41dd26e3a9a7c32 100644 --- a/hbase-shell/src/main/ruby/shell/commands/balancer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balancer.rb @@ -34,7 +34,7 @@ Examples: hbase> balancer hbase> balancer "force" -EOF + EOF end def command(force = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb old mode 100644 new mode 100755 index a2884c4c5f9208c588c82d359c06c6a9ae100489..710681ff46eb7d5a1742d4a6d2a94f1830eda158 --- a/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/balancer_enabled.rb @@ -26,7 +26,7 @@ Query the balancer's state. Examples: hbase> balancer_enabled -EOF + EOF end def command 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 22e26e96e38bccc81b99b2d121b3424a1494a405..8450920bc245ae5da656c10024dfcf15887d84ae 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_enabled.rb @@ -25,7 +25,7 @@ Query for the CatalogJanitor state (enabled/disabled?) Examples: hbase> catalogjanitor_enabled -EOF + EOF end def command 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 32f9f6a6204ddb5af231b3a35fd997aa5a4df097..2e4689efd34ef3d725ce4c02b6dd888f6eb33d9e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_run.rb @@ -25,7 +25,7 @@ Catalog janitor command to run the (garbage collection) scan from command line. hbase> catalogjanitor_run -EOF + EOF end def command 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 48fedc36095dc4dfd1fd1230408d6299b89d28e4..d993344c5b8b9fefcc5cafc6033e998b614c994a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/catalogjanitor_switch.rb @@ -26,7 +26,7 @@ Examples: hbase> catalogjanitor_switch true hbase> catalogjanitor_switch false -EOF + EOF end def command(enableDisable) diff --git a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_enabled.rb index 9fad7a0178399ed714f97a4a63e583451457e7f8..e6d3cb135e287d09f35fa95c8f3476e9cb01347b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_enabled.rb @@ -25,7 +25,7 @@ Query for the Cleaner chore state (enabled/disabled?). Examples: hbase> cleaner_chore_enabled -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_run.rb b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_run.rb index 210f3889bb95b84c5674b0e5181fdb1048d330c2..315a65fb5a9c5dec808fc5abf044814a7a650816 100644 --- a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_run.rb +++ b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_run.rb @@ -25,7 +25,7 @@ Cleaner chore command for garbage collection of HFiles and WAL files. hbase> cleaner_chore_run -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_switch.rb b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_switch.rb index 609978d2932b605d118ea1cd2e1cadc0bc869888..fe6c01a4657ae08ecd31823364fc34897062f33f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/cleaner_chore_switch.rb @@ -26,7 +26,7 @@ Examples: hbase> cleaner_chore_switch true hbase> cleaner_chore_switch false -EOF + EOF end def command(enableDisable) 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 9cd0a2b328bd53cb0633eb986888d17aedb53349..47c8c715f3eb9c0922abde249f3f2954b51653a2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clear_auths.rb @@ -27,7 +27,7 @@ For example: hbase> clear_auths 'user1', ['SECRET','PRIVATE'] hbase> clear_auths '@group1', ['SECRET','PRIVATE'] -EOF + EOF end def command(user, *args) diff --git a/hbase-shell/src/main/ruby/shell/commands/clear_block_cache.rb b/hbase-shell/src/main/ruby/shell/commands/clear_block_cache.rb index ef46cc59eb3a3aff110c137138cb41f250f06dfe..4133b70a0e9c43f122ea024f929770d355a4fba6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clear_block_cache.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clear_block_cache.rb @@ -28,7 +28,7 @@ have to retrieve the blocks from underlying filesystem. For example: hbase> clear_block_cache 'TABLENAME' -EOF + EOF end def command(table_name) 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 8f0b35b39e7af3c3f51dc04f2e8e08dfbf76241f..f546ee68c309ccd5dbd791c200476d16fe6cbde5 100644 --- a/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/clone_snapshot.rb @@ -33,11 +33,12 @@ Following command will restore all acl from origin snapshot table into the newly created table. hbase> clone_snapshot 'snapshotName', 'namespace:tableName', {RESTORE_ACL=>true} -EOF + EOF end def command(snapshot_name, table, args = {}) raise(ArgumentError, 'Arguments should be a Hash') unless args.is_a?(Hash) + restore_acl = args.delete(RESTORE_ACL) || false admin.clone_snapshot(snapshot_name, table, restore_acl) end 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 96450a7a23a796c13399d771db8f92361462d040..e3f656c40f325e38af6c8af2288f70638101bb8d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/close_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/close_region.rb @@ -25,10 +25,10 @@ module Shell --------------------------------------------- DEPRECATED!!! Use 'unassign' command instead. --------------------------------------------- -EOF + EOF end - def command(region_name, server = nil) + def command(_region_name, _server = nil) puts "DEPRECATED!!! Use 'unassign' command instead." 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 03840d0a0d627a8e40aa077975ac1065f8317040..2086b67a95869d9cd95d6e7a182bc5d34fbea037 100644 --- a/hbase-shell/src/main/ruby/shell/commands/count.rb +++ b/hbase-shell/src/main/ruby/shell/commands/count.rb @@ -49,7 +49,7 @@ t to table 't1', the corresponding commands would be: hbase> t.count FILTER => " (QualifierFilter (>=, 'binary:xyz')) AND (TimestampsFilter ( 123, 456))" hbase> t.count COLUMNS => ['c1', 'c2'], STARTROW => 'abc', STOPROW => 'xyz' -EOF + EOF end def command(table, params = {}) diff --git a/hbase-shell/src/main/ruby/shell/commands/create.rb b/hbase-shell/src/main/ruby/shell/commands/create.rb index 14a3942196f5f9c404c982a28ff34658a0e720e4..f6e4d188156ee1739bb0ff940090f52a91b6f85a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/create.rb +++ b/hbase-shell/src/main/ruby/shell/commands/create.rb @@ -59,7 +59,7 @@ You can also keep around a reference to the created table: Which gives you a reference to the table named 't1', on which you can then call methods. -EOF + EOF end def command(table, *args) 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 62a3bc21c2fcc72dc4f1d256bef3c25a483de27b..797eef3b236efd16cbbb6a9716c4ca9debeb5a64 100644 --- a/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/create_namespace.rb @@ -28,7 +28,7 @@ Examples: hbase> create_namespace 'ns1' hbase> create_namespace 'ns1', {'PROPERTY_NAME'=>'PROPERTY_VALUE'} -EOF + EOF end def command(namespace, *args) diff --git a/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb b/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb index 65ac1039c07637ecbf8427b6488d6d219bf88647..ad293174b764762571b9d7696a811c33b5a384e5 100644 --- a/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/decommission_regionservers.rb @@ -38,7 +38,7 @@ module Shell hbase> decommission_regionservers 'server,port,starttime' hbase> decommission_regionservers 'server', false hbase> decommission_regionservers ['server1','server2'], true -EOF + EOF end def command(server_names, should_offload = false) diff --git a/hbase-shell/src/main/ruby/shell/commands/delete.rb b/hbase-shell/src/main/ruby/shell/commands/delete.rb index 923d3498a06aa34e0acaa0d0e65f7fd1e88a66e2..cb57c7508e4765ebf967dcfee00ee6f845b20d50 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete.rb @@ -37,7 +37,7 @@ t to table 't1', the corresponding command would be: hbase> t.delete 'r1', 'c1', ts1 hbase> t.delete 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'} -EOF + EOF end def command(table, row, column, 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 52276fc9c797e879187362bb0c14be7b275c5ec5..89c260a9f924dce0fee2933d2de5345e553b4b5c 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 @@ -25,7 +25,7 @@ Delete all of the snapshots matching the given regex. Examples: hbase> delete_all_snapshot 's.*' -EOF + EOF end def command(regex) @@ -41,6 +41,7 @@ EOF answer = gets.chomp unless count == 0 puts "No snapshots matched the regex #{regex}" if count == 0 return unless answer =~ /y.*/i + @start_time = Time.now admin.delete_all_snapshot(regex) @end_time = Time.now @@ -49,6 +50,7 @@ EOF successfullyDeleted = count - leftOverSnapshotCount puts "#{successfullyDeleted} snapshots successfully deleted." unless successfullyDeleted == 0 return if leftOverSnapshotCount == 0 + puts "\nFailed to delete the below #{leftOverSnapshotCount} snapshots." formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME']) list.each do |snapshot| 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 85c73fb3f737eb8ddbd934326f3b255f4030f0cd..976eb33a7269151773cc8120ae14d725323ec9b9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/delete_snapshot.rb @@ -24,7 +24,7 @@ module Shell Delete a specified snapshot. Examples: hbase> delete_snapshot 'snapshotName', -EOF + EOF end def command(snapshot_name) 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 a7875f10234c46f39522a367cc893df2a2e10beb..bbd333f3c781eb220cf4de581682ba862d076b3a 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 @@ -34,7 +34,7 @@ Examples: hbase> delete_table_snapshots 'tableName.*', 'snapshotName.*' hbase> delete_table_snapshots 'ns:tableName.*', 'snapshotName.*' -EOF + EOF end def command(tableNameregex, snapshotNameRegex = '.*') diff --git a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb index f18fa0550679162490061dec02c44d4630d74df4..c028345bac0236b01ac5a0409a8c17ebc3287860 100644 --- a/hbase-shell/src/main/ruby/shell/commands/deleteall.rb +++ b/hbase-shell/src/main/ruby/shell/commands/deleteall.rb @@ -47,7 +47,7 @@ t to table 't1', the corresponding command would be: hbase> t.deleteall 'r1', 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'} hbase> t.deleteall {ROWPREFIXFILTER => 'prefix', CACHE => 100}, 'c1', ts1, {VISIBILITY=>'PRIVATE|SECRET'} -EOF + EOF end def command(table, row, column = nil, diff --git a/hbase-shell/src/main/ruby/shell/commands/describe.rb b/hbase-shell/src/main/ruby/shell/commands/describe.rb index 5ef02a03a84d56c471adff2fa19a82d2c81b34de..17adc8c4d5e478f8f75f1ff6e3282b711cb8acf2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe.rb @@ -29,7 +29,7 @@ Describe the named table. For example: Alternatively, you can use the abbreviated 'desc' for the same thing. hbase> desc 't1' hbase> desc 'ns1:t1' -EOF + EOF end # rubocop:disable Metrics/AbcSize, Metrics/MethodLength 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 4252ad6022dfaecdbdc077bdcd2851e91ffd7fa8..0e1a57364e27c1deba36e30a514c8fa74b62149f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe_namespace.rb @@ -24,7 +24,7 @@ module Shell <<-EOF Describe the named namespace. For example: hbase> describe_namespace 'ns1' -EOF + EOF end # rubocop:disable Metrics/AbcSize diff --git a/hbase-shell/src/main/ruby/shell/commands/disable.rb b/hbase-shell/src/main/ruby/shell/commands/disable.rb index 79be0a21dfad809f81291fb4c526e0fd9a87628c..e5ef6750e820b7407df95b6bfe6143c7e6d0d487 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable.rb @@ -25,7 +25,7 @@ module Shell Start disable of named table: hbase> disable 't1' hbase> disable 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/disable_all.rb b/hbase-shell/src/main/ruby/shell/commands/disable_all.rb index b4c5a39f407d592e684ce60dc492aa37c31c45ef..86c9543b6ef3e60e0cd77d210e446e8e87d7a900 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_all.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_all.rb @@ -27,7 +27,7 @@ Disable all of tables matching the given regex: hbase> disable_all 't.*' hbase> disable_all 'ns:t.*' hbase> disable_all 'ns:.*' -EOF + EOF end def command(regex) @@ -41,6 +41,7 @@ EOF answer = gets.chomp unless count == 0 puts "No tables matched the regex #{regex}" if count == 0 return unless answer =~ /y.*/i + failed = admin.disable_all(regex) puts "#{count - failed.size} tables successfully disabled" puts "#{failed.size} tables not disabled due to an exception: #{failed.join ','}" unless failed.empty? 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 102731667ca69da1164e48d82bcfb1544285dfdc..e6d101be73c685983c4c812908a2041affde1a5a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_peer.rb @@ -28,7 +28,7 @@ keeps track of new edits to replicate. Examples: hbase> disable_peer '1' -EOF + EOF end def command(id) diff --git a/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb b/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb index 8ecf6f6d64c3c8b1043815633b80f11ced6c757e..f0bbd2ef7ead67ad071f2c4eba4367a36b563214 100644 --- a/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb +++ b/hbase-shell/src/main/ruby/shell/commands/disable_rpc_throttle.rb @@ -21,7 +21,7 @@ module Shell module Commands class DisableRpcThrottle < Command def help - return <<-EOF + <<-EOF Disable quota rpc throttle. Returns previous rpc throttle enabled value. NOTE: if quota is not enabled, this will not work and always return false. 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 0e903ac8f7684d1d6f065ff1763163e92d308f19..c220ccd8c6597d371d475219cda5a1ae3d8eb7fa 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 @@ -26,7 +26,7 @@ Disable a table's replication switch. Examples: hbase> disable_table_replication 'table_name' -EOF + EOF end def command(table_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/drop.rb b/hbase-shell/src/main/ruby/shell/commands/drop.rb index 063eb32773e8d0a01609f59b33ad1ea509ffb865..e48e104be646371c862f5ef5bbd504fb2603e7b0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/drop.rb +++ b/hbase-shell/src/main/ruby/shell/commands/drop.rb @@ -25,7 +25,7 @@ module Shell Drop the named table. Table must first be disabled: hbase> drop 't1' hbase> drop 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/drop_all.rb b/hbase-shell/src/main/ruby/shell/commands/drop_all.rb index 5c40dfd134a4b08e31b71ad8794c6b925ff9779d..554919fc8c14917e625c30ba97de80b3f0fd50d7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/drop_all.rb +++ b/hbase-shell/src/main/ruby/shell/commands/drop_all.rb @@ -27,7 +27,7 @@ Drop all of the tables matching the given regex: hbase> drop_all 't.*' hbase> drop_all 'ns:t.*' hbase> drop_all 'ns:.*' -EOF + EOF end def command(regex) @@ -41,6 +41,7 @@ EOF answer = gets.chomp unless count == 0 puts "No tables matched the regex #{regex}" if count == 0 return unless answer =~ /y.*/i + failed = admin.drop_all(regex) puts "#{count - failed.size} tables successfully dropped" puts "#{failed.size} tables not dropped due to an exception: #{failed.join ','}" unless failed.empty? 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 e667c2ae21913e810afd0061c482371cd3f415c2..b2699ab89be1fb469d2049ba1466f24185f88edb 100644 --- a/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/drop_namespace.rb @@ -23,7 +23,7 @@ module Shell def help <<-EOF Drop the named namespace. The namespace must be empty. -EOF + EOF end def command(namespace) diff --git a/hbase-shell/src/main/ruby/shell/commands/enable.rb b/hbase-shell/src/main/ruby/shell/commands/enable.rb index 13598ecdf54963a842b24ca7c2ad8daad5ea67a4..3454b3ca620d32b0fd02806b3feb91f6b2c64383 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable.rb @@ -25,7 +25,7 @@ module Shell Start enable of named table: hbase> enable 't1' hbase> enable 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/enable_all.rb b/hbase-shell/src/main/ruby/shell/commands/enable_all.rb index a58f1187a5225df9a423688446d0948e48752ada..b68d3d50b99962f1f9ccd7b063b4c44fe4edceda 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_all.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_all.rb @@ -27,7 +27,7 @@ Enable all of the tables matching the given regex: hbase> enable_all 't.*' hbase> enable_all 'ns:t.*' hbase> enable_all 'ns:.*' -EOF + EOF end def command(regex) @@ -41,6 +41,7 @@ EOF answer = gets.chomp unless count == 0 puts "No tables matched the regex #{regex}" if count == 0 return unless answer =~ /y.*/i + failed = admin.enable_all(regex) puts "#{count - failed.size} tables successfully enabled" puts "#{failed.size} tables not enabled due to an exception: #{failed.join ','}" unless failed.empty? 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 19cf7af26f206484450efc63575054ae3c740a86..3d02c83905ea04a5f1646023a24d29d301811558 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_peer.rb @@ -28,7 +28,7 @@ continuing from where it was disabled. Examples: hbase> enable_peer '1' -EOF + EOF end def command(id) diff --git a/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb b/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb index a68c74064d0f7e4f61fb27174f751b63c319a557..28588f31938d02f642224fe10f6846a58126ba3d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb +++ b/hbase-shell/src/main/ruby/shell/commands/enable_rpc_throttle.rb @@ -21,7 +21,7 @@ module Shell module Commands class EnableRpcThrottle < Command def help - return <<-EOF + <<-EOF Enable quota rpc throttle. Returns previous rpc throttle enabled value. NOTE: if quota is not enabled, this will not work and always return false. 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 47eb649de8a4043b8d0401e7b372391fa46fd2e5..970acee1ae504a5af7ecf74f3630b12dc14900ab 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 @@ -26,7 +26,7 @@ Enable a table's replication switch. Examples: hbase> enable_table_replication 'table_name' -EOF + EOF end def command(table_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/exists.rb b/hbase-shell/src/main/ruby/shell/commands/exists.rb index 1471d4aa65f013ce1afd3a0f7ce1f967655461c4..63e0084d47bb22b5ca36a06d23f7fbb991721d72 100644 --- a/hbase-shell/src/main/ruby/shell/commands/exists.rb +++ b/hbase-shell/src/main/ruby/shell/commands/exists.rb @@ -25,7 +25,7 @@ module Shell Does the named table exist? hbase> exists 't1' hbase> exists 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/flush.rb b/hbase-shell/src/main/ruby/shell/commands/flush.rb index 1f6b3105a1d5155754c808a325eb373abb657e85..5729653faa3390a88c6a73fd2105dae2ffbfc63b 100644 --- a/hbase-shell/src/main/ruby/shell/commands/flush.rb +++ b/hbase-shell/src/main/ruby/shell/commands/flush.rb @@ -31,7 +31,7 @@ For example: hbase> flush 'REGIONNAME' hbase> flush 'ENCODED_REGIONNAME' hbase> flush 'REGION_SERVER_NAME' -EOF + EOF end def command(table_or_region_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/get.rb b/hbase-shell/src/main/ruby/shell/commands/get.rb index cdf429996b88b99786af7761b47e36c613dff6ca..9edfcd8993d490901e9b607d1e7dc5ab6d188632 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get.rb @@ -78,7 +78,7 @@ would be: hbase> t.get 'r1', ['c1', 'c2'] hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE'} hbase> t.get 'r1', {CONSISTENCY => 'TIMELINE', REGION_REPLICA_ID => 1} -EOF + EOF end def command(table, row, *args) 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 80e7aeb128df3234d259a7bcf2363e8bee5304cd..5319a66d645e20c8d89a4e6d25a1cefbdcd50921 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_auths.rb @@ -27,7 +27,7 @@ For example: hbase> get_auths 'user1' hbase> get_auths '@group1' -EOF + EOF end def command(user) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_counter.rb b/hbase-shell/src/main/ruby/shell/commands/get_counter.rb index 12ab4b2f2bb59e2d28152f1913a153680d0e045b..429907419f4fabba92b0442dad67b6c2328252b9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_counter.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_counter.rb @@ -33,7 +33,7 @@ The same commands also can be run on a table reference. Suppose you had a refere t to table 't1', the corresponding command would be: hbase> t.get_counter 'r1', 'c1' -EOF + EOF end def command(table, row, column) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/get_rsgroup.rb index 8f5b1c1f9210210850db4576f8879470fd4b4253..dac1341fbd81c8f739372ff57caecb5c5cc63512 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_rsgroup.rb @@ -26,7 +26,7 @@ Example: hbase> get_rsgroup 'default' -EOF + EOF end def command(group_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_server_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/get_server_rsgroup.rb index 042af2d19d3884b13ad70d9c96de131268b33105..22e5269eb4387a71e4f06c713e7f6f56c3f239d2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_server_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_server_rsgroup.rb @@ -26,7 +26,7 @@ Example: hbase> get_server_rsgroup 'server1:port1' -EOF + EOF end def command(server) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb index 49a7debaab9fff69d0f5a1765026f222aa694cc8..be40fb720d145d468d6d103a38d0fc7ad27abdf3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_splits.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_splits.rb @@ -29,7 +29,7 @@ The same commands also can be run on a table reference. Suppose you had a refere t to table 't1', the corresponding command would be: hbase> t.get_splits -EOF + EOF end def command(table) 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 6ad4f33e3e1cc368063c03888668fc42aa551c3c..d1b2780b58cf96494eee364e8176d89f97e1831a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_table.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_table.rb @@ -34,7 +34,7 @@ returns the table named 't1' as a table object. You can then do hbase> t1.help which will then print the help for that table. -EOF + EOF end def command(table, *_args) diff --git a/hbase-shell/src/main/ruby/shell/commands/get_table_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/get_table_rsgroup.rb index dd48ca93c1c292e8cfa69ad6d4e22e26e700afc0..ddde2bd95b64091d781055ae8813f95629cbde75 100644 --- a/hbase-shell/src/main/ruby/shell/commands/get_table_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/get_table_rsgroup.rb @@ -26,7 +26,7 @@ Example: hbase> get_table_rsgroup 'myTable' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/grant.rb b/hbase-shell/src/main/ruby/shell/commands/grant.rb index b5ee4ab863e90d465421922b62b9e4d9e2348b10..8eab679885716b2bb09b0492a9780b6ad9c50df7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/grant.rb +++ b/hbase-shell/src/main/ruby/shell/commands/grant.rb @@ -39,7 +39,7 @@ For example: hbase> grant 'bobsmith', 'RWXCA', '@ns1' hbase> grant 'bobsmith', 'RW', 't1', 'f1', 'col1' hbase> grant 'bobsmith', 'RW', 'ns1:t1', 'f1', 'col1' -EOF + EOF end def command(*args) @@ -60,15 +60,18 @@ EOF raise(ArgumentError, 'Permissions are not of String type') unless permissions.is_a?( String ) + table_name = family = qualifier = nil table_name = args[2] # will be nil if unset unless table_name.nil? raise(ArgumentError, 'Table name is not of String type') unless table_name.is_a?( String ) + family = args[3] # will be nil if unset unless family.nil? raise(ArgumentError, 'Family is not of String type') unless family.is_a?(String) + qualifier = args[4] # will be nil if unset unless qualifier.nil? raise(ArgumentError, 'Qualifier is not of String type') unless qualifier.is_a?( @@ -90,6 +93,7 @@ EOF permissions = args[1] raise(ArgumentError, 'Permissions are not of Hash type') unless permissions.is_a?(Hash) + scan = args[2] raise(ArgumentError, 'Scanner specification is not a Hash') unless scan.is_a?(Hash) diff --git a/hbase-shell/src/main/ruby/shell/commands/incr.rb b/hbase-shell/src/main/ruby/shell/commands/incr.rb index f1c31210af80e6f900aa315c8cbdde5d908344be..75ca3130648dcf66e34526e64bc09b4ebed57f9a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/incr.rb +++ b/hbase-shell/src/main/ruby/shell/commands/incr.rb @@ -41,7 +41,7 @@ t to table 't1', the corresponding command would be: hbase> t.incr 'r1', 'c1', 1 hbase> t.incr 'r1', 'c1', 10, {ATTRIBUTES=>{'mykey'=>'myvalue'}} hbase> t.incr 'r1', 'c1', 10, {VISIBILITY=>'PRIVATE|SECRET'} -EOF + EOF end def command(table, row, column, value = nil, args = {}) 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 20af00c152b782ef14a396ae6ad1a913d351827e..51f8179df514f1139ee3d1a16739d25f9413d300 100644 --- a/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/is_disabled.rb @@ -25,7 +25,7 @@ module Shell Is named table disabled? For example: hbase> is_disabled 't1' hbase> is_disabled 'ns1:t1' -EOF + EOF end def command(table) 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 fa122db374d172ea7e79c3ef211c1ca3ed554d6d..9dae90b4542098fd0018410c0c817796921f07ff 100644 --- a/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/is_enabled.rb @@ -25,7 +25,7 @@ module Shell Is named table enabled? For example: hbase> is_enabled 't1' hbase> is_enabled 'ns1:t1' -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb b/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb index 8ed244cebbef7a0412ecc398c109d68256e12537..ea09d1f7a0ebb9e93e50eab35b9f12d0269134bc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb +++ b/hbase-shell/src/main/ruby/shell/commands/is_in_maintenance_mode.rb @@ -25,7 +25,7 @@ module Shell Is master in maintenance mode? For example: hbase> is_in_maintenance_mode -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/list.rb b/hbase-shell/src/main/ruby/shell/commands/list.rb index 676b5bfd227b599b164bce5bbf1df53d8d23cd51..3e9fc2258f595e4f6768700ccab4b760b7df41d4 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list.rb @@ -29,7 +29,7 @@ be used to filter the output. Examples: hbase> list 'abc.*' hbase> list 'ns:abc.*' hbase> list 'ns:.*' -EOF + EOF end def command(regex = '.*') diff --git a/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb b/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb index 49a6e81d6e690b1bd6788dc0e1921f8877e1c0c1..7d300bd614a1aa7b8b56c5df3d49f8c4ecf1a408 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_decommissioned_regionservers.rb @@ -24,7 +24,7 @@ module Shell def help <<-EOF List region servers marked as decommissioned, which can not be assigned regions. -EOF + EOF end def command 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 8619642351a55c77a16454d1f89510309d28793c..da5cfd6de0104d4f94cdc784452f18e671be9871 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_labels.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_labels.rb @@ -28,7 +28,7 @@ For example: hbase> list_labels 'secret.*' hbase> list_labels -EOF + EOF end def command(regex = '.*') diff --git a/hbase-shell/src/main/ruby/shell/commands/list_locks.rb b/hbase-shell/src/main/ruby/shell/commands/list_locks.rb index 1bebdd514e6f5958f26e0bbc5104f57e9cfb86a6..cb63cdda0ea6dd2f8ed8374b4299b2bd50cedb4a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_locks.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_locks.rb @@ -27,7 +27,7 @@ module Shell List all locks in hbase. Examples: hbase> list_locks -EOF + EOF end def command 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 131337f48218fe0175b86661484e578e349be15e..6462460e1c6dbd4065f7677c319bda59e29d74f4 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_namespace.rb @@ -27,7 +27,7 @@ be used to filter the output. Examples: hbase> list_namespace hbase> list_namespace 'abc.*' -EOF + EOF end def command(regex = '.*') 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 ff08568ee4e52754069c15a343a464ed97321904..97d1a6aed238480896a0e84780556a63f868cb92 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 @@ -26,7 +26,7 @@ List all tables that are members of the namespace. Examples: hbase> list_namespace_tables 'ns1' -EOF + EOF end def command(namespace) 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 f2ec014df8bfdcbf9586fcb0bcd672dcabf80c4f..5c303d14d236869f12852c66e20688408d4f2d95 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_peers.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_peers.rb @@ -32,7 +32,7 @@ module Shell cluster, except that the namespaces and table-cfs in peer config. hbase> list_peers -EOF + EOF end def command @@ -55,9 +55,7 @@ EOF tableCFs = replication_admin.show_peer_tableCFs_by_config(config) end cluster_key = 'nil' - unless config.getClusterKey.nil? - cluster_key = config.getClusterKey - end + cluster_key = config.getClusterKey unless config.getClusterKey.nil? endpoint_classname = 'nil' unless config.getReplicationEndpointImpl.nil? endpoint_classname = config.getReplicationEndpointImpl 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 1d86b8dcddd186af2f2eb14f1f3db203b7bdcd48..3785ef7333a1f2e7c833e781aaeb99f6a398abe6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_procedures.rb @@ -27,7 +27,7 @@ module Shell List all procedures in hbase. For example: hbase> list_procedures -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/list_quota_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/list_quota_snapshots.rb index 5cb01a92a4fbd26b16b0c93fef4cc09787075c86..115b38091fcce9591505eb2131d90af6d66e9334 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_quota_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_quota_snapshots.rb @@ -40,7 +40,7 @@ For example: hbase> list_quota_snapshots({NAMESPACE => 'org1'}) hbase> list_quota_snapshots({REGIONSERVER => 'server1.domain,16020,1483482894742'}) hbase> list_quota_snapshots({NAMESPACE => 'org1', REGIONSERVER => 'server1.domain,16020,1483482894742'}) -EOF + EOF end def command(args = {}) @@ -53,6 +53,7 @@ EOF quotas_admin.get_quota_snapshots(desired_regionserver).each do |table_name, snapshot| # Skip this snapshot if it's for a table/namespace the user did not ask for next unless accept? table_name, desired_table, desired_namespace + status = snapshot.getQuotaStatus policy = get_policy(status) formatter.row([table_name.to_s, snapshot.getUsage.to_s, snapshot.getLimit.to_s, @@ -80,6 +81,7 @@ EOF if desired_namespace && table_name.getNamespaceAsString != desired_namespace return false end + true end end diff --git a/hbase-shell/src/main/ruby/shell/commands/list_quota_table_sizes.rb b/hbase-shell/src/main/ruby/shell/commands/list_quota_table_sizes.rb index ef7505e8c1e3578e132aef590a9d32c076a1495d..02fd41671cbdff399b987ae306346c6e7c1a07a0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_quota_table_sizes.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_quota_table_sizes.rb @@ -30,7 +30,7 @@ provides a higher-level of insight than this command. For example: hbase> list_quota_table_sizes -EOF + EOF end def command(_args = {}) 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 b20aae6762b0c76ff38181af93b7945b19ccb7e8..0110fa4233b5e41c0546e028cf68a92cc7de2182 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_quotas.rb @@ -33,7 +33,7 @@ For example: hbase> list_quotas USER => 'bob.*', NAMESPACE => 'ns.*' hbase> list_quotas TABLE => 'myTable' hbase> list_quotas NAMESPACE => 'ns.*' -EOF + EOF end def command(args = {}) 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 0ce569c0a3136a1dab0c7eabde066d7a0149ac06..a1b5caac347f4d7553c823733c6c4967873f685a 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -99,6 +99,7 @@ EOF # 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 raise "#{LOCALITY_THRESHOLD} must be between 0 and 1.0, inclusive" unless valid_locality_threshold? value + locality_threshold = value end @@ -116,6 +117,7 @@ EOF # Ignore regions which exceed our locality threshold next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold + result_hash = {} if size_hash.key?('SERVER_NAME') 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 1fc6e76517521931e0d98cddba3b0145aa48aa0d..078c6b704ca0325351af12211cd20ff542513e48 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 @@ -27,7 +27,7 @@ List all the tables and column families replicated from this cluster hbase> list_replicated_tables hbase> list_replicated_tables 'abc.*' -EOF + EOF end def command(regex = '.*') 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 dc33b851dc1ab84f12a38305904de84302f079ee..380c403fbb28df7427a3367e25d3099d65ede657 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_rsgroups.rb @@ -28,7 +28,7 @@ Example: hbase> list_rsgroups hbase> list_rsgroups 'abc.*' -EOF + EOF end def command(regex = '.*') 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 873a1f5af9f4b794a0d343f7a8f4e8a4dcbcd64f..9aff652cf1f97750088fb3083243df3b232d87cf 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 @@ -24,7 +24,7 @@ List supported security capabilities Example: hbase> list_security_capabilities -EOF + EOF end def command @@ -32,7 +32,7 @@ EOF list.each do |s| puts s.getName end - return list.map(&:getName) + list.map(&:getName) rescue Exception => e if e.to_s.include? 'UnsupportedOperationException' puts 'ERROR: Master does not support getSecurityCapabilities' 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 c00007c9d3277a6b5184927ec94f9d6d9c2c05d1..7bde4016a8074d8e1b8df51efda9f092c643eaa3 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 @@ -25,7 +25,7 @@ module Shell 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 + EOF end def command(_args = {}) 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 1b3b8f26c3fb330d2ca4b99563ef97372a67ef08..2692d2655e87826cc2883ff07031404d1359a834 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb @@ -30,7 +30,7 @@ by snapshot name. Examples: hbase> list_snapshots hbase> list_snapshots 'abc.*' -EOF + EOF end def command(regex = '.*') 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 558fda8dedf9bcf22ad72846b381438dd4f5b38e..45b8b9919394836639c60d6178be061723057a29 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 @@ -35,7 +35,7 @@ Examples: hbase> list_table_snapshots 'tableName', 'snapshotName.*' hbase> list_table_snapshots 'tableName.*', 'snapshotName.*' hbase> list_table_snapshots 'ns:tableName.*', 'snapshotName.*' -EOF + EOF end def command(tableNameRegex, snapshotNameRegex = '.*') 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 9afbbec4cd8a98b86e8409f8ca1372b6027d302b..6e30e96b24bd1fab677e7dfafa10cbeea9c64675 100644 --- a/hbase-shell/src/main/ruby/shell/commands/locate_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/locate_region.rb @@ -26,7 +26,7 @@ module Shell Locate the region given a table name and a row-key hbase> locate_region 'tableName', 'key0' -EOF + EOF end def command(table, row_key) 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 b4f6cae82050b5569aa08a07d186730ee072ae6b..c4b1509687910c62a14a3ea2d5579bce271f1a49 100644 --- a/hbase-shell/src/main/ruby/shell/commands/merge_region.rb +++ b/hbase-shell/src/main/ruby/shell/commands/merge_region.rb @@ -38,7 +38,7 @@ Examples: hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME' hbase> merge_region 'ENCODED_REGIONNAME', 'ENCODED_REGIONNAME', true -EOF + EOF end def command(region_a_name, region_b_name, force = 'false') diff --git a/hbase-shell/src/main/ruby/shell/commands/move.rb b/hbase-shell/src/main/ruby/shell/commands/move.rb index 3bb2ebc16081fab134605abe712ea5bf23901f9c..789d487e4b27dfe7067a6bc4a25ab8430bc78f5c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move.rb @@ -34,7 +34,7 @@ Examples: hbase> move 'ENCODED_REGIONNAME' hbase> move 'ENCODED_REGIONNAME', 'SERVER_NAME' -EOF + EOF end def command(encoded_region_name, server_name = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb index 0151f7aec6a89af490041c9392463847a56bd576..7ef1972b7b66e8d36c4b1c8f470987fa3d9e02b0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_namespaces_rsgroup.rb @@ -26,7 +26,7 @@ module Shell Example: hbase> move_namespaces_rsgroup 'dest',['ns1','ns2'] -CMD + CMD end def command(dest, namespaces) diff --git a/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb index 16b1ce996c148f3196d7bbafc523e5d90536c304..c65518026f7e99ff36ecf2d46ba81817599c58e7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/move_servers_namespaces_rsgroup.rb @@ -26,7 +26,7 @@ module Shell Example: hbase> move_servers_namespaces_rsgroup 'dest',['server1:port','server2:port'],['ns1','ns2'] -CMD + CMD end def command(dest, servers, namespaces) 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 5370f483ffd45b6524980791640965e3d7dc64d6..b0054ce0fb3412411b3d2071245b109f770bfcd0 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 @@ -27,7 +27,7 @@ Example: hbase> move_servers_rsgroup 'dest',['server1:port','server2:port'] -EOF + EOF end def command(dest, servers) 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 1789a3579e705d11a1f93b645a4cef9978df3680..5aa4facc983e6b5d5c063ffa0c61b9fb86d43e3b 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 @@ -26,7 +26,7 @@ Example: hbase> move_servers_tables_rsgroup 'dest',['server1:port','server2:port'],['table1','table2'] -EOF + EOF end def command(dest, servers, tables) 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 ff644d1cb46a21e46845288794c8a1d147a80df5..51148ce811cb294f673673961289d557e9c084d6 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 @@ -26,7 +26,7 @@ Example: hbase> move_tables_rsgroup 'dest',['table1','table2'] -EOF + EOF end def command(dest, tables) diff --git a/hbase-shell/src/main/ruby/shell/commands/normalize.rb b/hbase-shell/src/main/ruby/shell/commands/normalize.rb index 0d97ec8ae9df96278534e43118bd2a4f474ea573..d9eac2961d294a21d7ecb201f84b07355f6641f1 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalize.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalize.rb @@ -29,7 +29,7 @@ Trigger region normalizer for all tables which have NORMALIZATION_ENABLED flag s Examples: hbase> normalize -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb old mode 100644 new mode 100755 index aed476e879bfc7ca4369462a806c7418bf9b737c..a701c5aade3895e6c8f801a097490e396283eb47 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_enabled.rb @@ -26,7 +26,7 @@ Query the state of region normalizer. Examples: hbase> normalizer_enabled -EOF + EOF end def command 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 03d8d5aa631af81173da15f502fef816cb8991a9..e2758a87e3676f9e6368183e36a792476522ab16 100644 --- a/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/normalizer_switch.rb @@ -28,7 +28,7 @@ Examples: hbase> normalizer_switch true hbase> normalizer_switch false -EOF + EOF end def command(enableDisable) diff --git a/hbase-shell/src/main/ruby/shell/commands/processlist.rb b/hbase-shell/src/main/ruby/shell/commands/processlist.rb index cfb568f518275c775f8801618f612df780bcb5e7..5608b81dc44286e0606867837ef34da12585464f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/processlist.rb +++ b/hbase-shell/src/main/ruby/shell/commands/processlist.rb @@ -35,7 +35,7 @@ Show regionserver task list. hbase> processlist 'all','host187.example.com,16020' hbase> processlist 'all','host187.example.com,16020,1289493121758' -EOF + EOF end def command(*args) diff --git a/hbase-shell/src/main/ruby/shell/commands/put.rb b/hbase-shell/src/main/ruby/shell/commands/put.rb index 118902a400deddc51b9e33acccb21906ef460265..fe0b4d22cc9149cc404ff7c91ca4906bd095b22f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/put.rb +++ b/hbase-shell/src/main/ruby/shell/commands/put.rb @@ -37,7 +37,7 @@ The same commands also can be run on a table reference. Suppose you had a refere t to table 't1', the corresponding command would be: hbase> t.put 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}} -EOF + EOF end def command(table, row, column, value, timestamp = nil, args = {}) diff --git a/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb b/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb index 125eebce5933486dbffef31ddd4214d8fd53ddd7..57ecd2f02f925d7ed2d25cf57177cf0b78db1a7d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb +++ b/hbase-shell/src/main/ruby/shell/commands/recommission_regionserver.rb @@ -33,7 +33,7 @@ module Shell hbase> recommission_regionserver 'server,port' hbase> recommission_regionserver 'server,port,starttime' hbase> recommission_regionserver 'server,port,starttime', ['encoded_region_name1', 'encoded_region_name1'] -EOF + EOF end def command(server_name, encoded_region_names = []) 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 26da40887ae3cfd4b0e784671664cfef8d4eba1b..8256467a2bbeebf00233e07f0fd7a660f784476d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_peer.rb @@ -26,7 +26,7 @@ Stops the specified replication stream and deletes all the meta information kept about it. Examples: hbase> remove_peer '1' -EOF + EOF end def command(id) 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 79b56d90cd9d5ba275ef92f1cd41142619f9b95d..cf680fda7a2ee6bef33a457051ea39f5f98e1e40 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 @@ -30,7 +30,7 @@ module Shell # remove ns1 from the replicable namespaces for peer '2'. hbase> remove_peer_namespaces '2', ["ns1"] - EOF + EOF end def command(id, namespaces) 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 595cf32851c9ed3eb44bcf38c5ece99baf32099f..f478a9ccc2a1b866e217b45da1c51da8420c0b6a 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 @@ -29,7 +29,7 @@ Examples: hbase> remove_peer_tableCFs '2', { "ns1:table1" => []} hbase> remove_peer_tableCFs '2', { "ns1:table1" => ["cf1"]} -EOF + EOF end def command(id, table_cfs) 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 9d39aac9f53da8d51228751b7f707776073de2c7..915e9cb931cf4c4b55c67de37b4a557e2593e802 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_rsgroup.rb @@ -24,7 +24,7 @@ Remove a RegionServer group. hbase> remove_rsgroup 'my_group' -EOF + EOF end def command(group_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/remove_servers_rsgroup.rb b/hbase-shell/src/main/ruby/shell/commands/remove_servers_rsgroup.rb index ba8e60c8d2c221fafee8747bdceb5356994bdbaf..757319815b4c06918aa34a3962946d52db22a025 100644 --- a/hbase-shell/src/main/ruby/shell/commands/remove_servers_rsgroup.rb +++ b/hbase-shell/src/main/ruby/shell/commands/remove_servers_rsgroup.rb @@ -24,7 +24,7 @@ Remove decommissioned servers from rsgroup. Dead/recovering/live servers will be disallowed. Example: hbase> remove_servers_rsgroup ['server1:port','server2:port'] -EOF + EOF end def command(servers) 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 be6ee3ca827a12952017130431e124c2df219588..1c471f1f7ca324fa08c0b4256df8f003fee936a9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/restore_snapshot.rb @@ -32,11 +32,12 @@ Examples: Following command will restore all acl from snapshot table into the table. hbase> restore_snapshot 'snapshotName', {RESTORE_ACL=>true} -EOF + EOF end def command(snapshot_name, args = {}) 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 diff --git a/hbase-shell/src/main/ruby/shell/commands/revoke.rb b/hbase-shell/src/main/ruby/shell/commands/revoke.rb index 4742bd79f63ad5a577f5d1e828252048ae5a090d..f978f15f8a719137e4890c7279197055396e3a30 100644 --- a/hbase-shell/src/main/ruby/shell/commands/revoke.rb +++ b/hbase-shell/src/main/ruby/shell/commands/revoke.rb @@ -36,7 +36,7 @@ For example: hbase> revoke 'bobsmith', '@ns1' hbase> revoke 'bobsmith', 't1', 'f1', 'col1' hbase> revoke 'bobsmith', 'ns1:t1', 'f1', 'col1' -EOF + EOF end def command(user, table_name = nil, family = nil, qualifier = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/scan.rb b/hbase-shell/src/main/ruby/shell/commands/scan.rb index 96382f3195f0849b362f40716b62bc21a7e101d5..4868206e89adc1231289d17707612b8d00d6d3a9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/scan.rb +++ b/hbase-shell/src/main/ruby/shell/commands/scan.rb @@ -100,7 +100,7 @@ table, like such: Note in the above situation, you can still provide all the filtering, columns, options, etc as described above. -EOF + EOF end def command(table, args = {}) 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 ddd04aa6dfc1abeee22ca2878ed3cc7755807c4b..69bbbe43f8695cc2d0dc1a9481d9d7027ae14532 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_auths.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_auths.rb @@ -27,7 +27,7 @@ For example: hbase> set_auths 'user1', ['SECRET','PRIVATE'] hbase> set_auths '@group1', ['SECRET','PRIVATE'] -EOF + EOF end def command(user, *args) 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 e932b9367dfb2f6ea76e52fc023643c13127a307..7e8e80ac1e689b2b990b4e29b740623f56011add 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 @@ -31,7 +31,7 @@ Examples: # unset bandwidth for a peer to use the default bandwidth configured in server-side hbase> set_peer_bandwidth '1' -EOF + EOF end def command(id, bandwidth = 0) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb index bf9b90b45bddd47a41450ad65fb41bb9b9a234b3..50d7131fe09f4020ac2864bcafb47003491a6d07 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_namespaces.rb @@ -41,7 +41,7 @@ module Shell # namespace will not be replicated. hbase> set_peer_exclude_namespaces '2', ["ns1", "ns2"] - EOF + EOF end def command(id, exclude_namespaces) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb index ccb1329cfa21b3087df251c450008d6adc446e11..fefb53d29fd618ce9604f2f5b68131ff533c3dce 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_exclude_tableCFs.rb @@ -40,7 +40,7 @@ module Shell "ns2:table2" => ["cf1", "cf2"], "ns3:table3" => ["cfA", "cfB"]} - EOF + EOF end def command(id, exclude_peer_table_cfs = nil) 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 9f0649dabd4a8c9a601541b168d8091e29826800..bd6fd29ad1974972ed61ffdf6dd793e116d799bf 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 @@ -40,7 +40,7 @@ module Shell # namespace (with replication_scope != 0 ) will be replicated. hbase> set_peer_namespaces '2', ["ns1", "ns2"] - EOF + EOF end def command(id, namespaces) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb index 89969647e5f410b67e1821091234bdf8135fcddb..942341b3ab1b5ebb305b76e3594f0db85b0ca0d3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_replicate_all.rb @@ -49,7 +49,7 @@ module Shell hbase> set_peer_replicate_all '1', true # set replicate_all flag to false hbase> set_peer_replicate_all '1', false -EOF + EOF end def command(id, replicate_all) diff --git a/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb b/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb index a6484cd702b20105818e4736760726eee6e405e2..46652f8b88daf13c1caf8be287c02ae21aa987f2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_peer_serial.rb @@ -38,7 +38,7 @@ module Shell hbase> set_peer_serial '1', true # set serial flag to false hbase> set_peer_serial '1', false - EOF + EOF end def command(id, serial) 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 03b21862a978d1da667f569b1b2abf85b9c58897..d1b5e3ee673bd99df98b3953f37965a111e6ac14 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 @@ -43,7 +43,7 @@ module Shell "ns2:table2" => ["cf1", "cf2"], "ns3:table3" => ["cfA", "cfB"]} - EOF + EOF end def command(id, peer_table_cfs = nil) 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 696fa2a2a84fdbe23570279aa36f500ee5219569..d5aac4b61828399a4c37583092095ca9ddf6dac0 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_quota.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_quota.rb @@ -91,7 +91,7 @@ For example: hbase> set_quota TYPE => SPACE, TABLE => 't1', LIMIT => NONE hbase> set_quota TYPE => SPACE, NAMESPACE => 'ns1', LIMIT => NONE -EOF + EOF end def command(args = {}) @@ -113,6 +113,7 @@ EOF 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 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 5c57d9c528ef7e9886f1e066d48256194de11c2c..6d9de87b6534507b32fd29df12b6e34b9f44af2e 100644 --- a/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb +++ b/hbase-shell/src/main/ruby/shell/commands/set_visibility.rb @@ -46,7 +46,7 @@ Examples: This command will only affect existing cells and is expected to be mainly useful for feature testing and functional verification. -EOF + EOF end def command(table, visibility, scan) 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 0017ed0e26d252118f2ca52276f1d33d071695c6..90e8419d6b4aa9e81766fc3a7f4230908794fbfc 100644 --- a/hbase-shell/src/main/ruby/shell/commands/show_filters.rb +++ b/hbase-shell/src/main/ruby/shell/commands/show_filters.rb @@ -32,7 +32,7 @@ Show all the filters in hbase. Example: PageFilter ..... KeyOnlyFilter -EOF + EOF end def command 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 c2a3f7a526cc5d6c0696ab68f98f934060e5e41c..6d0ccdda2abae54d972218be91429edc3f847530 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 @@ -26,7 +26,7 @@ module Shell Show replicable table-cf config for the specified peer. hbase> show_peer_tableCFs '2' - EOF + EOF end def command(id) diff --git a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb index c591e12b5df6fd793bef4cdf854f385c648e04b0..888016a492c8a35a8a6acbbaa6696e5ada083b40 100644 --- a/hbase-shell/src/main/ruby/shell/commands/snapshot.rb +++ b/hbase-shell/src/main/ruby/shell/commands/snapshot.rb @@ -25,7 +25,7 @@ Take a snapshot of specified table. Examples: hbase> snapshot 'sourceTable', 'snapshotName' hbase> snapshot 'namespace:sourceTable', 'snapshotName', {SKIP_FLUSH => true} -EOF + EOF end def command(table, snapshot_name, *args) diff --git a/hbase-shell/src/main/ruby/shell/commands/split.rb b/hbase-shell/src/main/ruby/shell/commands/split.rb index c7a1e2938ff26a61deb75eac9facd6df3375e050..f09218777b1dbc8b041f0dde8083e9ec716a0c81 100644 --- a/hbase-shell/src/main/ruby/shell/commands/split.rb +++ b/hbase-shell/src/main/ruby/shell/commands/split.rb @@ -30,7 +30,7 @@ Examples: split 'regionName' # format: 'tableName,startKey,id' split 'tableName', 'splitKey' split 'regionName', 'splitKey' -EOF + EOF end def command(table_or_region_name, split_point = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb old mode 100644 new mode 100755 index 5a138718c3c90e296a4b3db51aef5f54937350de..1101abd8357547de8f315074190ec62ebe8c6503 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_enabled.rb @@ -26,7 +26,7 @@ Query the switch's state. You can set switch type, 'SPLIT' or 'MERGE' Examples: hbase> splitormerge_enabled 'SPLIT' -EOF + EOF end def command(switch_type) 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 73dc82dbb029c7f2af970fc25fff86c7c9066d1d..38a6c84ebf3816724087179f78177ad8f3d35cfd 100644 --- a/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb +++ b/hbase-shell/src/main/ruby/shell/commands/splitormerge_switch.rb @@ -28,7 +28,7 @@ Examples: hbase> splitormerge_switch 'SPLIT', true hbase> splitormerge_switch 'SPLIT', false -EOF + EOF end def command(switch_type, enabled) diff --git a/hbase-shell/src/main/ruby/shell/commands/status.rb b/hbase-shell/src/main/ruby/shell/commands/status.rb index af71f6cb0969bb2e6e504d9a79f999e6ee218855..e166b27b189f5e470f859fcd78def324cd0667a1 100644 --- a/hbase-shell/src/main/ruby/shell/commands/status.rb +++ b/hbase-shell/src/main/ruby/shell/commands/status.rb @@ -32,7 +32,7 @@ default is 'summary'. Examples: hbase> status 'replication' hbase> status 'replication', 'source' hbase> status 'replication', 'sink' -EOF + EOF end def command(format = 'summary', type = 'both') diff --git a/hbase-shell/src/main/ruby/shell/commands/stop_master.rb b/hbase-shell/src/main/ruby/shell/commands/stop_master.rb index 45a2b1121a6182019e8fd9bfff1d55dcdbc3101e..b731ad5cc7dc096856dfaa2e6a0373a83022187f 100644 --- a/hbase-shell/src/main/ruby/shell/commands/stop_master.rb +++ b/hbase-shell/src/main/ruby/shell/commands/stop_master.rb @@ -27,7 +27,7 @@ Stop active Master. For experts only. Examples: hbase> stop_master -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb b/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb index 127088d43652600162f6a49056c813fcdfad48ad..113228dee0da3d60eca781068e835498536bdf7d 100644 --- a/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb +++ b/hbase-shell/src/main/ruby/shell/commands/stop_regionserver.rb @@ -29,7 +29,7 @@ Consider using graceful_stop.sh script instead! Examples: hbase> stop_regionserver 'hostname:port' -EOF + EOF end def command(hostport) diff --git a/hbase-shell/src/main/ruby/shell/commands/trace.rb b/hbase-shell/src/main/ruby/shell/commands/trace.rb index f2a8ee0b086d33d092ed6957d95e88d697302b06..5cb9df2912e5979d306c031064211e877dea5520 100644 --- a/hbase-shell/src/main/ruby/shell/commands/trace.rb +++ b/hbase-shell/src/main/ruby/shell/commands/trace.rb @@ -25,7 +25,7 @@ module Shell @@conf = org.apache.htrace.core.HTraceConfiguration.fromKeyValuePairs( 'sampler.classes', 'org.apache.htrace.core.AlwaysSampler' ) - @@tracer = org.apache.htrace.core.Tracer::Builder.new('HBaseShell').conf(@@conf).build() + @@tracer = org.apache.htrace.core.Tracer::Builder.new('HBaseShell').conf(@@conf).build @@tracescope = nil def help @@ -49,7 +49,7 @@ Examples: hbase> trace 'start', 'MySpanName' hbase> trace 'stop' -EOF + EOF end def command(startstop = 'status', spanname = 'HBaseShell') @@ -59,9 +59,7 @@ EOF def trace(startstop, spanname) @@receiver ||= SpanReceiverHost.getInstance(@shell.hbase.configuration) if startstop == 'start' - unless tracing? - @@tracescope = @@tracer.newScope(spanname) - end + @@tracescope = @@tracer.newScope(spanname) unless tracing? elsif startstop == 'stop' if tracing? @@tracescope.close diff --git a/hbase-shell/src/main/ruby/shell/commands/transit_peer_sync_replication_state.rb b/hbase-shell/src/main/ruby/shell/commands/transit_peer_sync_replication_state.rb index 6d4a9638282fc9cf3c9ec1a06ee1eb755a6eb7e1..df6b3bb2af6b2c4bf1d5a25e7d3a1a5c657c2f04 100644 --- a/hbase-shell/src/main/ruby/shell/commands/transit_peer_sync_replication_state.rb +++ b/hbase-shell/src/main/ruby/shell/commands/transit_peer_sync_replication_state.rb @@ -33,7 +33,7 @@ Examples: # Transit cluster state to STANDBY in a synchronous replication peer hbase> transit_peer_sync_replication_state '1', 'STANDBY' -EOF + EOF end def command(id, state) diff --git a/hbase-shell/src/main/ruby/shell/commands/truncate.rb b/hbase-shell/src/main/ruby/shell/commands/truncate.rb index 8c9f30e8e29a48398575f883d49ee99223c05e69..3525db27bc172c5ed62b608f6c916569f60911c9 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate.rb @@ -23,7 +23,7 @@ module Shell def help <<-EOF Disables, drops and recreates the specified table. -EOF + EOF end def command(table) 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 59be7d6193ac8ec400468206a5bd619f4f41a79b..1aef77517adcd429f8b74d00950ce7fa813cd666 100644 --- a/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb +++ b/hbase-shell/src/main/ruby/shell/commands/truncate_preserve.rb @@ -23,7 +23,7 @@ module Shell def help <<-EOF Disables, drops and recreates the specified table while still maintaing the previous region boundaries. -EOF + EOF end def command(table) diff --git a/hbase-shell/src/main/ruby/shell/commands/unassign.rb b/hbase-shell/src/main/ruby/shell/commands/unassign.rb index e13e72e07544bb39f16f4be2dc73c8cb1ed4bd15..0dfc3dbfb3b5a345cd4895ed49ecf28e26630ea7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/unassign.rb +++ b/hbase-shell/src/main/ruby/shell/commands/unassign.rb @@ -32,7 +32,7 @@ Use with caution. For expert use only. Examples: hbase> unassign 'REGIONNAME', true hbase> unassign 'ENCODED_REGIONNAME' hbase> unassign 'ENCODED_REGIONNAME', true -EOF + EOF end def command(region_name, force = 'false') 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 a3907a17f0d658b3d9072f5823182d90c3a78b1f..568ef40d0c82dc008ec725bd9e3f58eefe36bbe8 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 @@ -26,7 +26,7 @@ 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: hbase> update_all_config -EOF + EOF end def command 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 e492db56f7c02436d26d137d1f2d6b0ddd248e66..add5feceb48bfd0f63569fc54b82487ed0272d26 100644 --- a/hbase-shell/src/main/ruby/shell/commands/update_config.rb +++ b/hbase-shell/src/main/ruby/shell/commands/update_config.rb @@ -27,7 +27,7 @@ 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 you would run the command in the hbase shell: hbase> update_config 'servername' -EOF + EOF end def command(serverName) 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 ba40c6c23d115003fe29cee0023840893809526d..198943b9579306c9774f524aeb1b2c68cef80f4c 100644 --- a/hbase-shell/src/main/ruby/shell/commands/user_permission.rb +++ b/hbase-shell/src/main/ruby/shell/commands/user_permission.rb @@ -36,7 +36,7 @@ For example: hbase> user_permission 'namespace1:table1' hbase> user_permission '.*' hbase> user_permission '^[A-C].*' -EOF + EOF end def command(table_regex = nil) diff --git a/hbase-shell/src/main/ruby/shell/commands/version.rb b/hbase-shell/src/main/ruby/shell/commands/version.rb index 788501a55a464a3a74d7fdca4a88e05375a3fb2e..2b85445b82f497d9cce5aa7ed700b19726655229 100644 --- a/hbase-shell/src/main/ruby/shell/commands/version.rb +++ b/hbase-shell/src/main/ruby/shell/commands/version.rb @@ -23,7 +23,7 @@ module Shell def help <<-EOF Output this HBase version -EOF + EOF end def command 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 8ee1abc436cd5c26b4638eac96f55b1afa0b5f58..2ed1808f67f1c45b4dd58f0f37c56539691ecb51 100644 --- a/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb +++ b/hbase-shell/src/main/ruby/shell/commands/wal_roll.rb @@ -26,7 +26,7 @@ The name of the regionserver should be given as the parameter. A 'server_name' is the host, port plus startcode of a regionserver. For example: host187.example.com,60020,1289493121758 (find servername in master ui or when you do detailed status in shell) -EOF + EOF end def command(server_name) diff --git a/hbase-shell/src/main/ruby/shell/commands/whoami.rb b/hbase-shell/src/main/ruby/shell/commands/whoami.rb index aac4e3bae93f48443b486304539d5888c815b0c7..47e3c5770dd2a258af5b8bc3f6d37fa226dc8d12 100644 --- a/hbase-shell/src/main/ruby/shell/commands/whoami.rb +++ b/hbase-shell/src/main/ruby/shell/commands/whoami.rb @@ -26,7 +26,7 @@ Syntax : whoami For example: hbase> whoami -EOF + EOF end def command 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 fe89014a97043d1ee83e2189a543d39c84d3ecb2..79070bdc9f443f645bcbf47cc557db3634c499e2 100644 --- a/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb +++ b/hbase-shell/src/main/ruby/shell/commands/zk_dump.rb @@ -23,7 +23,7 @@ module Shell def help <<-EOF Dump status of HBase cluster as seen by ZooKeeper. -EOF + EOF end def command diff --git a/hbase-shell/src/main/ruby/shell/formatter.rb b/hbase-shell/src/main/ruby/shell/formatter.rb index 30402f31786f74e44a0e79cd3de0a80ee9fd4346..e33422bf081265dbec96cefe4c994bad2fa9b6f1 100644 --- a/hbase-shell/src/main/ruby/shell/formatter.rb +++ b/hbase-shell/src/main/ruby/shell/formatter.rb @@ -77,7 +77,7 @@ module Shell # TODO: Look at the type. Is it RowResult? if args.length == 1 splits = split(@max_width, dump(args[0])) - for l in splits + splits.each do |l| output(@max_width, l) @out.puts end @@ -107,7 +107,7 @@ module Shell # Print a space to set off multi-column rows print ' ' first = true - for e in args + args.each do |e| @out.print ' ' unless first first = false @out.print e @@ -121,6 +121,7 @@ module Shell # in the metric_filter def scan_metrics(scan_metrics = nil, metric_filter = []) 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') @@ -151,6 +152,7 @@ module Shell def split(width, str) return [str] if width == 0 + result = [] index = 0 while index < str.length @@ -162,6 +164,7 @@ module Shell def dump(str) return if str.instance_of?(Integer) + # Remove double-quotes added by 'dump'. str end diff --git a/hbase-shell/src/test/ruby/hbase/admin2_test.rb b/hbase-shell/src/test/ruby/hbase/admin2_test.rb index 2d80b04d2bd8fa5208aa27300a282352da21d2f4..cbe70868251fb51eae4cf2945efdd12c8be62565 100644 --- a/hbase-shell/src/test/ruby/hbase/admin2_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin2_test.rb @@ -83,7 +83,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' drop_test_table(@test_name) create_test_table(@test_name) # Test snapshot name @@ -95,51 +95,51 @@ module Hbase end #------------------------------------------------------------------------------- - define_test "Snapshot should fail with non-string table name" do + define_test 'Snapshot should fail with non-string table name' do assert_raise(ArgumentError) do command(:snapshot, 123, 'xxx') end end - define_test "Snapshot should fail with non-string snapshot name" do + define_test 'Snapshot should fail with non-string snapshot name' do assert_raise(ArgumentError) do command(:snapshot, @test_name, 123) end end - define_test "Snapshot should fail without snapshot name" do + define_test 'Snapshot should fail without snapshot name' do assert_raise(ArgumentError) do command(:snapshot, @test_name) end end - define_test "Snapshot should work with string args" do - drop_test_snapshot() + define_test 'Snapshot should work with string args' do + drop_test_snapshot command(:snapshot, @test_name, @create_test_snapshot) list = command(:list_snapshots, @create_test_snapshot) assert_equal(1, list.size) end - define_test "Snapshot should work when SKIP_FLUSH args" do - drop_test_snapshot() - command(:snapshot, @test_name, @create_test_snapshot, {SKIP_FLUSH => true}) + define_test 'Snapshot should work when SKIP_FLUSH args' do + drop_test_snapshot + command(:snapshot, @test_name, @create_test_snapshot, SKIP_FLUSH => true) list = command(:list_snapshots, @create_test_snapshot) assert_equal(1, list.size) end - define_test "List snapshot without any args" do - drop_test_snapshot() + define_test 'List snapshot without any args' do + drop_test_snapshot command(:snapshot, @test_name, @create_test_snapshot) list = command(:list_snapshots) assert_equal(1, list.size) end - define_test "List snapshot for a non-existing snapshot" do - list = command(:list_snapshots, "xyz") + define_test 'List snapshot for a non-existing snapshot' do + list = command(:list_snapshots, 'xyz') assert_equal(0, list.size) end - define_test "Restore snapshot without any args" do + define_test 'Restore snapshot without any args' do assert_raise(ArgumentError) do command(:restore_snapshot) end @@ -175,38 +175,38 @@ module Hbase drop_test_table(restore_table) end - define_test "Clone snapshot without any args" do + define_test 'Clone snapshot without any args' do assert_raise(ArgumentError) do command(:restore_snapshot) end end - define_test "Clone snapshot without table name args" do + define_test 'Clone snapshot without table name args' do assert_raise(ArgumentError) do command(:clone_snapshot, @create_test_snapshot) end end - define_test "Clone snapshot should work" do - drop_test_snapshot() - clone_table = "test_clone_snapshot_table" - assert_match(eval("/" + "x" + "/"), admin.describe(@test_name)) - assert_match(eval("/" + "y" + "/"), admin.describe(@test_name)) + define_test 'Clone snapshot should work' do + drop_test_snapshot + clone_table = 'test_clone_snapshot_table' + assert_match(eval('/' + 'x' + '/'), admin.describe(@test_name)) + assert_match(eval('/' + 'y' + '/'), admin.describe(@test_name)) command(:snapshot, @test_name, @create_test_snapshot) command(:clone_snapshot, @create_test_snapshot, clone_table) - assert_match(eval("/" + "x" + "/"), admin.describe(clone_table)) - assert_match(eval("/" + "y" + "/"), admin.describe(clone_table)) + assert_match(eval('/' + 'x' + '/'), admin.describe(clone_table)) + assert_match(eval('/' + 'y' + '/'), admin.describe(clone_table)) drop_test_table(clone_table) end - define_test "Delete snapshot without any args" do + define_test 'Delete snapshot without any args' do assert_raise(ArgumentError) do - admin.delete_snapshot() + admin.delete_snapshot end end - define_test "Delete snapshot should work" do - drop_test_snapshot() + define_test 'Delete snapshot should work' do + drop_test_snapshot command(:snapshot, @test_name, @create_test_snapshot) list = command(:list_snapshots) assert_equal(1, list.size) @@ -215,84 +215,84 @@ module Hbase assert_equal(0, list.size) end - define_test "Delete all snapshots without any args" do + define_test 'Delete all snapshots without any args' do assert_raise(ArgumentError) do - admin.delete_all_snapshot() + admin.delete_all_snapshot end end - define_test "Delete all snapshots should work" do - drop_test_snapshot() - command(:snapshot, @test_name, "delete_all_snapshot1") - command(:snapshot, @test_name, "delete_all_snapshot2") - command(:snapshot, @test_name, "snapshot_delete_all_1") - command(:snapshot, @test_name, "snapshot_delete_all_2") + define_test 'Delete all snapshots should work' do + drop_test_snapshot + command(:snapshot, @test_name, 'delete_all_snapshot1') + command(:snapshot, @test_name, 'delete_all_snapshot2') + command(:snapshot, @test_name, 'snapshot_delete_all_1') + command(:snapshot, @test_name, 'snapshot_delete_all_2') list = command(:list_snapshots) assert_equal(4, list.size) - admin.delete_all_snapshot("d.*") + admin.delete_all_snapshot('d.*') list = command(:list_snapshots) assert_equal(2, list.size) - admin.delete_all_snapshot(".*") + admin.delete_all_snapshot('.*') list = command(:list_snapshots) assert_equal(0, list.size) end - define_test "Delete table snapshots without any args" do + define_test 'Delete table snapshots without any args' do assert_raise(ArgumentError) do - admin.delete_table_snapshots() + admin.delete_table_snapshots end end - define_test "Delete table snapshots should work" do - drop_test_snapshot() - command(:snapshot, @test_name, "delete_table_snapshot1") - command(:snapshot, @test_name, "delete_table_snapshot2") - command(:snapshot, @test_name, "snapshot_delete_table1") - new_table = "test_delete_table_snapshots_table" + define_test 'Delete table snapshots should work' do + drop_test_snapshot + command(:snapshot, @test_name, 'delete_table_snapshot1') + command(:snapshot, @test_name, 'delete_table_snapshot2') + command(:snapshot, @test_name, 'snapshot_delete_table1') + new_table = 'test_delete_table_snapshots_table' command(:create, new_table, 'f1') - command(:snapshot, new_table, "delete_table_snapshot3") + command(:snapshot, new_table, 'delete_table_snapshot3') list = command(:list_snapshots) assert_equal(4, list.size) - admin.delete_table_snapshots(@test_name, "d.*") + admin.delete_table_snapshots(@test_name, 'd.*') list = command(:list_snapshots) assert_equal(2, list.size) admin.delete_table_snapshots(@test_name) list = command(:list_snapshots) assert_equal(1, list.size) - admin.delete_table_snapshots(".*", "d.*") + admin.delete_table_snapshots('.*', 'd.*') list = command(:list_snapshots) assert_equal(0, list.size) drop_test_table(new_table) end - define_test "List table snapshots without any args" do + define_test 'List table snapshots without any args' do assert_raise(ArgumentError) do command(:list_table_snapshots) end end - define_test "List table snapshots should work" do - drop_test_snapshot() - command(:snapshot, @test_name, "delete_table_snapshot1") - command(:snapshot, @test_name, "delete_table_snapshot2") - command(:snapshot, @test_name, "snapshot_delete_table1") - new_table = "test_list_table_snapshots_table" + define_test 'List table snapshots should work' do + drop_test_snapshot + command(:snapshot, @test_name, 'delete_table_snapshot1') + command(:snapshot, @test_name, 'delete_table_snapshot2') + command(:snapshot, @test_name, 'snapshot_delete_table1') + new_table = 'test_list_table_snapshots_table' command(:create, new_table, 'f1') - command(:snapshot, new_table, "delete_table_snapshot3") - list = command(:list_table_snapshots, ".*") + command(:snapshot, new_table, 'delete_table_snapshot3') + list = command(:list_table_snapshots, '.*') assert_equal(4, list.size) - list = command(:list_table_snapshots, @test_name, "d.*") + list = command(:list_table_snapshots, @test_name, 'd.*') assert_equal(2, list.size) list = command(:list_table_snapshots, @test_name) assert_equal(3, list.size) - admin.delete_table_snapshots(".*") - list = command(:list_table_snapshots, ".*", ".*") + admin.delete_table_snapshots('.*') + list = command(:list_table_snapshots, '.*', '.*') assert_equal(0, list.size) drop_test_table(new_table) end end -class CommissioningTest < Test::Unit::TestCase + class CommissioningTest < Test::Unit::TestCase include TestHelpers def setup @@ -308,47 +308,47 @@ class CommissioningTest < Test::Unit::TestCase end define_test 'list decommissioned regionservers' do - server_name = admin.getServerNames([], true)[0].getServerName() + server_name = admin.getServerNames([], true)[0].getServerName command(:decommission_regionservers, server_name) begin output = capture_stdout { command(:list_decommissioned_regionservers) } - puts "#{output}" + puts output.to_s assert output.include? 'DECOMMISSIONED REGION SERVERS' - assert output.include? "#{server_name}" + assert output.include? server_name.to_s assert output.include? '1 row(s)' ensure command(:recommission_regionserver, server_name) output = capture_stdout { command(:list_decommissioned_regionservers) } - puts "#{output}" + puts output.to_s assert output.include? 'DECOMMISSIONED REGION SERVERS' - assert (output.include? "#{server_name}") ? false : true + assert output.include? server_name.to_s ? false : true assert output.include? '0 row(s)' end end define_test 'decommission regionservers without offload' do - server_name = admin.getServerNames([], true)[0].getServerName() + server_name = admin.getServerNames([], true)[0].getServerName command(:decommission_regionservers, server_name, false) begin output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name}") + assert (output.include? server_name.to_s) ensure command(:recommission_regionserver, server_name) output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name}") ? false : true + assert output.include? server_name.to_s ? false : true end end define_test 'decommission regionservers with server names as list' do - server_name = admin.getServerNames([], true)[0].getServerName() + server_name = admin.getServerNames([], true)[0].getServerName command(:decommission_regionservers, [server_name]) begin output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name}") + assert (output.include? server_name.to_s) ensure command(:recommission_regionserver, server_name) output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name}") ? false : true + assert output.include? server_name.to_s ? false : true end end @@ -359,38 +359,38 @@ class CommissioningTest < Test::Unit::TestCase command(:decommission_regionservers, host_name) begin output = capture_stdout { command(:list_decommissioned_regionservers) } - assert output.include? "#{server_name_str}" + assert output.include? server_name_str.to_s ensure command(:recommission_regionserver, host_name) output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name_str}") ? false : true + assert output.include? server_name_str.to_s ? false : true end end define_test 'decommission regionservers with server host name and port' do server_name = admin.getServerNames([], true)[0] - host_name_and_port = server_name.getHostname + ',' +server_name.getPort.to_s + host_name_and_port = server_name.getHostname + ',' + server_name.getPort.to_s server_name_str = server_name.getServerName command(:decommission_regionservers, host_name_and_port) begin output = capture_stdout { command(:list_decommissioned_regionservers) } - assert output.include? "#{server_name_str}" + assert output.include? server_name_str.to_s ensure command(:recommission_regionserver, host_name_and_port) output = capture_stdout { command(:list_decommissioned_regionservers) } - assert (output.include? "#{server_name_str}") ? false : true + assert output.include? server_name_str.to_s ? false : true end end define_test 'decommission regionservers with non-existant server name' do - server_name = admin.getServerNames([], true)[0].getServerName() + server_name = admin.getServerNames([], true)[0].getServerName assert_raise(ArgumentError) do command(:decommission_regionservers, 'dummy') end end define_test 'recommission regionserver with non-existant server name' do - server_name = admin.getServerNames([], true)[0].getServerName() + server_name = admin.getServerNames([], true)[0].getServerName assert_raise(ArgumentError) do command(:recommission_regionserver, 'dummy') end @@ -402,15 +402,15 @@ class CommissioningTest < Test::Unit::TestCase end assert_raise(ArgumentError) do - command(:decommission_regionservers, {1=>1}) + command(:decommission_regionservers, 1 => 1) end assert_raise(ArgumentError) do - command(:decommission_regionservers, 'dummy', 1) + command(:decommission_regionservers, 'dummy', 1) end assert_raise(ArgumentError) do - command(:decommission_regionservers, 'dummy', {1=>1}) + command(:decommission_regionservers, 'dummy', 1 => 1) end end @@ -420,7 +420,7 @@ class CommissioningTest < Test::Unit::TestCase end assert_raise(ArgumentError) do - command(:recommission_regionserver, {1=>1}) + command(:recommission_regionserver, 1 => 1) end assert_raise(ArgumentError) do @@ -428,9 +428,9 @@ class CommissioningTest < Test::Unit::TestCase end assert_raise(ArgumentError) do - command(:recommission_regionserver, 'dummy', {1=>1}) + command(:recommission_regionserver, 'dummy', 1 => 1) end end - end + end # rubocop:enable ClassLength end diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 3bd3961f106114051e96ec2900a50934e3107798..bc847bf7f3d256972bf5ef8cd85142c38d11161c 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -32,7 +32,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_admin_test_table" + @test_name = 'hbase_shell_admin_test_table' create_test_table(@test_name) end @@ -40,20 +40,20 @@ module Hbase shutdown end - define_test "exists? should return true when a table exists" do + define_test 'exists? should return true when a table exists' do assert(command(:exists, 'hbase:meta')) end - define_test "exists? should return false when a table exists" do + define_test 'exists? should return false when a table exists' do assert(!command(:exists, 'NOT.EXISTS')) end - define_test "enabled? should return true for enabled tables" do + define_test 'enabled? should return true for enabled tables' do command(:enable, @test_name) assert(command(:is_enabled, @test_name)) end - define_test "enabled? should return false for disabled tables" do + define_test 'enabled? should return false for disabled tables' do command(:disable, @test_name) assert(!command(:is_enabled, @test_name)) end @@ -67,7 +67,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' create_test_table(@test_name) # Create table test table name @@ -78,29 +78,29 @@ module Hbase shutdown end - define_test "list should return a list of tables" do + define_test 'list should return a list of tables' do list = command(:list) assert(list.member?(@test_name)) end - define_test "list should not return meta tables" do + define_test 'list should not return meta tables' do list = command(:list) assert(!list.member?('hbase:meta')) end - define_test "list_namespace_tables for the system namespace should return a list of tables" do + define_test 'list_namespace_tables for the system namespace should return a list of tables' do list = command(:list_namespace_tables, 'hbase') assert(list.count > 0) end - define_test "list_namespace_tables for the default namespace should return a list of tables" do + define_test 'list_namespace_tables for the default namespace should return a list of tables' do list = command(:list_namespace_tables, 'default') assert(list.count > 0) end #------------------------------------------------------------------------------- - define_test "flush should work" do + define_test 'flush should work' do command(:flush, 'hbase:meta') servers = admin.list_liveservers servers.each do |s| @@ -110,47 +110,47 @@ module Hbase #------------------------------------------------------------------------------- - define_test "compact should work" do + define_test 'compact should work' do command(:compact, 'hbase:meta') end #------------------------------------------------------------------------------- - define_test "compaction_state should work" do + define_test 'compaction_state should work' do command(:compaction_state, 'hbase:meta') end #------------------------------------------------------------------------------- - define_test "major_compact should work" do + define_test 'major_compact should work' do command(:major_compact, 'hbase:meta') end #------------------------------------------------------------------------------- - define_test "split should work" do + define_test 'split should work' do begin command(:split, 'hbase:meta', nil) rescue org.apache.hadoop.hbase.ipc.RemoteWithExtrasException => e - puts "can not split hbase:meta" + puts 'can not split hbase:meta' end end #------------------------------------------------------------------------------- - define_test "drop should fail on non-existent tables" do + define_test 'drop should fail on non-existent tables' do assert_raise(ArgumentError) do command(:drop, 'NOT.EXISTS') end end - define_test "drop should fail on enabled tables" do + define_test 'drop should fail on enabled tables' do assert_raise(ArgumentError) do command(:drop, @test_name) end end - define_test "drop should drop tables" do + define_test 'drop should drop tables' do command(:disable, @test_name) command(:drop, @test_name) assert(!command(:exists, @test_name)) @@ -158,58 +158,58 @@ module Hbase #------------------------------------------------------------------------------- - define_test "zk_dump should work" do + define_test 'zk_dump should work' do assert_not_nil(admin.zk_dump) end #------------------------------------------------------------------------------- - define_test "create should fail with non-string table names" do + define_test 'create should fail with non-string table names' do assert_raise(ArgumentError) do command(:create, 123, 'xxx') end end - define_test "create should fail with non-string/non-hash column args" do + define_test 'create should fail with non-string/non-hash column args' do assert_raise(ArgumentError) do command(:create, @create_test_name, 123) end end - define_test "create should fail without columns" do + define_test 'create should fail without columns' do drop_test_table(@create_test_name) assert_raise(ArgumentError) do command(:create, @create_test_name) end end - define_test "create should fail without columns when called with options" do + define_test 'create should fail without columns when called with options' do drop_test_table(@create_test_name) assert_raise(ArgumentError) do - command(:create, @create_test_name, { OWNER => 'a' }) + command(:create, @create_test_name, OWNER => 'a') end end - define_test "create should work with string column args" do + define_test 'create should work with string column args' do drop_test_table(@create_test_name) command(:create, @create_test_name, 'a', 'b') assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) end - define_test "create should work with hash column args" do + define_test 'create should work with hash column args' do drop_test_table(@create_test_name) - command(:create, @create_test_name, { NAME => 'a'}, { NAME => 'b'}) + command(:create, @create_test_name, { NAME => 'a' }, NAME => 'b') assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) end - define_test "create should be able to set column options" do + define_test 'create should be able to set column options' do drop_test_table(@create_test_name) command(:create, @create_test_name, - { NAME => 'a', + NAME => 'a', CACHE_BLOOMS_ON_WRITE => 'TRUE', CACHE_INDEX_ON_WRITE => 'TRUE', EVICT_BLOCKS_ON_CLOSE => 'TRUE', - COMPRESSION_COMPACT => 'GZ'}) + COMPRESSION_COMPACT => 'GZ') assert_equal(['a:'], table(@create_test_name).get_all_columns.sort) assert_match(/CACHE_BLOOMS_ON_WRITE/, admin.describe(@create_test_name)) assert_match(/CACHE_INDEX_ON_WRITE/, admin.describe(@create_test_name)) @@ -217,15 +217,15 @@ module Hbase assert_match(/GZ/, admin.describe(@create_test_name)) end - define_test "create should be able to set table options" do + define_test 'create should be able to set table options' do drop_test_table(@create_test_name) - command(:create, @create_test_name, 'a', 'b', 'MAX_FILESIZE' => 12345678, - OWNER => '987654321', - PRIORITY => '77', - FLUSH_POLICY => 'org.apache.hadoop.hbase.regionserver.FlushAllLargeStoresPolicy', - REGION_MEMSTORE_REPLICATION => 'TRUE', - SPLIT_POLICY => 'org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy', - COMPACTION_ENABLED => 'false') + command(:create, @create_test_name, 'a', 'b', 'MAX_FILESIZE' => 12_345_678, + OWNER => '987654321', + PRIORITY => '77', + FLUSH_POLICY => 'org.apache.hadoop.hbase.regionserver.FlushAllLargeStoresPolicy', + REGION_MEMSTORE_REPLICATION => 'TRUE', + SPLIT_POLICY => 'org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy', + COMPACTION_ENABLED => 'false') assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) assert_match(/12345678/, admin.describe(@create_test_name)) assert_match(/987654321/, admin.describe(@create_test_name)) @@ -233,28 +233,28 @@ module Hbase assert_match(/COMPACTION_ENABLED/, admin.describe(@create_test_name)) assert_match(/REGION_MEMSTORE_REPLICATION/, admin.describe(@create_test_name)) assert_match(/org.apache.hadoop.hbase.regionserver.FlushAllLargeStoresPolicy/, - admin.describe(@create_test_name)) + admin.describe(@create_test_name)) assert_match(/org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy/, - admin.describe(@create_test_name)) + admin.describe(@create_test_name)) end - define_test "create should ignore table_att" do + define_test 'create should ignore table_att' do drop_test_table(@create_test_name) command(:create, @create_test_name, 'a', 'b', METHOD => 'table_att', OWNER => '987654321') assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) assert_match(/987654321/, admin.describe(@create_test_name)) end - define_test "create should work with SPLITALGO" do + define_test 'create should work with SPLITALGO' do drop_test_table(@create_test_name) command(:create, @create_test_name, 'a', 'b', - {NUMREGIONS => 10, SPLITALGO => 'HexStringSplit'}) + NUMREGIONS => 10, SPLITALGO => 'HexStringSplit') assert_equal(['a:', 'b:'], table(@create_test_name).get_all_columns.sort) end define_test "create should work when attributes value 'false' is not enclosed in single quotation marks" do drop_test_table(@create_test_name) - command(:create, @create_test_name,{NAME => 'a', BLOCKCACHE => false}, {COMPACTION_ENABLED => false}) + command(:create, @create_test_name, { NAME => 'a', BLOCKCACHE => false }, COMPACTION_ENABLED => false) assert_equal(['a:'], table(@create_test_name).get_all_columns.sort) assert_match(/BLOCKCACHE/, admin.describe(@create_test_name)) assert_match(/COMPACTION_ENABLED/, admin.describe(@create_test_name)) @@ -262,7 +262,7 @@ module Hbase #------------------------------------------------------------------------------- - define_test "describe should fail for non-existent tables" do + define_test 'describe should fail for non-existent tables' do assert_raise(ArgumentError) do admin.describe('NOT.EXISTS') end @@ -327,56 +327,56 @@ module Hbase #------------------------------------------------------------------------------- - define_test "truncate should empty a table" do - table(@test_name).put(1, "x:a", 1) - table(@test_name).put(2, "x:a", 2) + define_test 'truncate should empty a table' do + table(@test_name).put(1, 'x:a', 1) + table(@test_name).put(2, 'x:a', 2) assert_equal(2, table(@test_name)._count_internal) # This is hacky. Need to get the configuration into admin instance command(:truncate, @test_name) assert_equal(0, table(@test_name)._count_internal) end - define_test "truncate should yield log records" do + define_test 'truncate should yield log records' do output = capture_stdout { command(:truncate, @test_name) } assert(!output.empty?) end #------------------------------------------------------------------------------- - define_test "truncate_preserve should empty a table" do - table(@test_name).put(1, "x:a", 1) - table(@test_name).put(2, "x:a", 2) + define_test 'truncate_preserve should empty a table' do + table(@test_name).put(1, 'x:a', 1) + table(@test_name).put(2, 'x:a', 2) assert_equal(2, table(@test_name)._count_internal) # This is hacky. Need to get the configuration into admin instance command(:truncate_preserve, @test_name) assert_equal(0, table(@test_name)._count_internal) end - define_test "truncate_preserve should yield log records" do + define_test 'truncate_preserve should yield log records' do output = capture_stdout { command(:truncate_preserve, @test_name) } assert(!output.empty?) end - define_test "truncate_preserve should maintain the previous region boundaries" do + define_test 'truncate_preserve should maintain the previous region boundaries' do drop_test_table(@create_test_name) - admin.create(@create_test_name, 'a', {NUMREGIONS => 10, SPLITALGO => 'HexStringSplit'}) - splits = table(@create_test_name)._get_splits_internal() + admin.create(@create_test_name, 'a', NUMREGIONS => 10, SPLITALGO => 'HexStringSplit') + splits = table(@create_test_name)._get_splits_internal command(:truncate_preserve, @create_test_name) - assert_equal(splits, table(@create_test_name)._get_splits_internal()) + assert_equal(splits, table(@create_test_name)._get_splits_internal) end define_test "truncate_preserve should be fine when truncateTable method doesn't support" do drop_test_table(@create_test_name) - admin.create(@create_test_name, 'a', {NUMREGIONS => 10, SPLITALGO => 'HexStringSplit'}) - splits = table(@create_test_name)._get_splits_internal() - $TEST_CLUSTER.getConfiguration.setBoolean("hbase.client.truncatetable.support", false) + admin.create(@create_test_name, 'a', NUMREGIONS => 10, SPLITALGO => 'HexStringSplit') + splits = table(@create_test_name)._get_splits_internal + $TEST_CLUSTER.getConfiguration.setBoolean('hbase.client.truncatetable.support', false) admin.truncate_preserve(@create_test_name, $TEST_CLUSTER.getConfiguration) - assert_equal(splits, table(@create_test_name)._get_splits_internal()) + assert_equal(splits, table(@create_test_name)._get_splits_internal) end #------------------------------------------------------------------------------- - define_test "list_regions should fail for disabled table" do + define_test 'list_regions should fail for disabled table' do drop_test_table(@create_test_name) admin.create(@create_test_name, 'a') command(:disable, @create_test_name) @@ -477,7 +477,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' drop_test_table(@test_name) create_test_table(@test_name) end @@ -486,15 +486,15 @@ module Hbase shutdown end - define_test "unassign should allow encoded region names" do + define_test 'unassign should allow encoded region names' do region = command(:locate_region, @test_name, '') - regionName = region.getRegionInfo().getRegionNameAsString() + regionName = region.getRegionInfo.getRegionNameAsString command(:unassign, regionName, true) end - define_test "unassign should allow non-encoded region names" do + define_test 'unassign should allow non-encoded region names' do region = command(:locate_region, @test_name, '') - encodedRegionName = region.getRegionInfo().getEncodedName() + encodedRegionName = region.getRegionInfo.getEncodedName command(:unassign, encodedRegionName, true) end end @@ -507,7 +507,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' drop_test_table(@test_name) create_test_table(@test_name) end @@ -518,38 +518,38 @@ module Hbase #------------------------------------------------------------------------------- - define_test "alter should fail with non-string table names" do + define_test 'alter should fail with non-string table names' do assert_raise(ArgumentError) do command(:alter, 123, METHOD => 'delete', NAME => 'y') end end - define_test "alter should fail with non-existing tables" do + define_test 'alter should fail with non-existing tables' do assert_raise(ArgumentError) do command(:alter, 'NOT.EXISTS', METHOD => 'delete', NAME => 'y') end end - define_test "alter should not fail with enabled tables" do + define_test 'alter should not fail with enabled tables' do command(:enable, @test_name) command(:alter, @test_name, METHOD => 'delete', NAME => 'y') end - define_test "alter should be able to delete column families" do + define_test 'alter should be able to delete column families' do assert_equal(['x:', 'y:'], table(@test_name).get_all_columns.sort) command(:alter, @test_name, METHOD => 'delete', NAME => 'y') command(:enable, @test_name) assert_equal(['x:'], table(@test_name).get_all_columns.sort) end - define_test "alter should be able to add column families" do + define_test 'alter should be able to add column families' do assert_equal(['x:', 'y:'], table(@test_name).get_all_columns.sort) command(:alter, @test_name, NAME => 'z') command(:enable, @test_name) assert_equal(['x:', 'y:', 'z:'], table(@test_name).get_all_columns.sort) end - define_test "alter should be able to add column families (name-only alter spec)" do + define_test 'alter should be able to add column families (name-only alter spec)' do assert_equal(['x:', 'y:'], table(@test_name).get_all_columns.sort) command(:alter, @test_name, 'z') command(:enable, @test_name) @@ -584,94 +584,94 @@ module Hbase assert_equal(['x:'], table(@test_name).get_all_columns.sort) end - define_test "alter should be able to change table options" do - command(:alter, @test_name, METHOD => 'table_att', 'MAX_FILESIZE' => 12345678) + define_test 'alter should be able to change table options' do + command(:alter, @test_name, METHOD => 'table_att', 'MAX_FILESIZE' => 12_345_678) assert_match(/12345678/, admin.describe(@test_name)) end - define_test "alter should be able to change table options w/o table_att" do - command(:alter, @test_name, 'MAX_FILESIZE' => 12345678) + define_test 'alter should be able to change table options w/o table_att' do + command(:alter, @test_name, 'MAX_FILESIZE' => 12_345_678) assert_match(/12345678/, admin.describe(@test_name)) end - define_test "alter should be able to change coprocessor attributes" do + define_test 'alter should be able to change coprocessor attributes' do drop_test_table(@test_name) create_test_table(@test_name) - cp_key = "coprocessor" - class_name = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver" + cp_key = 'coprocessor' + class_name = 'org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver' - cp_value = "|" + class_name + "|12|arg1=1,arg2=2" + cp_value = '|' + class_name + '|12|arg1=1,arg2=2' # eval() is used to convert a string to regex - assert_no_match(eval("/" + class_name + "/"), admin.describe(@test_name)) - assert_no_match(eval("/" + cp_key + "/"), admin.describe(@test_name)) + assert_no_match(eval('/' + class_name + '/'), admin.describe(@test_name)) + assert_no_match(eval('/' + cp_key + '/'), admin.describe(@test_name)) command(:alter, @test_name, 'METHOD' => 'table_att', cp_key => cp_value) - assert_match(eval("/" + class_name + "/"), admin.describe(@test_name)) - assert_match(eval("/" + cp_key + "\\$(\\d+)/"), admin.describe(@test_name)) + assert_match(eval('/' + class_name + '/'), admin.describe(@test_name)) + assert_match(eval('/' + cp_key + '\\$(\\d+)/'), admin.describe(@test_name)) end - define_test "alter should be able to remove a table attribute" do + define_test 'alter should be able to remove a table attribute' do drop_test_table(@test_name) create_test_table(@test_name) - key = "MAX_FILESIZE" - command(:alter, @test_name, 'METHOD' => 'table_att', key => 12345678) + key = 'MAX_FILESIZE' + command(:alter, @test_name, 'METHOD' => 'table_att', key => 12_345_678) # eval() is used to convert a string to regex - assert_match(eval("/" + key + "/"), admin.describe(@test_name)) + assert_match(eval('/' + key + '/'), admin.describe(@test_name)) command(:alter, @test_name, 'METHOD' => 'table_att_unset', 'NAME' => key) - assert_no_match(eval("/" + key + "/"), admin.describe(@test_name)) + assert_no_match(eval('/' + key + '/'), admin.describe(@test_name)) end - define_test "alter should be able to remove a list of table attributes" do + define_test 'alter should be able to remove a list of table attributes' do drop_test_table(@test_name) - key_1 = "TestAttr1" - key_2 = "TestAttr2" - command(:create, @test_name, { NAME => 'i'}, METADATA => { key_1 => 1, key_2 => 2 }) + key_1 = 'TestAttr1' + key_2 = 'TestAttr2' + command(:create, @test_name, { NAME => 'i' }, METADATA => { key_1 => 1, key_2 => 2 }) # eval() is used to convert a string to regex - assert_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) - assert_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + assert_match(eval('/' + key_1 + '/'), admin.describe(@test_name)) + assert_match(eval('/' + key_2 + '/'), admin.describe(@test_name)) - command(:alter, @test_name, 'METHOD' => 'table_att_unset', 'NAME' => [ key_1, key_2 ]) - assert_no_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) - assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + command(:alter, @test_name, 'METHOD' => 'table_att_unset', 'NAME' => [key_1, key_2]) + assert_no_match(eval('/' + key_1 + '/'), admin.describe(@test_name)) + assert_no_match(eval('/' + key_2 + '/'), admin.describe(@test_name)) end - define_test "alter should be able to remove a table configuration" do + define_test 'alter should be able to remove a table configuration' do drop_test_table(@test_name) create_test_table(@test_name) - key = "TestConf" - command(:alter, @test_name, CONFIGURATION => {key => 1}) + key = 'TestConf' + command(:alter, @test_name, CONFIGURATION => { key => 1 }) # eval() is used to convert a string to regex - assert_match(eval("/" + key + "/"), admin.describe(@test_name)) + assert_match(eval('/' + key + '/'), admin.describe(@test_name)) command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => key) - assert_no_match(eval("/" + key + "/"), admin.describe(@test_name)) + assert_no_match(eval('/' + key + '/'), admin.describe(@test_name)) end - define_test "alter should be able to remove a list of table configuration" do + define_test 'alter should be able to remove a list of table configuration' do drop_test_table(@test_name) - key_1 = "TestConf1" - key_2 = "TestConf2" - command(:create, @test_name, { NAME => 'i'}, CONFIGURATION => { key_1 => 1, key_2 => 2 }) + key_1 = 'TestConf1' + key_2 = 'TestConf2' + command(:create, @test_name, { NAME => 'i' }, CONFIGURATION => { key_1 => 1, key_2 => 2 }) # eval() is used to convert a string to regex - assert_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) - assert_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + assert_match(eval('/' + key_1 + '/'), admin.describe(@test_name)) + assert_match(eval('/' + key_2 + '/'), admin.describe(@test_name)) - command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => [ key_1, key_2 ]) - assert_no_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) - assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => [key_1, key_2]) + assert_no_match(eval('/' + key_1 + '/'), admin.describe(@test_name)) + assert_no_match(eval('/' + key_2 + '/'), admin.describe(@test_name)) end - define_test "get_table should get a real table" do + define_test 'get_table should get a real table' do drop_test_table(@test_name) create_test_table(@test_name) diff --git a/hbase-shell/src/test/ruby/hbase/hbase_test.rb b/hbase-shell/src/test/ruby/hbase/hbase_test.rb index 0f192344a399b29f43522c7c15db0b46d3f865e6..fd60e807a7be693ca53cc998bd943dbb262ed15f 100644 --- a/hbase-shell/src/test/ruby/hbase/hbase_test.rb +++ b/hbase-shell/src/test/ruby/hbase/hbase_test.rb @@ -25,23 +25,23 @@ module Hbase @hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) end - define_test "Hbase::Hbase constructor should initialize hbase configuration object" do + define_test 'Hbase::Hbase constructor should initialize hbase configuration object' do assert_kind_of(org.apache.hadoop.conf.Configuration, @hbase.configuration) end - define_test "Hbase::Hbase#admin should create a new admin object when called the first time" do - assert_kind_of(::Hbase::Admin, @hbase.admin()) + define_test 'Hbase::Hbase#admin should create a new admin object when called the first time' do + assert_kind_of(::Hbase::Admin, @hbase.admin) end - define_test "Hbase::Hbase#admin should create a new admin object every call" do - assert_not_same(@hbase.admin(), @hbase.admin()) + define_test 'Hbase::Hbase#admin should create a new admin object every call' do + assert_not_same(@hbase.admin, @hbase.admin) end - define_test "Hbase::Hbase#table should create a new table object when called the first time" do + define_test 'Hbase::Hbase#table should create a new table object when called the first time' do assert_kind_of(::Hbase::Table, @hbase.table('hbase:meta', @shell)) end - define_test "Hbase::Hbase#table should create a new table object every call" do + define_test 'Hbase::Hbase#table should create a new table object every call' do assert_not_same(@hbase.table('hbase:meta', @shell), @hbase.table('hbase:meta', @shell)) end end diff --git a/hbase-shell/src/test/ruby/hbase/quotas_test.rb b/hbase-shell/src/test/ruby/hbase/quotas_test.rb index 1bcc07b7e58939f7ae9ce8e62ee9564c672931ad..b533d67d1df0014075104a6ed26e1b30a3e00542 100644 --- a/hbase-shell/src/test/ruby/hbase/quotas_test.rb +++ b/hbase-shell/src/test/ruby/hbase/quotas_test.rb @@ -33,7 +33,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_quota_tests_table" + @test_name = 'hbase_shell_quota_tests_table' create_test_table(@test_name) end @@ -42,22 +42,22 @@ module Hbase end define_test 'limit_space errors on non Hash argument' do - qa = quotas_admin() + qa = quotas_admin assert_raise(ArgumentError) do qa.limit_space('foo') end assert_raise(ArgumentError) do - qa.limit_space() + qa.limit_space end end define_test 'remove_space_limit errors on non Hash argument' do - qa = quotas_admin() + qa = quotas_admin assert_raise(ArgumentError) do qa.remove_space_limit('foo') end assert_raise(ArgumentError) do - qa.remove_space_limit() + qa.remove_space_limit end end @@ -173,21 +173,21 @@ module Hbase define_test 'table and namespace are mutually exclusive in set quota' do assert_raise(ArgumentError) do - command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, TABLE => @test_name, NAMESPACE => "foo") + command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, TABLE => @test_name, NAMESPACE => 'foo') end end define_test 'can set and remove quota' do command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, TABLE => @test_name) - output = capture_stdout{ command(:list_quotas) } - assert(output.include?("LIMIT => 1G")) - assert(output.include?("VIOLATION_POLICY => NO_INSERTS")) - assert(output.include?("TYPE => SPACE")) + output = capture_stdout { command(:list_quotas) } + assert(output.include?('LIMIT => 1G')) + assert(output.include?('VIOLATION_POLICY => NO_INSERTS')) + assert(output.include?('TYPE => SPACE')) assert(output.include?("TABLE => #{@test_name}")) command(:set_quota, TYPE => SPACE, LIMIT => NONE, TABLE => @test_name) - output = capture_stdout{ command(:list_quotas) } - assert(output.include?("0 row(s)")) + output = capture_stdout { command(:list_quotas) } + assert(output.include?('0 row(s)')) end define_test 'can view size of snapshots' do @@ -195,52 +195,51 @@ module Hbase snapshot2 = "#{@test_name}_2" # Set a quota on our table command(:set_quota, TYPE => SPACE, LIMIT => '1G', POLICY => NO_INSERTS, TABLE => @test_name) - (1..10).each{|i| command(:put, @test_name, 'a', "x:#{i}", "#{i}")} + (1..10).each { |i| command(:put, @test_name, 'a', "x:#{i}", i.to_s) } command(:flush, @test_name) command(:snapshot, @test_name, snapshot1) - (1..10).each{|i| command(:put, @test_name, 'b', "x:#{i}", "#{i}")} + (1..10).each { |i| command(:put, @test_name, 'b', "x:#{i}", i.to_s) } command(:flush, @test_name) command(:snapshot, @test_name, snapshot2) duration_to_check = 1000 * 30 start = current = Time.now.to_i # Poor man's Waiter from Java test classes while current - start < duration_to_check - output = capture_stdout{ command(:list_snapshot_sizes) } - if output.include? snapshot1 and output.include? snapshot2 - break - end + output = capture_stdout { command(:list_snapshot_sizes) } + break if output.include?(snapshot1) && output.include?(snapshot2) + sleep 5 current = Time.now.to_i end - output = capture_stdout{ command(:list_snapshot_sizes) } - assert(output.include? snapshot1) - assert(output.include? snapshot2) + output = capture_stdout { command(:list_snapshot_sizes) } + assert(output.include?(snapshot1)) + assert(output.include?(snapshot2)) end define_test 'can set and remove user CU quota' do command(:set_quota, TYPE => THROTTLE, USER => 'user1', LIMIT => '1CU/sec') - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('USER => user1')) assert(output.include?('TYPE => THROTTLE')) assert(output.include?('THROTTLE_TYPE => REQUEST_CAPACITY_UNIT')) assert(output.include?('LIMIT => 1CU/sec')) command(:set_quota, TYPE => THROTTLE, USER => 'user1', LIMIT => NONE) - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('0 row(s)')) end define_test 'can set and remove table CU quota' do command(:set_quota, TYPE => THROTTLE, TABLE => @test_name, - THROTTLE_TYPE => WRITE, LIMIT => '2CU/min') - output = capture_stdout{ command(:list_quotas) } + THROTTLE_TYPE => WRITE, LIMIT => '2CU/min') + output = capture_stdout { command(:list_quotas) } assert(output.include?('TABLE => hbase_shell_quota_tests_table')) assert(output.include?('TYPE => THROTTLE')) assert(output.include?('THROTTLE_TYPE => WRITE_CAPACITY_UNIT')) assert(output.include?('LIMIT => 2CU/min')) command(:set_quota, TYPE => THROTTLE, TABLE => @test_name, LIMIT => NONE) - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('0 row(s)')) end @@ -254,14 +253,14 @@ module Hbase define_test 'can set and remove region server quota' do command(:set_quota, TYPE => THROTTLE, REGIONSERVER => 'all', LIMIT => '1CU/sec') - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('REGIONSERVER => all')) assert(output.include?('TYPE => THROTTLE')) assert(output.include?('THROTTLE_TYPE => REQUEST_CAPACITY_UNIT')) assert(output.include?('LIMIT => 1CU/sec')) command(:set_quota, TYPE => THROTTLE, REGIONSERVER => 'all', THROTTLE_TYPE => WRITE, LIMIT => '2req/sec') - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('REGIONSERVER => all')) assert(output.include?('TYPE => THROTTLE')) assert(output.include?('THROTTLE_TYPE => WRITE')) @@ -269,7 +268,7 @@ module Hbase assert(output.include?('LIMIT => 2req/sec')) command(:set_quota, TYPE => THROTTLE, REGIONSERVER => 'all', LIMIT => NONE) - output = capture_stdout{ command(:list_quotas) } + output = capture_stdout { command(:list_quotas) } assert(output.include?('0 row(s)')) end end diff --git a/hbase-shell/src/test/ruby/hbase/quotas_test_no_cluster.rb b/hbase-shell/src/test/ruby/hbase/quotas_test_no_cluster.rb index 7de122553ffdc8a1269fbfbfd1d4e3c9cd2e87a8..d71e7d81b09772b6176ce6afe2acb2e440d8b465 100644 --- a/hbase-shell/src/test/ruby/hbase/quotas_test_no_cluster.rb +++ b/hbase-shell/src/test/ruby/hbase/quotas_test_no_cluster.rb @@ -40,25 +40,25 @@ module Hbase GIGA = MEGA * KILO TERA = GIGA * KILO PETA = TERA * KILO - assert_equal(1, qa._parse_size("1")) - assert_equal(1, qa._parse_size("1b")) - assert_equal(1, qa._parse_size("1B")) - assert_equal(KILO * 2, qa._parse_size("2k")) - assert_equal(KILO * 2, qa._parse_size("2K")) - assert_equal(MEGA * 5, qa._parse_size("5m")) - assert_equal(MEGA * 5, qa._parse_size("5M")) - assert_equal(GIGA * 3, qa._parse_size("3g")) - assert_equal(GIGA * 3, qa._parse_size("3G")) - assert_equal(TERA * 4, qa._parse_size("4t")) - assert_equal(TERA * 4, qa._parse_size("4T")) - assert_equal(PETA * 32, qa._parse_size("32p")) - assert_equal(PETA * 32, qa._parse_size("32P")) - assert_equal(GIGA * 4, qa._parse_size("4096m")) - assert_equal(GIGA * 4, qa._parse_size("4096M")) + assert_equal(1, qa._parse_size('1')) + assert_equal(1, qa._parse_size('1b')) + assert_equal(1, qa._parse_size('1B')) + assert_equal(KILO * 2, qa._parse_size('2k')) + assert_equal(KILO * 2, qa._parse_size('2K')) + assert_equal(MEGA * 5, qa._parse_size('5m')) + assert_equal(MEGA * 5, qa._parse_size('5M')) + assert_equal(GIGA * 3, qa._parse_size('3g')) + assert_equal(GIGA * 3, qa._parse_size('3G')) + assert_equal(TERA * 4, qa._parse_size('4t')) + assert_equal(TERA * 4, qa._parse_size('4T')) + assert_equal(PETA * 32, qa._parse_size('32p')) + assert_equal(PETA * 32, qa._parse_size('32P')) + assert_equal(GIGA * 4, qa._parse_size('4096m')) + assert_equal(GIGA * 4, qa._parse_size('4096M')) end define_test 'get policy name for status not in violation' do - okStatus = SpaceQuotaSnapshot::SpaceQuotaStatus::notInViolation() + okStatus = SpaceQuotaSnapshot::SpaceQuotaStatus.notInViolation # By default, statuses are in violation violatedStatus = SpaceQuotaSnapshot::SpaceQuotaStatus.new(SpaceViolationPolicy::NO_INSERTS) # Pass in nil for the Shell instance (that we don't care about) diff --git a/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb b/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb index 7f5400f6994b79ab4883f6857dc69c59e04e958d..fc2eda600d8ffa673042a801b17ed065a389dca2 100644 --- a/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/replication_admin_test.rb @@ -51,14 +51,14 @@ module Hbase end end - define_test "add_peer: fail when neither CLUSTER_KEY nor ENDPOINT_CLASSNAME are specified" do + define_test 'add_peer: fail when neither CLUSTER_KEY nor ENDPOINT_CLASSNAME are specified' do assert_raise(ArgumentError) do args = {} command(:add_peer, @peer_id, args) end end - define_test "add_peer: args must be a hash" do + define_test 'add_peer: args must be a hash' do assert_raise(ArgumentError) do command(:add_peer, @peer_id, 1) end @@ -70,10 +70,10 @@ module Hbase end end - define_test "add_peer: single zk cluster key" do - cluster_key = "server1.cie.com:2181:/hbase" + define_test 'add_peer: single zk cluster key' do + cluster_key = 'server1.cie.com:2181:/hbase' - command(:add_peer, @peer_id, {CLUSTER_KEY => cluster_key}) + command(:add_peer, @peer_id, CLUSTER_KEY => cluster_key) assert_equal(1, command(:list_peers).length) peer = command(:list_peers).get(0) @@ -85,10 +85,10 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: multiple zk cluster key" do - cluster_key = "zk1,zk2,zk3:2182:/hbase-prod" + define_test 'add_peer: multiple zk cluster key' do + cluster_key = 'zk1,zk2,zk3:2182:/hbase-prod' - command(:add_peer, @peer_id, {CLUSTER_KEY => cluster_key}) + command(:add_peer, @peer_id, CLUSTER_KEY => cluster_key) assert_equal(1, command(:list_peers).length) peer = command(:list_peers).get(0) @@ -100,14 +100,14 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: serial" do - cluster_key = "server1.cie.com:2181:/hbase" - remote_wal_dir = "hdfs://srv1:9999/hbase" - table_cfs = { "ns3:table1" => [], "ns3:table2" => [], - "ns3:table3" => [] } + define_test 'add_peer: serial' do + cluster_key = 'server1.cie.com:2181:/hbase' + remote_wal_dir = 'hdfs://srv1:9999/hbase' + table_cfs = { 'ns3:table1' => [], 'ns3:table2' => [], + 'ns3:table3' => [] } # add a new replication peer which serial flag is true args = { CLUSTER_KEY => cluster_key, SERIAL => true, - TABLE_CFS => table_cfs} + TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) @@ -115,19 +115,19 @@ module Hbase assert_equal(@peer_id, peer.getPeerId) assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) assert_equal(true, peer.getPeerConfig.isSerial) - assert_tablecfs_equal(table_cfs, peer.getPeerConfig.getTableCFsMap()) + assert_tablecfs_equal(table_cfs, peer.getPeerConfig.getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) end - define_test "add_peer: remote wal dir" do - cluster_key = "server1.cie.com:2181:/hbase" - remote_wal_dir = "hdfs://srv1:9999/hbase" - table_cfs = { "ns3:table1" => [], "ns3:table2" => [], - "ns3:table3" => [] } + define_test 'add_peer: remote wal dir' do + cluster_key = 'server1.cie.com:2181:/hbase' + remote_wal_dir = 'hdfs://srv1:9999/hbase' + table_cfs = { 'ns3:table1' => [], 'ns3:table2' => [], + 'ns3:table3' => [] } args = { CLUSTER_KEY => cluster_key, REMOTE_WAL_DIR => remote_wal_dir, - TABLE_CFS => table_cfs} + TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) @@ -135,14 +135,14 @@ module Hbase assert_equal(@peer_id, peer.getPeerId) assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) assert_equal(remote_wal_dir, peer.getPeerConfig.getRemoteWALDir) - assert_tablecfs_equal(table_cfs, peer.getPeerConfig.getTableCFsMap()) + assert_tablecfs_equal(table_cfs, peer.getPeerConfig.getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) end - define_test "add_peer: single zk cluster key with enabled/disabled state" do - cluster_key = "server1.cie.com:2181:/hbase" + define_test 'add_peer: single zk cluster key with enabled/disabled state' do + cluster_key = 'server1.cie.com:2181:/hbase' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) @@ -172,8 +172,8 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: multiple zk cluster key - peer config" do - cluster_key = "zk1,zk2,zk3:2182:/hbase-prod" + define_test 'add_peer: multiple zk cluster key - peer config' do + cluster_key = 'zk1,zk2,zk3:2182:/hbase-prod' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) @@ -188,10 +188,10 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: multiple zk cluster key and namespaces" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - namespaces = ["ns1", "ns2", "ns3"] - namespaces_str = "ns1;ns2;ns3" + define_test 'add_peer: multiple zk cluster key and namespaces' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + namespaces = %w[ns1 ns2 ns3] + namespaces_str = 'ns1;ns2;ns3' args = { CLUSTER_KEY => cluster_key, NAMESPACES => namespaces } command(:add_peer, @peer_id, args) @@ -209,15 +209,15 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: multiple zk cluster key and namespaces, table_cfs" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - namespaces = ["ns1", "ns2"] - table_cfs = { "ns3:table1" => [], "ns3:table2" => ["cf1"], - "ns3:table3" => ["cf1", "cf2"] } - namespaces_str = "ns1;ns2" + define_test 'add_peer: multiple zk cluster key and namespaces, table_cfs' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + namespaces = %w[ns1 ns2] + table_cfs = { 'ns3:table1' => [], 'ns3:table2' => ['cf1'], + 'ns3:table3' => %w[cf1 cf2] } + namespaces_str = 'ns1;ns2' args = { CLUSTER_KEY => cluster_key, NAMESPACES => namespaces, - TABLE_CFS => table_cfs } + TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) @@ -227,8 +227,8 @@ module Hbase assert_equal(false, peer_config.replicateAllUserTables) assert_equal(cluster_key, peer_config.get_cluster_key) assert_equal(namespaces_str, - replication_admin.show_peer_namespaces(peer_config)) - assert_tablecfs_equal(table_cfs, peer_config.getTableCFsMap()) + replication_admin.show_peer_namespaces(peer_config)) + assert_tablecfs_equal(table_cfs, peer_config.getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) @@ -236,22 +236,22 @@ module Hbase def assert_tablecfs_equal(table_cfs, table_cfs_map) assert_equal(table_cfs.length, table_cfs_map.length) - table_cfs_map.each{|key, value| - assert(table_cfs.has_key?(key.getNameAsString)) - if table_cfs.fetch(key.getNameAsString).length == 0 + table_cfs_map.each do |key, value| + assert(table_cfs.key?(key.getNameAsString)) + if table_cfs.fetch(key.getNameAsString).empty? assert_equal(nil, value) else assert_equal(table_cfs.fetch(key.getNameAsString).length, value.length) - value.each{|v| + value.each do |v| assert(table_cfs.fetch(key.getNameAsString).include?(v)) - } + end end - } + end end - define_test "add_peer: multiple zk cluster key and table_cfs - peer config" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - table_cfs = { "table1" => [], "table2" => ["cf1"], "table3" => ["cf1", "cf2"] } + define_test 'add_peer: multiple zk cluster key and table_cfs - peer config' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + table_cfs = { 'table1' => [], 'table2' => ['cf1'], 'table3' => %w[cf1 cf2] } args = { CLUSTER_KEY => cluster_key, TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) @@ -267,9 +267,9 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "add_peer: should fail when args is a hash and peer_tableCFs provided" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - table_cfs_str = "table1;table2:cf1;table3:cf1,cf2" + define_test 'add_peer: should fail when args is a hash and peer_tableCFs provided' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + table_cfs_str = 'table1;table2:cf1;table3:cf1,cf2' assert_raise(ArgumentError) do args = { CLUSTER_KEY => cluster_key } @@ -277,9 +277,9 @@ module Hbase end end - define_test "set_peer_tableCFs: works with table-cfs map" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - args = { CLUSTER_KEY => cluster_key} + define_test 'set_peer_tableCFs: works with table-cfs map' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) command(:set_peer_replicate_all, @peer_id, false) @@ -288,17 +288,17 @@ module Hbase assert_equal(@peer_id, peer.getPeerId) assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) - table_cfs = { "table1" => [], "table2" => ["cf1"], "ns3:table3" => ["cf1", "cf2"] } + table_cfs = { 'table1' => [], 'table2' => ['cf1'], 'ns3:table3' => %w[cf1 cf2] } command(:set_peer_tableCFs, @peer_id, table_cfs) - assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap()) + assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) end - define_test "append_peer_tableCFs: works with table-cfs map" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - args = { CLUSTER_KEY => cluster_key} + define_test 'append_peer_tableCFs: works with table-cfs map' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) command(:set_peer_replicate_all, @peer_id, false) @@ -307,21 +307,21 @@ module Hbase assert_equal(@peer_id, peer.getPeerId) assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) - table_cfs = { "table1" => [], "ns2:table2" => ["cf1"] } + table_cfs = { 'table1' => [], 'ns2:table2' => ['cf1'] } command(:append_peer_tableCFs, @peer_id, table_cfs) - assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap()) + assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap) - table_cfs = { "table1" => [], "ns2:table2" => ["cf1"], "ns3:table3" => ["cf1", "cf2"] } - command(:append_peer_tableCFs, @peer_id, { "ns3:table3" => ["cf1", "cf2"] }) - assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap()) + table_cfs = { 'table1' => [], 'ns2:table2' => ['cf1'], 'ns3:table3' => %w[cf1 cf2] } + command(:append_peer_tableCFs, @peer_id, 'ns3:table3' => %w[cf1 cf2]) + assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) end - define_test "remove_peer_tableCFs: works with table-cfs map" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - table_cfs = { "table1" => [], "ns2:table2" => ["cf1"], "ns3:table3" => ["cf1", "cf2"] } + define_test 'remove_peer_tableCFs: works with table-cfs map' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + table_cfs = { 'table1' => [], 'ns2:table2' => ['cf1'], 'ns3:table3' => %w[cf1 cf2] } args = { CLUSTER_KEY => cluster_key, TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) @@ -330,9 +330,9 @@ module Hbase assert_equal(@peer_id, peer.getPeerId) assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) - table_cfs = { "table1" => [], "ns2:table2" => ["cf1"] } - command(:remove_peer_tableCFs, @peer_id, { "ns3:table3" => ["cf1", "cf2"] }) - assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap()) + table_cfs = { 'table1' => [], 'ns2:table2' => ['cf1'] } + command(:remove_peer_tableCFs, @peer_id, 'ns3:table3' => %w[cf1 cf2]) + assert_tablecfs_equal(table_cfs, command(:get_peer_config, @peer_id).getTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) @@ -349,7 +349,7 @@ module Hbase assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) table_cfs = { 'table1' => [], 'table2' => ['cf1'], - 'ns3:table3' => ['cf1', 'cf2'] } + 'ns3:table3' => %w[cf1 cf2] } command(:set_peer_exclude_tableCFs, @peer_id, table_cfs) assert_equal(1, command(:list_peers).length) peer = command(:list_peers).get(0) @@ -361,9 +361,9 @@ module Hbase replication_admin.remove_peer(@peer_id) end - define_test "append_peer_exclude_tableCFs: works with exclude table-cfs map" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - args = {CLUSTER_KEY => cluster_key} + define_test 'append_peer_exclude_tableCFs: works with exclude table-cfs map' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) peer = command(:list_peers).get(0) @@ -371,26 +371,26 @@ module Hbase assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) # set exclude-table-cfs - exclude_table_cfs = {"table1" => [], "ns2:table2" => ["cf1", "cf2"]} + exclude_table_cfs = { 'table1' => [], 'ns2:table2' => %w[cf1 cf2] } command(:set_peer_exclude_tableCFs, @peer_id, exclude_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # append empty exclude-table-cfs append_table_cfs = {} command(:append_peer_exclude_tableCFs, @peer_id, append_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # append exclude-table-cfs which don't exist in peer' exclude-table-cfs - append_table_cfs = {"table3" => ["cf3"]} - exclude_table_cfs = {"table1" => [], "ns2:table2" => ["cf1", "cf2"], "table3" => ["cf3"]} + append_table_cfs = { 'table3' => ['cf3'] } + exclude_table_cfs = { 'table1' => [], 'ns2:table2' => %w[cf1 cf2], 'table3' => ['cf3'] } command(:append_peer_exclude_tableCFs, @peer_id, append_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # append exclude-table-cfs which exist in peer' exclude-table-cfs - append_table_cfs = {"table1" => ["cf1"], "ns2:table2" => ["cf1", "cf3"], "table3" => []} - exclude_table_cfs = {"table1" => [], "ns2:table2" => ["cf1", "cf2", "cf3"], "table3" => []} + append_table_cfs = { 'table1' => ['cf1'], 'ns2:table2' => %w[cf1 cf3], 'table3' => [] } + exclude_table_cfs = { 'table1' => [], 'ns2:table2' => %w[cf1 cf2 cf3], 'table3' => [] } command(:append_peer_exclude_tableCFs, @peer_id, append_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # cleanup for future tests command(:remove_peer, @peer_id) @@ -398,7 +398,7 @@ module Hbase define_test 'remove_peer_exclude_tableCFs: works with exclude table-cfs map' do cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' - args = {CLUSTER_KEY => cluster_key} + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) peer = command(:list_peers).get(0) @@ -406,35 +406,35 @@ module Hbase assert_equal(cluster_key, peer.getPeerConfig.getClusterKey) # set exclude-table-cfs - exclude_table_cfs = {'table1' => [], 'table2' => ['cf1'], 'ns3:table3' => ['cf1', 'cf2']} + exclude_table_cfs = { 'table1' => [], 'table2' => ['cf1'], 'ns3:table3' => %w[cf1 cf2] } command(:set_peer_exclude_tableCFs, @peer_id, exclude_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # remove empty exclude-table-cfs remove_table_cfs = {} command(:remove_peer_exclude_tableCFs, @peer_id, remove_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # remove exclude-table-cfs which exist in pees' exclude table cfs - remove_table_cfs = {'table1' => [], 'table2' => ['cf1']} - exclude_table_cfs = {'ns3:table3' => ['cf1', 'cf2']} + remove_table_cfs = { 'table1' => [], 'table2' => ['cf1'] } + exclude_table_cfs = { 'ns3:table3' => %w[cf1 cf2] } command(:remove_peer_exclude_tableCFs, @peer_id, remove_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # remove exclude-table-cfs which exist in pees' exclude-table-cfs - remove_table_cfs = {'ns3:table3' => ['cf2', 'cf3']} - exclude_table_cfs = {'ns3:table3' => ['cf1']} + remove_table_cfs = { 'ns3:table3' => %w[cf2 cf3] } + exclude_table_cfs = { 'ns3:table3' => ['cf1'] } command(:remove_peer_exclude_tableCFs, @peer_id, remove_table_cfs) - assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap()) + assert_tablecfs_equal(exclude_table_cfs, command(:get_peer_config, @peer_id).getExcludeTableCFsMap) # cleanup for future tests replication_admin.remove_peer(@peer_id) end - define_test "set_peer_namespaces: works with namespaces array" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - namespaces = ["ns1", "ns2"] - namespaces_str = "ns1;ns2" + define_test 'set_peer_namespaces: works with namespaces array' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + namespaces = %w[ns1 ns2] + namespaces_str = 'ns1;ns2' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) @@ -452,10 +452,10 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "append_peer_namespaces: works with namespaces array" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - namespaces = ["ns1", "ns2"] - namespaces_str = "ns1;ns2" + define_test 'append_peer_namespaces: works with namespaces array' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + namespaces = %w[ns1 ns2] + namespaces_str = 'ns1;ns2' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) @@ -469,8 +469,8 @@ module Hbase assert_equal(namespaces_str, replication_admin.show_peer_namespaces(peer_config)) - namespaces = ["ns3"] - namespaces_str = "ns1;ns2;ns3" + namespaces = ['ns3'] + namespaces_str = 'ns1;ns2;ns3' command(:append_peer_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) @@ -492,15 +492,15 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "remove_peer_namespaces: works with namespaces array" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - namespaces = ["ns1", "ns2", "ns3"] + define_test 'remove_peer_namespaces: works with namespaces array' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + namespaces = %w[ns1 ns2 ns3] args = { CLUSTER_KEY => cluster_key, NAMESPACES => namespaces } command(:add_peer, @peer_id, args) - namespaces = ["ns1", "ns2"] - namespaces_str = "ns3" + namespaces = %w[ns1 ns2] + namespaces_str = 'ns3' command(:remove_peer_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) @@ -509,7 +509,7 @@ module Hbase assert_equal(namespaces_str, replication_admin.show_peer_namespaces(peer_config)) - namespaces = ["ns3"] + namespaces = ['ns3'] namespaces_str = nil command(:remove_peer_namespaces, @peer_id, namespaces) @@ -534,7 +534,7 @@ module Hbase define_test 'set_peer_exclude_namespaces: works with namespaces array' do cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' - namespaces = ['ns1', 'ns2'] + namespaces = %w[ns1 ns2] namespaces_str = '!ns1;ns2' args = { CLUSTER_KEY => cluster_key } @@ -597,28 +597,28 @@ module Hbase assert_equal(0, command(:list_peers).length) end - define_test "set_peer_bandwidth: works with peer bandwidth upper limit" do - cluster_key = "localhost:2181:/hbase-test" + define_test 'set_peer_bandwidth: works with peer bandwidth upper limit' do + cluster_key = 'localhost:2181:/hbase-test' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) peer_config = command(:get_peer_config, @peer_id) assert_equal(0, peer_config.get_bandwidth) - command(:set_peer_bandwidth, @peer_id, 2097152) + command(:set_peer_bandwidth, @peer_id, 2_097_152) peer_config = command(:get_peer_config, @peer_id) - assert_equal(2097152, peer_config.get_bandwidth) + assert_equal(2_097_152, peer_config.get_bandwidth) - #cleanup + # cleanup command(:remove_peer, @peer_id) end - define_test "transit_peer_sync_replication_state: test" do - cluster_key = "server1.cie.com:2181:/hbase" - remote_wal_dir = "hdfs://srv1:9999/hbase" - table_cfs = { "ns3:table1" => [], "ns3:table2" => [], - "ns3:table3" => [] } + define_test 'transit_peer_sync_replication_state: test' do + cluster_key = 'server1.cie.com:2181:/hbase' + remote_wal_dir = 'hdfs://srv1:9999/hbase' + table_cfs = { 'ns3:table1' => [], 'ns3:table2' => [], + 'ns3:table3' => [] } args = { CLUSTER_KEY => cluster_key, REMOTE_WAL_DIR => remote_wal_dir, - TABLE_CFS => table_cfs} + TABLE_CFS => table_cfs } command(:add_peer, @peer_id, args) assert_equal(1, command(:list_peers).length) @@ -643,20 +643,20 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "get_peer_config: works with simple clusterKey peer" do - cluster_key = "localhost:2181:/hbase-test" + define_test 'get_peer_config: works with simple clusterKey peer' do + cluster_key = 'localhost:2181:/hbase-test' args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) peer_config = command(:get_peer_config, @peer_id) assert_equal(cluster_key, peer_config.get_cluster_key) - #cleanup + # cleanup command(:remove_peer, @peer_id) end - define_test "get_peer_config: works with replicationendpointimpl peer and config params" do + define_test 'get_peer_config: works with replicationendpointimpl peer and config params' do cluster_key = 'localhost:2181:/hbase-test' repl_impl = 'org.apache.hadoop.hbase.replication.ReplicationEndpointForTest' - config_params = { "config1" => "value1", "config2" => "value2" } + config_params = { 'config1' => 'value1', 'config2' => 'value2' } args = { CLUSTER_KEY => cluster_key, ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params } command(:add_peer, @peer_id, args) @@ -664,61 +664,61 @@ module Hbase assert_equal(cluster_key, peer_config.get_cluster_key) assert_equal(repl_impl, peer_config.get_replication_endpoint_impl) assert_equal(2, peer_config.get_configuration.size) - assert_equal("value1", peer_config.get_configuration.get("config1")) - #cleanup + assert_equal('value1', peer_config.get_configuration.get('config1')) + # cleanup command(:remove_peer, @peer_id) end define_test "list_peer_configs: returns all peers' ReplicationPeerConfig objects" do - cluster_key = "localhost:2181:/hbase-test" + cluster_key = 'localhost:2181:/hbase-test' args = { CLUSTER_KEY => cluster_key } peer_id_second = '2' command(:add_peer, @peer_id, args) - repl_impl = "org.apache.hadoop.hbase.replication.ReplicationEndpointForTest" - config_params = { "config1" => "value1", "config2" => "value2" } - args2 = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params} + repl_impl = 'org.apache.hadoop.hbase.replication.ReplicationEndpointForTest' + config_params = { 'config1' => 'value1', 'config2' => 'value2' } + args2 = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params } command(:add_peer, peer_id_second, args2) peer_configs = command(:list_peer_configs) assert_equal(2, peer_configs.size) assert_equal(cluster_key, peer_configs.get(@peer_id).get_cluster_key) assert_equal(repl_impl, peer_configs.get(peer_id_second).get_replication_endpoint_impl) - #cleanup + # cleanup command(:remove_peer, @peer_id) command(:remove_peer, peer_id_second) end - define_test "update_peer_config: can update peer config and data" do - repl_impl = "org.apache.hadoop.hbase.replication.ReplicationEndpointForTest" - config_params = { "config1" => "value1", "config2" => "value2" } - data_params = {"data1" => "value1", "data2" => "value2"} - args = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params, DATA => data_params} + define_test 'update_peer_config: can update peer config and data' do + repl_impl = 'org.apache.hadoop.hbase.replication.ReplicationEndpointForTest' + config_params = { 'config1' => 'value1', 'config2' => 'value2' } + data_params = { 'data1' => 'value1', 'data2' => 'value2' } + args = { ENDPOINT_CLASSNAME => repl_impl, CONFIG => config_params, DATA => data_params } command(:add_peer, @peer_id, args) - new_config_params = { "config1" => "new_value1" } - new_data_params = {"data1" => "new_value1"} - new_args = {CONFIG => new_config_params, DATA => new_data_params} + new_config_params = { 'config1' => 'new_value1' } + new_data_params = { 'data1' => 'new_value1' } + new_args = { CONFIG => new_config_params, DATA => new_data_params } command(:update_peer_config, @peer_id, new_args) - #Make sure the updated key/value pairs in config and data were successfully updated, and that those we didn't - #update are still there and unchanged + # Make sure the updated key/value pairs in config and data were successfully updated, and that those we didn't + # update are still there and unchanged peer_config = command(:get_peer_config, @peer_id) command(:remove_peer, @peer_id) - assert_equal("new_value1", peer_config.get_configuration.get("config1")) - assert_equal("value2", peer_config.get_configuration.get("config2")) - assert_equal("new_value1", Bytes.to_string(peer_config.get_peer_data.get(Bytes.toBytes("data1")))) - assert_equal("value2", Bytes.to_string(peer_config.get_peer_data.get(Bytes.toBytes("data2")))) + assert_equal('new_value1', peer_config.get_configuration.get('config1')) + assert_equal('value2', peer_config.get_configuration.get('config2')) + assert_equal('new_value1', Bytes.to_string(peer_config.get_peer_data.get(Bytes.toBytes('data1')))) + assert_equal('value2', Bytes.to_string(peer_config.get_peer_data.get(Bytes.toBytes('data2')))) end - define_test "append_peer_exclude_namespaces: works with namespaces array" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - args = {CLUSTER_KEY => cluster_key} + define_test 'append_peer_exclude_namespaces: works with namespaces array' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) command(:set_peer_replicate_all, @peer_id, true) - namespaces = ["ns1", "ns2"] - namespaces_str = "!ns1;ns2" + namespaces = %w[ns1 ns2] + namespaces_str = '!ns1;ns2' command(:append_peer_exclude_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) assert_equal(@peer_id, command(:list_peers).get(0).getPeerId) @@ -726,8 +726,8 @@ module Hbase assert_equal(namespaces_str, replication_admin.show_peer_exclude_namespaces(peer_config)) - namespaces = ["ns3"] - namespaces_str = "!ns1;ns2;ns3" + namespaces = ['ns3'] + namespaces_str = '!ns1;ns2;ns3' command(:append_peer_exclude_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) assert_equal(@peer_id, command(:list_peers).get(0).getPeerId) @@ -747,16 +747,16 @@ module Hbase command(:remove_peer, @peer_id) end - define_test "remove_peer_exclude_namespaces: works with namespaces array" do - cluster_key = "zk4,zk5,zk6:11000:/hbase-test" - args = {CLUSTER_KEY => cluster_key} + define_test 'remove_peer_exclude_namespaces: works with namespaces array' do + cluster_key = 'zk4,zk5,zk6:11000:/hbase-test' + args = { CLUSTER_KEY => cluster_key } command(:add_peer, @peer_id, args) - namespaces = ["ns1", "ns2", "ns3"] + namespaces = %w[ns1 ns2 ns3] command(:set_peer_exclude_namespaces, @peer_id, namespaces) - namespaces = ["ns1", "ns2"] - namespaces_str = "!ns3" + namespaces = %w[ns1 ns2] + namespaces_str = '!ns3' command(:remove_peer_exclude_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) assert_equal(@peer_id, command(:list_peers).get(0).getPeerId) @@ -764,7 +764,7 @@ module Hbase assert_equal(namespaces_str, replication_admin.show_peer_exclude_namespaces(peer_config)) - namespaces = ["ns3"] + namespaces = ['ns3'] namespaces_str = nil command(:remove_peer_exclude_namespaces, @peer_id, namespaces) assert_equal(1, command(:list_peers).length) diff --git a/hbase-shell/src/test/ruby/hbase/security_admin_test.rb b/hbase-shell/src/test/ruby/hbase/security_admin_test.rb index fd8f6ade0a304ecd51b604be3adb7fc66d30d26c..8f84fd5e2cb45490697837439741af166b6be5da 100644 --- a/hbase-shell/src/test/ruby/hbase/security_admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/security_admin_test.rb @@ -32,7 +32,7 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' create_test_table(@test_name) # Create table test table name @@ -43,40 +43,41 @@ module Hbase shutdown end - define_test "Revoke should rid access rights appropriately" do + define_test 'Revoke should rid access rights appropriately' do drop_test_table(@test_name) create_test_table(@test_name) table = table(@test_name) - user = org.apache.hadoop.hbase.security.User.getCurrent().getName(); + user = org.apache.hadoop.hbase.security.User.getCurrent.getName assert_equal(1, security_admin.user_permission(@test_name).length) security_admin.revoke(user, @test_name) assert_equal(0, security_admin.user_permission(@test_name).length) end - define_test "Grant should set access rights appropriately" do + define_test 'Grant should set access rights appropriately' do drop_test_table(@test_name) create_test_table(@test_name) table = table(@test_name) test_grant_revoke_user = org.apache.hadoop.hbase.security.User.createUserForTesting( - $TEST_CLUSTER.getConfiguration, "test_grant_revoke", []).getName() - security_admin.grant(test_grant_revoke_user,"W", @test_name) - security_admin.user_permission(@test_name) do |user, permission| - assert_match(eval("/WRITE/"), permission.to_s) + $TEST_CLUSTER.getConfiguration, 'test_grant_revoke', [] + ).getName + security_admin.grant(test_grant_revoke_user, 'W', @test_name) + security_admin.user_permission(@test_name) do |_user, permission| + assert_match(eval('/WRITE/'), permission.to_s) end - security_admin.grant(test_grant_revoke_user,"RX", @test_name) + security_admin.grant(test_grant_revoke_user, 'RX', @test_name) found_permission = false security_admin.user_permission(@test_name) do |user, permission| - if user == "test_grant_revoke" - assert_match(eval("/READ/"), permission.to_s) - assert_match(eval("/WRITE/"), permission.to_s) - assert_match(eval("/EXEC/"), permission.to_s) - assert_no_match(eval("/CREATE/"), permission.to_s) - assert_no_match(eval("/ADMIN/"), permission.to_s) - found_permission = true - end + if user == 'test_grant_revoke' + assert_match(eval('/READ/'), permission.to_s) + assert_match(eval('/WRITE/'), permission.to_s) + assert_match(eval('/EXEC/'), permission.to_s) + assert_no_match(eval('/CREATE/'), permission.to_s) + assert_no_match(eval('/ADMIN/'), permission.to_s) + found_permission = true + end end - assert(found_permission, "Permission for user test_grant_revoke was not found.") + assert(found_permission, 'Permission for user test_grant_revoke was not found.') end end end diff --git a/hbase-shell/src/test/ruby/hbase/table_test.rb b/hbase-shell/src/test/ruby/hbase/table_test.rb index e2645d805af3bb25cb3f6adf47616d463be9f3ff..b0f56236107930586bcedcd2616573b93ede1610 100644 --- a/hbase-shell/src/test/ruby/hbase/table_test.rb +++ b/hbase-shell/src/test/ruby/hbase/table_test.rb @@ -33,9 +33,9 @@ module Hbase shutdown end - define_test "Hbase::Table constructor should not fail for existent tables" do + define_test 'Hbase::Table constructor should not fail for existent tables' do assert_nothing_raised do - table('hbase:meta').close() + table('hbase:meta').close end end end @@ -47,47 +47,47 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' create_test_table(@test_name) @test_table = table(@test_name) end def tearDown - @test_table.close() + @test_table.close shutdown end - define_test "is_meta_table? method should return true for the meta table" do + define_test 'is_meta_table? method should return true for the meta table' do assert(table('hbase:meta').is_meta_table?) end - define_test "is_meta_table? method should return false for a normal table" do + define_test 'is_meta_table? method should return false for a normal table' do assert(!@test_table.is_meta_table?) end #------------------------------------------------------------------------------- - define_test "get_all_columns should return columns list" do + define_test 'get_all_columns should return columns list' do cols = table('hbase:meta').get_all_columns assert_kind_of(Array, cols) - assert(cols.length > 0) + assert(!cols.empty?) end #------------------------------------------------------------------------------- - define_test "parse_column_name should not return a qualifier for name-only column specifiers" do + define_test 'parse_column_name should not return a qualifier for name-only column specifiers' do col, qual = table('hbase:meta').parse_column_name('foo') assert_not_nil(col) assert_nil(qual) end - define_test "parse_column_name should support and empty column qualifier" do + define_test 'parse_column_name should support and empty column qualifier' do col, qual = table('hbase:meta').parse_column_name('foo:') assert_not_nil(col) assert_not_nil(qual) end - define_test "parse_column_name should return a qualifier for family:qualifier column specifiers" do + define_test 'parse_column_name should return a qualifier for family:qualifier column specifiers' do col, qual = table('hbase:meta').parse_column_name('foo:bar') assert_not_nil(col) assert_not_nil(qual) @@ -101,23 +101,23 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' create_test_table(@test_name) @test_table = table(@test_name) - + # Insert data to perform delete operations - @test_table.put("102", "x:a", "2", 1212) - @test_table.put(103, "x:a", "3", 1214) + @test_table.put('102', 'x:a', '2', 1212) + @test_table.put(103, 'x:a', '3', 1214) - @test_table.put("104", "x:a", 5) - @test_table.put("104", "x:b", 6) + @test_table.put('104', 'x:a', 5) + @test_table.put('104', 'x:b', 6) - @test_table.put(105, "x:a", "3") - @test_table.put(105, "x:a", "4") + @test_table.put(105, 'x:a', '3') + @test_table.put(105, 'x:a', '4') - @test_table.put("111", "x:a", "5") - @test_table.put("111", "x:b", "6") - @test_table.put("112", "x:a", "5") + @test_table.put('111', 'x:a', '5') + @test_table.put('111', 'x:b', '6') + @test_table.put('112', 'x:a', '5') end def teardown @@ -125,34 +125,34 @@ module Hbase shutdown end - define_test "put should work without timestamp" do - @test_table.put("123", "x:a", "1") + define_test 'put should work without timestamp' do + @test_table.put('123', 'x:a', '1') end - define_test "put should work with timestamp" do - @test_table.put("123", "x:a", "2", Time.now.to_i) + define_test 'put should work with timestamp' do + @test_table.put('123', 'x:a', '2', Time.now.to_i) end - define_test "put should work with integer keys" do - @test_table.put(123, "x:a", "3") + define_test 'put should work with integer keys' do + @test_table.put(123, 'x:a', '3') end - define_test "put should work with integer values" do - @test_table.put("123", "x:a", 4) + define_test 'put should work with integer values' do + @test_table.put('123', 'x:a', 4) end - - define_test "put should work with attributes" do - @test_table.put("123", "x:a", 4, {ATTRIBUTES=>{'mykey'=>'myvalue'}}) + + define_test 'put should work with attributes' do + @test_table.put('123', 'x:a', 4, ATTRIBUTES => { 'mykey' => 'myvalue' }) end #------------------------------------------------------------------------------- - define_test "delete should work with string keys" do + define_test 'delete should work with string keys' do @test_table.delete('102', 'x:a', 1212) res = @test_table._get_internal('102', 'x:a') assert_nil(res) end - define_test "delete should work with integer keys" do + define_test 'delete should work with integer keys' do res = @test_table._get_internal('103', 'x:a') assert_not_nil(res) @test_table.delete(103, 'x:a', 1214) @@ -162,29 +162,29 @@ module Hbase #------------------------------------------------------------------------------- - define_test "deleteall should work w/o columns and timestamps" do - @test_table.deleteall("104") + define_test 'deleteall should work w/o columns and timestamps' do + @test_table.deleteall('104') res = @test_table._get_internal('104', 'x:a', 'x:b') assert_nil(res) end - define_test "deleteall should work with integer keys" do + define_test 'deleteall should work with integer keys' do @test_table.deleteall(105) res = @test_table._get_internal('105', 'x:a') assert_nil(res) end - define_test "deletall should work with row prefix" do - @test_table.deleteall({ROWPREFIXFILTER => '11'}) + define_test 'deletall should work with row prefix' do + @test_table.deleteall(ROWPREFIXFILTER => '11') res1 = @test_table._get_internal('111') assert_nil(res1) res2 = @test_table._get_internal('112') assert_nil(res2) end - define_test "append should work with value" do - @test_table.append("123", 'x:cnt2', '123') - assert_equal("123123", @test_table._append_internal("123", 'x:cnt2', '123')) + define_test 'append should work with value' do + @test_table.append('123', 'x:cnt2', '123') + assert_equal('123123', @test_table._append_internal('123', 'x:cnt2', '123')) end define_test 'append should work without qualifier' do @@ -200,13 +200,13 @@ module Hbase assert_equal(246, @test_table._get_counter_internal('1010', 'x')) end - define_test "get_counter should work with integer keys" do - @test_table.incr(12345, 'x:cnt') - assert_kind_of(Fixnum, @test_table._get_counter_internal(12345, 'x:cnt')) + define_test 'get_counter should work with integer keys' do + @test_table.incr(12_345, 'x:cnt') + assert_kind_of(Integer, @test_table._get_counter_internal(12_345, 'x:cnt')) end - define_test "get_counter should return nil for non-existent counters" do - assert_nil(@test_table._get_counter_internal(12345, 'x:qqqq')) + define_test 'get_counter should return nil for non-existent counters' do + assert_nil(@test_table._get_counter_internal(12_345, 'x:qqqq')) end end @@ -218,20 +218,20 @@ module Hbase def setup setup_hbase # Create test table if it does not exist - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' create_test_table(@test_name) @test_table = table(@test_name) # Instert test data - @test_ts = 12345678 - @test_table.put(1, "x:a", 1) - @test_table.put(1, "x:b", 2, @test_ts) + @test_ts = 12_345_678 + @test_table.put(1, 'x:a', 1) + @test_table.put(1, 'x:b', 2, @test_ts) - @test_table.put(2, "x:a", 11) - @test_table.put(2, "x:b", 12, @test_ts) - - @test_table.put(3, "x:a", 21, {ATTRIBUTES=>{'mykey'=>'myvalue'}}) - @test_table.put(3, "x:b", 22, @test_ts, {ATTRIBUTES=>{'mykey'=>'myvalue'}}) + @test_table.put(2, 'x:a', 11) + @test_table.put(2, 'x:b', 12, @test_ts) + + @test_table.put(3, 'x:a', 21, ATTRIBUTES => { 'mykey' => 'myvalue' }) + @test_table.put(3, 'x:b', 22, @test_ts, ATTRIBUTES => { 'mykey' => 'myvalue' }) end def teardown @@ -239,55 +239,55 @@ module Hbase shutdown end - define_test "count should work w/o a block passed" do + define_test 'count should work w/o a block passed' do assert(@test_table._count_internal > 0) end - define_test "count should work with a block passed (and yield)" do + define_test 'count should work with a block passed (and yield)' do rows = [] - cnt = @test_table._count_internal(1) do |cnt, row| + cnt = @test_table._count_internal(1) do |_cnt, row| rows << row end assert(cnt > 0) assert(!rows.empty?) end - define_test "count should support STARTROW parameter" do + define_test 'count should support STARTROW parameter' do count = @test_table.count STARTROW => '4' assert(count == 0) end - define_test "count should support STOPROW parameter" do + define_test 'count should support STOPROW parameter' do count = @test_table.count STOPROW => '0' assert(count == 0) end - define_test "count should support COLUMNS parameter" do - @test_table.put(4, "x:c", "31") + define_test 'count should support COLUMNS parameter' do + @test_table.put(4, 'x:c', '31') begin - count = @test_table.count COLUMNS => [ 'x:c'] + count = @test_table.count COLUMNS => ['x:c'] assert(count == 1) ensure @test_table.deleteall(4, 'x:c') end end - define_test "count should support FILTER parameter" do + define_test 'count should support FILTER parameter' do count = @test_table.count FILTER => "ValueFilter(=, 'binary:11')" assert(count == 1) end #------------------------------------------------------------------------------- - define_test "get should work w/o columns specification" do + define_test 'get should work w/o columns specification' do res = @test_table._get_internal('1') assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['x:a']) assert_not_nil(res['x:b']) end - - define_test "get should work for data written with Attributes" do + + define_test 'get should work for data written with Attributes' do res = @test_table._get_internal('3') assert_not_nil(res) assert_kind_of(Hash, res) @@ -295,7 +295,7 @@ module Hbase assert_not_nil(res['x:b']) end - define_test "get should work with integer keys" do + define_test 'get should work with integer keys' do res = @test_table._get_internal(1) assert_not_nil(res) assert_kind_of(Hash, res) @@ -303,7 +303,7 @@ module Hbase assert_not_nil(res['x:b']) end - define_test "get should work with hash columns spec and a single string COLUMN parameter" do + define_test 'get should work with hash columns spec and a single string COLUMN parameter' do res = @test_table._get_internal('1', COLUMN => 'x:a') assert_not_nil(res) assert_kind_of(Hash, res) @@ -311,7 +311,7 @@ module Hbase assert_nil(res['x:b']) end - define_test "get should work with hash columns spec and a single string COLUMNS parameter" do + define_test 'get should work with hash columns spec and a single string COLUMNS parameter' do res = @test_table._get_internal('1', COLUMNS => 'x:a') assert_not_nil(res) assert_kind_of(Hash, res) @@ -319,31 +319,31 @@ module Hbase assert_nil(res['x:b']) end - define_test "get should work with hash columns spec and an array of strings COLUMN parameter" do - res = @test_table._get_internal('1', COLUMN => [ 'x:a', 'x:b' ]) + define_test 'get should work with hash columns spec and an array of strings COLUMN parameter' do + res = @test_table._get_internal('1', COLUMN => ['x:a', 'x:b']) assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['x:a']) assert_not_nil(res['x:b']) end - define_test "get should work with hash columns spec and an array of strings COLUMNS parameter" do - res = @test_table._get_internal('1', COLUMNS => [ 'x:a', 'x:b' ]) + define_test 'get should work with hash columns spec and an array of strings COLUMNS parameter' do + res = @test_table._get_internal('1', COLUMNS => ['x:a', 'x:b']) assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['x:a']) assert_not_nil(res['x:b']) end - - define_test "get should work with hash columns spec and an array of strings COLUMNS parameter with AUTHORIZATIONS" do - res = @test_table._get_internal('1', COLUMNS => [ 'x:a', 'x:b' ], AUTHORIZATIONS=>['PRIVATE']) + + define_test 'get should work with hash columns spec and an array of strings COLUMNS parameter with AUTHORIZATIONS' do + res = @test_table._get_internal('1', COLUMNS => ['x:a', 'x:b'], AUTHORIZATIONS => ['PRIVATE']) assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['x:a']) assert_not_nil(res['x:b']) end - define_test "get should work with hash columns spec and TIMESTAMP only" do + define_test 'get should work with hash columns spec and TIMESTAMP only' do res = @test_table._get_internal('1', TIMESTAMP => @test_ts) assert_not_nil(res) assert_kind_of(Hash, res) @@ -353,29 +353,29 @@ module Hbase define_test 'get should work with hash columns spec and TIMESTAMP and' \ ' AUTHORIZATIONS' do - res = @test_table._get_internal('1', TIMESTAMP => 1234, AUTHORIZATIONS=>['PRIVATE']) + res = @test_table._get_internal('1', TIMESTAMP => 1234, AUTHORIZATIONS => ['PRIVATE']) assert_nil(res) end - - define_test "get should fail with hash columns spec and strange COLUMN value" do + + define_test 'get should fail with hash columns spec and strange COLUMN value' do assert_raise(ArgumentError) do @test_table._get_internal('1', COLUMN => {}) end end - define_test "get should fail with hash columns spec and strange COLUMNS value" do + define_test 'get should fail with hash columns spec and strange COLUMNS value' do assert_raise(ArgumentError) do @test_table._get_internal('1', COLUMN => {}) end end - define_test "get should fail with hash columns spec and no TIMESTAMP or COLUMN[S]" do + define_test 'get should fail with hash columns spec and no TIMESTAMP or COLUMN[S]' do assert_raise(ArgumentError) do - @test_table._get_internal('1', { :foo => :bar }) + @test_table._get_internal('1', foo: :bar) end end - define_test "get should work with a string column spec" do + define_test 'get should work with a string column spec' do res = @test_table._get_internal('1', 'x:b') assert_not_nil(res) assert_kind_of(Hash, res) @@ -383,7 +383,7 @@ module Hbase assert_not_nil(res['x:b']) end - define_test "get should work with an array columns spec" do + define_test 'get should work with an array columns spec' do res = @test_table._get_internal('1', 'x:a', 'x:b') assert_not_nil(res) assert_kind_of(Hash, res) @@ -391,7 +391,7 @@ module Hbase assert_not_nil(res['x:b']) end - define_test "get should work with an array or arrays columns spec (yeah, crazy)" do + define_test 'get should work with an array or arrays columns spec (yeah, crazy)' do res = @test_table._get_internal('1', ['x:a'], ['x:b']) assert_not_nil(res) assert_kind_of(Hash, res) @@ -399,30 +399,30 @@ module Hbase assert_not_nil(res['x:b']) end - define_test "get with a block should yield (column, value) pairs" do + define_test 'get with a block should yield (column, value) pairs' do res = {} @test_table._get_internal('1') { |col, val| res[col] = val } - assert_equal(res.keys.sort, [ 'x:a', 'x:b' ]) - end - - define_test "get should support COLUMNS with value CONVERTER information" do - @test_table.put(1, "x:c", [1024].pack('N')) - @test_table.put(1, "x:d", [98].pack('N')) - begin - res = @test_table._get_internal('1', ['x:c:toInt'], ['x:d:c(org.apache.hadoop.hbase.util.Bytes).toInt']) - assert_not_nil(res) - assert_kind_of(Hash, res) - assert_not_nil(/value=1024/.match(res['x:c'])) - assert_not_nil(/value=98/.match(res['x:d'])) - ensure - # clean up newly added columns for this test only. - @test_table.deleteall(1, 'x:c') - @test_table.deleteall(1, 'x:d') - end + assert_equal(res.keys.sort, ['x:a', 'x:b']) end - define_test "get should support FILTER" do - @test_table.put(1, "x:v", "thisvalue") + define_test 'get should support COLUMNS with value CONVERTER information' do + @test_table.put(1, 'x:c', [1024].pack('N')) + @test_table.put(1, 'x:d', [98].pack('N')) + begin + res = @test_table._get_internal('1', ['x:c:toInt'], ['x:d:c(org.apache.hadoop.hbase.util.Bytes).toInt']) + assert_not_nil(res) + assert_kind_of(Hash, res) + assert_not_nil(/value=1024/.match(res['x:c'])) + assert_not_nil(/value=98/.match(res['x:d'])) + ensure + # clean up newly added columns for this test only. + @test_table.deleteall(1, 'x:c') + @test_table.deleteall(1, 'x:d') + end + end + + define_test 'get should support FILTER' do + @test_table.put(1, 'x:v', 'thisvalue') begin res = @test_table._get_internal('1', FILTER => "ValueFilter(=, 'binary:thisvalue')") assert_not_nil(res) @@ -454,7 +454,7 @@ module Hbase #------------------------------------------------------------------------------- - define_test "scan should work w/o any params" do + define_test 'scan should work w/o any params' do res = @test_table._scan_internal assert_not_nil(res) assert_kind_of(Hash, res) @@ -466,7 +466,7 @@ module Hbase assert_not_nil(res['2']['x:b']) end - define_test "scan should support STARTROW parameter" do + define_test 'scan should support STARTROW parameter' do res = @test_table._scan_internal STARTROW => '2' assert_not_nil(res) assert_kind_of(Hash, res) @@ -476,7 +476,7 @@ module Hbase assert_not_nil(res['2']['x:b']) end - define_test "scan should support STARTKEY parameter" do + define_test 'scan should support STARTKEY parameter' do res = @test_table._scan_internal STARTKEY => '2' assert_not_nil(res) assert_kind_of(Hash, res) @@ -486,7 +486,7 @@ module Hbase assert_not_nil(res['2']['x:b']) end - define_test "scan should support STOPROW parameter" do + define_test 'scan should support STOPROW parameter' do res = @test_table._scan_internal STOPROW => '2' assert_not_nil(res) assert_kind_of(Hash, res) @@ -496,7 +496,7 @@ module Hbase assert_nil(res['2']) end - define_test "scan should support ENDROW parameter" do + define_test 'scan should support ENDROW parameter' do res = @test_table._scan_internal ENDROW => '2' assert_not_nil(res) assert_kind_of(Hash, res) @@ -506,7 +506,7 @@ module Hbase assert_nil(res['2']) end - define_test "scan should support ENDKEY parameter" do + define_test 'scan should support ENDKEY parameter' do res = @test_table._scan_internal ENDKEY => '2' assert_not_nil(res) assert_kind_of(Hash, res) @@ -545,8 +545,8 @@ module Hbase assert_not_nil(res['1']['x:b']) assert_nil(res['2']) end - - define_test "scan should support REVERSED parameter" do + + define_test 'scan should support REVERSED parameter' do res = @test_table._scan_internal REVERSED => true assert_not_nil(res) assert_kind_of(Hash, res) @@ -558,7 +558,7 @@ module Hbase assert_not_nil(res['2']['x:b']) end - define_test "scan should support TIMESTAMP parameter" do + define_test 'scan should support TIMESTAMP parameter' do res = @test_table._scan_internal TIMESTAMP => @test_ts assert_not_nil(res) assert_kind_of(Hash, res) @@ -570,7 +570,7 @@ module Hbase assert_not_nil(res['2']['x:b']) end - define_test "scan should support TIMERANGE parameter" do + define_test 'scan should support TIMERANGE parameter' do res = @test_table._scan_internal TIMERANGE => [0, 1] assert_not_nil(res) assert_kind_of(Hash, res) @@ -578,8 +578,8 @@ module Hbase assert_nil(res['2']) end - define_test "scan should support COLUMNS parameter with an array of columns" do - res = @test_table._scan_internal COLUMNS => [ 'x:a', 'x:b' ] + define_test 'scan should support COLUMNS parameter with an array of columns' do + res = @test_table._scan_internal COLUMNS => ['x:a', 'x:b'] assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['1']) @@ -589,8 +589,8 @@ module Hbase assert_not_nil(res['2']['x:a']) assert_not_nil(res['2']['x:b']) end - - define_test "scan should support COLUMNS parameter with a single column name" do + + define_test 'scan should support COLUMNS parameter with a single column name' do res = @test_table._scan_internal COLUMNS => 'x:a' assert_not_nil(res) assert_kind_of(Hash, res) @@ -602,18 +602,18 @@ module Hbase assert_nil(res['2']['x:b']) end - define_test "scan should work with raw and version parameter" do + define_test 'scan should work with raw and version parameter' do # Create test table if it does not exist - @test_name_raw = "hbase_shell_tests_raw_scan" + @test_name_raw = 'hbase_shell_tests_raw_scan' create_test_table(@test_name_raw) @test_table = table(@test_name_raw) # Instert test data - @test_table.put(1, "x:a", 1) - @test_table.put(2, "x:raw1", 11) - @test_table.put(2, "x:raw1", 11) - @test_table.put(2, "x:raw1", 11) - @test_table.put(2, "x:raw1", 11) + @test_table.put(1, 'x:a', 1) + @test_table.put(2, 'x:raw1', 11) + @test_table.put(2, 'x:raw1', 11) + @test_table.put(2, 'x:raw1', 11) + @test_table.put(2, 'x:raw1', 11) args = {} num_rows = 0 @@ -651,27 +651,27 @@ module Hbase 'Num rows scanned without RAW/VERSIONS are not 5') end - define_test "scan should fail on invalid COLUMNS parameter types" do + define_test 'scan should fail on invalid COLUMNS parameter types' do assert_raise(ArgumentError) do @test_table._scan_internal COLUMNS => {} end end - define_test "scan should fail on non-hash params" do + define_test 'scan should fail on non-hash params' do assert_raise(ArgumentError) do @test_table._scan_internal 123 end end - define_test "scan with a block should yield rows and return rows counter" do + define_test 'scan with a block should yield rows and return rows counter' do rows = {} res = @test_table._scan_internal { |row, cells| rows[row] = cells } - assert_equal([rows.keys.size,false], res) + assert_equal([rows.keys.size, false], res) end - - define_test "scan should support COLUMNS with value CONVERTER information" do - @test_table.put(1, "x:c", [1024].pack('N')) - @test_table.put(1, "x:d", [98].pack('N')) + + define_test 'scan should support COLUMNS with value CONVERTER information' do + @test_table.put(1, 'x:c', [1024].pack('N')) + @test_table.put(1, 'x:d', [98].pack('N')) begin res = @test_table._scan_internal COLUMNS => ['x:c:toInt', 'x:d:c(org.apache.hadoop.hbase.util.Bytes).toInt'] assert_not_nil(res) @@ -685,29 +685,29 @@ module Hbase end end - define_test "scan should support FILTER" do - @test_table.put(1, "x:v", "thisvalue") + define_test 'scan should support FILTER' do + @test_table.put(1, 'x:v', 'thisvalue') begin res = @test_table._scan_internal FILTER => "ValueFilter(=, 'binary:thisvalue')" - assert_not_equal(res, {}, "Result is empty") + assert_not_equal(res, {}, 'Result is empty') assert_kind_of(Hash, res) assert_not_nil(res['1']) assert_not_nil(res['1']['x:v']) assert_nil(res['1']['x:a']) assert_nil(res['2']) res = @test_table._scan_internal FILTER => "ValueFilter(=, 'binary:thatvalue')" - assert_equal(res, {}, "Result is not empty") + assert_equal(res, {}, 'Result is not empty') ensure # clean up newly added columns for this test only. @test_table.deleteall(1, 'x:v') end end - define_test "scan should support FILTER with non-ASCII bytes" do - @test_table.put(4, "x:a", "\x82") + define_test 'scan should support FILTER with non-ASCII bytes' do + @test_table.put(4, 'x:a', "\x82") begin res = @test_table._scan_internal FILTER => "SingleColumnValueFilter('x', 'a', >=, 'binary:\x82', true, true)" - assert_not_equal(res, {}, "Result is empty") + assert_not_equal(res, {}, 'Result is empty') assert_kind_of(Hash, res) assert_not_nil(res['4']) assert_not_nil(res['4']['x:a']) @@ -719,8 +719,8 @@ module Hbase end end - define_test "scan hbase meta table" do - res = table("hbase:meta")._scan_internal + define_test 'scan hbase meta table' do + res = table('hbase:meta')._scan_internal assert_not_nil(res) end @@ -739,8 +739,8 @@ module Hbase end end - define_test "mutation with TTL should expire" do - @test_table.put('ttlTest', 'x:a', 'foo', { TTL => 1000 } ) + define_test 'mutation with TTL should expire' do + @test_table.put('ttlTest', 'x:a', 'foo', TTL => 1000) begin res = @test_table._get_internal('ttlTest', 'x:a') assert_not_nil(res) @@ -801,7 +801,7 @@ module Hbase drop_test_table(@test_table_name) end - define_test "scan should throw an exception on a disabled table" do + define_test 'scan should throw an exception on a disabled table' do @test_table.disable begin assert_raise(RuntimeError) do diff --git a/hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb b/hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb index cdb91c717976d17ea477e122dfb79e8fa544bbd0..2c15fd3867ecaec531ed2348ba19b59074f9c6e7 100644 --- a/hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb +++ b/hbase-shell/src/test/ruby/hbase/taskmonitor_test.rb @@ -26,12 +26,12 @@ module Hbase setup_hbase end - define_test "tasksOnHost should return tasks list" do + define_test 'tasksOnHost should return tasks list' do filter = 'all' - hosts = admin.getRegionServers() + hosts = admin.getRegionServers hosts.each do |host| - tasks = taskmonitor.tasksOnHost(filter,host) - assert(tasks.length > 0) + tasks = taskmonitor.tasksOnHost(filter, host) + assert(!tasks.empty?) end end end diff --git a/hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb b/hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb index d240ff8604661cdd674ac7beb0d42dff4cb8ae53..1e9731c7506a7e59eb411c3600004b54654081a1 100644 --- a/hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb +++ b/hbase-shell/src/test/ruby/hbase/test_connection_no_cluster.rb @@ -30,14 +30,14 @@ module Hbase include TestHelpers def setup - puts "starting shell" + puts 'starting shell' end def teardown # nothing to teardown end - define_test "start_hbase_shell_no_cluster" do + define_test 'start_hbase_shell_no_cluster' do assert_nothing_raised do setup_hbase end diff --git a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb index b42290fa8dda60690fe47a8fd5f26f6d5b1e1142..4f1676c61b33f4f04eb6a24a938f5015502f1cc2 100644 --- a/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/visibility_labels_admin_test.rb @@ -31,7 +31,7 @@ module Hbase def setup setup_hbase - @test_name = "hbase_shell_tests_table" + @test_name = 'hbase_shell_tests_table' @test_table = table(@test_name) # Create table test table name create_test_table(@test_name) @@ -42,27 +42,27 @@ module Hbase shutdown end - define_test "Labels should be created as specified" do + define_test 'Labels should be created as specified' do label = 'TEST_LABELS' count = table('hbase:labels')._count_internal command(:add_labels, 'test_label') assert_equal(count + 1, table('hbase:labels')._count_internal) end - define_test "The set/clear methods should work with authorizations" do + define_test 'The set/clear methods should work with authorizations' do label = 'TEST_AUTHS' - user = org.apache.hadoop.hbase.security.User.getCurrent().getName(); + user = org.apache.hadoop.hbase.security.User.getCurrent.getName command(:add_labels, label) - $TEST_CLUSTER.waitLabelAvailable(10000, label) + $TEST_CLUSTER.waitLabelAvailable(10_000, label) count = command(:get_auths, user).length # verifying the set functionality command(:set_auths, user, label) assert_equal(count + 1, command(:get_auths, user).length) assert_block do - command(:get_auths, user).any? { - |auth| org.apache.hadoop.hbase.util.Bytes::toStringBinary(auth.toByteArray) == label - } + command(:get_auths, user).any? do |auth| + org.apache.hadoop.hbase.util.Bytes.toStringBinary(auth.toByteArray) == label + end end # verifying the clear functionality @@ -70,22 +70,21 @@ module Hbase assert_equal(count, command(:get_auths, user).length) end - define_test "The get/put methods should work for data written with Visibility" do + define_test 'The get/put methods should work for data written with Visibility' do label = 'TEST_VISIBILITY' - user = org.apache.hadoop.hbase.security.User.getCurrent().getName(); + user = org.apache.hadoop.hbase.security.User.getCurrent.getName command(:add_labels, label) - $TEST_CLUSTER.waitLabelAvailable(10000, label) + $TEST_CLUSTER.waitLabelAvailable(10_000, label) command(:set_auths, user, label) # verifying put functionality - @test_table.put(1, "x:a", 31, {VISIBILITY=>label}) + @test_table.put(1, 'x:a', 31, VISIBILITY => label) # verifying get functionality - res = @test_table._get_internal('1', {AUTHORIZATIONS=>[label]}) + res = @test_table._get_internal('1', AUTHORIZATIONS => [label]) assert_not_nil(res) assert_kind_of(Hash, res) assert_not_nil(res['x:a']) end - end end diff --git a/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb b/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb index 77b16df02e7cbc50c5137d2035404dff2fb8d94b..2aadafbb19a07602bcdd84db58ba0f01ce2fc37d 100644 --- a/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb +++ b/hbase-shell/src/test/ruby/no_cluster_tests_runner.rb @@ -21,7 +21,6 @@ require 'rubygems' require 'rake' require 'set' - # This runner will only launch shell tests that don't require a HBase cluster running. unless defined?($TEST_CLUSTER) @@ -29,22 +28,22 @@ unless defined?($TEST_CLUSTER) # Set logging level to avoid verboseness org.apache.log4j.Logger.getRootLogger.setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.hdfs").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.ipc.HBaseServer").setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.zookeeper').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.hdfs').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.hbase').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.ipc.HBaseServer').setLevel(org.apache.log4j.Level::OFF) java_import org.apache.hadoop.hbase.HBaseTestingUtility $TEST_CLUSTER = HBaseTestingUtility.new - $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100) - $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250) + $TEST_CLUSTER.configuration.setInt('hbase.regionserver.msginterval', 100) + $TEST_CLUSTER.configuration.setInt('hbase.client.pause', 250) $TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER, 6) end require 'test_helper' -puts "Running tests without a cluster..." +puts 'Running tests without a cluster...' if java.lang.System.get_property('shell.test.include') includes = Set.new(java.lang.System.get_property('shell.test.include').split(',')) @@ -54,20 +53,20 @@ if java.lang.System.get_property('shell.test.exclude') excludes = Set.new(java.lang.System.get_property('shell.test.exclude').split(',')) end -files = Dir[ File.dirname(__FILE__) + "/**/*_no_cluster.rb" ] +files = Dir[File.dirname(__FILE__) + '/**/*_no_cluster.rb'] files.each do |file| filename = File.basename(file) - if includes != nil && !includes.include?(filename) + if !includes.nil? && !includes.include?(filename) puts "Skip #{filename} because of not included" next end - if excludes != nil && excludes.include?(filename) + if !excludes.nil? && excludes.include?(filename) puts "Skip #{filename} because of excluded" next end begin load(file) - rescue => e + rescue StandardError => e puts "ERROR: #{e}" raise end @@ -81,11 +80,11 @@ if java.lang.System.get_property('shell.test') runner_args << "--testcase=#{shell_test_pattern}" end # first couple of args are to match the defaults, so we can pass options to limit the tests run -if !(Test::Unit::AutoRunner.run(false, nil, runner_args)) - raise "Shell unit tests failed. Check output file for details." +unless Test::Unit::AutoRunner.run(false, nil, runner_args) + raise 'Shell unit tests failed. Check output file for details.' end -puts "Done with tests! Shutting down the cluster..." +puts 'Done with tests! Shutting down the cluster...' if @own_cluster $TEST_CLUSTER.shutdownMiniCluster java.lang.System.exit(0) diff --git a/hbase-shell/src/test/ruby/shell/converter_test.rb b/hbase-shell/src/test/ruby/shell/converter_test.rb index 8b6079bcb36ba53757ec491056b8746e281f5485..08eccddc1e78b691e08f6ba833f69bfa00e4a281 100644 --- a/hbase-shell/src/test/ruby/shell/converter_test.rb +++ b/hbase-shell/src/test/ruby/shell/converter_test.rb @@ -47,21 +47,21 @@ module Hbase create_test_table(table_name) # Write a record command(:put, table_name, 'r1', 'x:a', non_ascii_text) - output = capture_stdout{ command(:scan, table_name) } + output = capture_stdout { command(:scan, table_name) } # Encoded value not there by default assert(!output.include?(non_ascii_text)) # Hex-encoded value is there by default (manually converted) assert(output.include?(hex_text)) # Use the formatter method - output = capture_stdout{ command(:scan, table_name, {'FORMATTER'=>'toString'}) } + output = capture_stdout { command(:scan, table_name, 'FORMATTER' => 'toString') } # Should have chinese characters assert(output.include?(non_ascii_text)) # Should not have hex-encoded string assert(!output.include?(hex_text)) # Use the formatter method + class - output = capture_stdout{ command(:scan, table_name, {'FORMATTER'=>'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes'}) } + output = capture_stdout { command(:scan, table_name, 'FORMATTER' => 'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes') } # Should have chinese characters assert(output.include?(non_ascii_text)) # Should not have hex-encoded string @@ -72,7 +72,7 @@ module Hbase command(:create, table_name, non_ascii_family) command(:put, table_name, non_ascii_row, non_ascii_column, non_ascii_text) - output = capture_stdout{ command(:scan, table_name) } + output = capture_stdout { command(:scan, table_name) } # By default, get hex-encoded data assert(!output.include?(non_ascii_text)) assert(!output.include?(non_ascii_row)) @@ -82,7 +82,7 @@ module Hbase assert(output.include?(hex_column)) # Use the formatter method - output = capture_stdout{ command(:scan, table_name, {'FORMATTER'=>'toString'}) } + output = capture_stdout { command(:scan, table_name, 'FORMATTER' => 'toString') } # By default, get hex-encoded data assert(output.include?(non_ascii_text)) assert(output.include?(non_ascii_row)) @@ -92,7 +92,7 @@ module Hbase assert(!output.include?(hex_column)) # Use the formatter method + class - output = capture_stdout{ command(:scan, table_name, {'FORMATTER'=>'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes'}) } + output = capture_stdout { command(:scan, table_name, 'FORMATTER' => 'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes') } # By default, get hex-encoded data assert(output.include?(non_ascii_text)) assert(output.include?(non_ascii_row)) @@ -107,21 +107,21 @@ module Hbase create_test_table(table_name) # Write a record command(:put, table_name, 'r1', 'x:a', non_ascii_text) - output = capture_stdout{ command(:get, table_name, 'r1') } + output = capture_stdout { command(:get, table_name, 'r1') } # Encoded value not there by default assert(!output.include?(non_ascii_text)) # Hex-encoded value is there by default (manually converted) assert(output.include?(hex_text)) # use the formatter method - output = capture_stdout{ command(:get, table_name, 'r1', {'FORMATTER'=>'toString'}) } + output = capture_stdout { command(:get, table_name, 'r1', 'FORMATTER' => 'toString') } # Should have chinese characters assert(output.include?(non_ascii_text)) # Should not have hex-encoded string assert(!output.include?(hex_text)) # use the formatter method + class - output = capture_stdout{ command(:get, table_name, 'r1', {'FORMATTER'=>'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes'}) } + output = capture_stdout { command(:get, table_name, 'r1', 'FORMATTER' => 'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes') } # Should have chinese characters assert(output.include?(non_ascii_text)) # Should not have hex-encoded string @@ -133,25 +133,25 @@ module Hbase # use no formatter (expect hex) command(:put, table_name, non_ascii_row, non_ascii_column, non_ascii_text) - output = capture_stdout{ command(:get, table_name, non_ascii_row) } + output = capture_stdout { command(:get, table_name, non_ascii_row) } assert(!output.include?(non_ascii_text)) assert(!output.include?(non_ascii_column)) assert(output.include?(hex_text)) assert(output.include?(hex_column)) # use the formatter method - output = capture_stdout{ command(:get, table_name, non_ascii_row, {'FORMATTER'=>'toString'}) } + output = capture_stdout { command(:get, table_name, non_ascii_row, 'FORMATTER' => 'toString') } assert(output.include?(non_ascii_text)) assert(output.include?(non_ascii_column)) assert(!output.include?(hex_text)) assert(!output.include?(hex_column)) # use the formatter method + class - output = capture_stdout{ command(:get, table_name, non_ascii_row, {'FORMATTER'=>'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes'}) } + output = capture_stdout { command(:get, table_name, non_ascii_row, 'FORMATTER' => 'toString', 'FORMATTER_CLASS' => 'org.apache.hadoop.hbase.util.Bytes') } assert(output.include?(non_ascii_text)) assert(output.include?(non_ascii_column)) assert(!output.include?(hex_text)) assert(!output.include?(hex_column)) end end -end \ No newline at end of file +end diff --git a/hbase-shell/src/test/ruby/shell/formatter_test.rb b/hbase-shell/src/test/ruby/shell/formatter_test.rb index 540dd09db056c0d291e39a71ccb56bac257ae996..0e02f92d669735e2348a6525199bf5457bdaf931 100644 --- a/hbase-shell/src/test/ruby/shell/formatter_test.rb +++ b/hbase-shell/src/test/ruby/shell/formatter_test.rb @@ -22,27 +22,27 @@ require 'shell/formatter' class ShellFormatterTest < Test::Unit::TestCase # Helper method to construct a null formatter def formatter - Shell::Formatter::Base.new(:output_stream => STDOUT) + Shell::Formatter::Base.new(output_stream: STDOUT) end # # Constructor tests # - define_test "Formatter constructor should not raise error valid IO streams" do + define_test 'Formatter constructor should not raise error valid IO streams' do assert_nothing_raised do - Shell::Formatter::Base.new(:output_stream => STDOUT) + Shell::Formatter::Base.new(output_stream: STDOUT) end end - define_test "Formatter constructor should not raise error when no IO stream passed" do + define_test 'Formatter constructor should not raise error when no IO stream passed' do assert_nothing_raised do - Shell::Formatter::Base.new() + Shell::Formatter::Base.new end end - define_test "Formatter constructor should raise error on non-IO streams" do + define_test 'Formatter constructor should raise error on non-IO streams' do assert_raise TypeError do - Shell::Formatter::Base.new(:output_stream => 'foostring') + Shell::Formatter::Base.new(output_stream: 'foostring') end end @@ -50,19 +50,19 @@ class ShellFormatterTest < Test::Unit::TestCase # Printing methods tests # FIXME: The tests are just checking that the code has no typos, try to figure out a better way to test # - define_test "Formatter#header should work" do - formatter.header(['a', 'b']) - formatter.header(['a', 'b'], [10, 20]) + define_test 'Formatter#header should work' do + formatter.header(%w[a b]) + formatter.header(%w[a b], [10, 20]) end - define_test "Formatter#row should work" do - formatter.row(['a', 'b']) + define_test 'Formatter#row should work' do + formatter.row(%w[a b]) formatter.row(['xxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxxxx']) formatter.row(['yyyyyy yyyyyy yyyyy yyy', 'xxxxxxxxx xxxxxxxxxxx xxxxxxxxxxx xxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxx xxxxxxxxxxxxxx xxx xx x xx xxx xx xx xx x xx x x xxx x x xxx x x xx x x x x x x xx ']) formatter.row(["NAME => 'table1', FAMILIES => [{NAME => 'fam2', VERSIONS => 3, COMPRESSION => 'NONE', IN_MEMORY => false, BLOCKCACHE => false, LENGTH => 2147483647, TTL => FOREVER, BLOOMFILTER => NONE}, {NAME => 'fam1', VERSIONS => 3, COMPRESSION => 'NONE', IN_MEMORY => false, BLOCKCACHE => false, LENGTH => 2147483647, TTL => FOREVER, BLOOMFILTER => NONE}]"]) end - define_test "Froematter#footer should work" do - formatter.footer() + define_test 'Froematter#footer should work' do + formatter.footer end end diff --git a/hbase-shell/src/test/ruby/shell/list_locks_test.rb b/hbase-shell/src/test/ruby/shell/list_locks_test.rb index ef1c0ce1e7aefd9566a7e86dad2c9c8b83723bc7..ba51e2c6a58e878120a97c0daed06498dc31b90c 100644 --- a/hbase-shell/src/test/ruby/shell/list_locks_test.rb +++ b/hbase-shell/src/test/ruby/shell/list_locks_test.rb @@ -57,14 +57,14 @@ module Hbase def create_exclusive_lock(proc_id) create_lock(org.apache.hadoop.hbase.procedure2.LockType::EXCLUSIVE, - org.apache.hadoop.hbase.master.procedure.TableProcedureInterface::TableOperationType::EDIT, - proc_id) + org.apache.hadoop.hbase.master.procedure.TableProcedureInterface::TableOperationType::EDIT, + proc_id) end def create_shared_lock(proc_id) create_lock(org.apache.hadoop.hbase.procedure2.LockType::SHARED, - org.apache.hadoop.hbase.master.procedure.TableProcedureInterface::TableOperationType::READ, - proc_id) + org.apache.hadoop.hbase.master.procedure.TableProcedureInterface::TableOperationType::READ, + proc_id) end define_test 'list peer locks' do @@ -77,13 +77,14 @@ module Hbase assert_equal( "PEER(1)\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"0\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", " \ - "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"0", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", ' \ + '"stateMessage"=>[{"lockType"=>"EXCLUSIVE", "description"=>"description"}]' \ "}\n\n", - output) + output + ) end define_test 'list server locks' do @@ -97,13 +98,14 @@ module Hbase assert_equal( "SERVER(server1,1234,0)\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"0\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", " \ - "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"0", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", ' \ + '"stateMessage"=>[{"lockType"=>"EXCLUSIVE", "description"=>"description"}]' \ "}\n\n", - output) + output + ) end define_test 'list namespace locks' do @@ -115,15 +117,16 @@ module Hbase assert_equal( "NAMESPACE(ns1)\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"1\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", " \ - "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"1", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", ' \ + '"stateMessage"=>[{"lockType"=>"EXCLUSIVE", "description"=>"description"}]' \ "}\n\n" \ "TABLE(hbase:namespace)\n" \ "Lock type: SHARED, count: 1\n\n", - output) + output + ) end define_test 'list table locks' do @@ -139,13 +142,14 @@ module Hbase "NAMESPACE(ns2)\n" \ "Lock type: SHARED, count: 1\n\n" \ "TABLE(ns2:table2)\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"2\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", " \ - "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"2", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", ' \ + '"stateMessage"=>[{"lockType"=>"EXCLUSIVE", "description"=>"description"}]' \ "}\n\n", - output) + output + ) end define_test 'list region locks' do @@ -163,14 +167,15 @@ module Hbase "Lock type: SHARED, count: 1\n\n" \ "TABLE(ns3:table3)\n" \ "Lock type: SHARED, count: 1\n\n" \ - "REGION(" << region_info.getEncodedName << ")\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"3\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", " \ - "\"stateMessage\"=>[{\"lockType\"=>\"EXCLUSIVE\", \"description\"=>\"description\"}]" \ + 'REGION(' << region_info.getEncodedName << ")\n" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"3", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", ' \ + '"stateMessage"=>[{"lockType"=>"EXCLUSIVE", "description"=>"description"}]' \ "}\n\n", - output) + output + ) end define_test 'list waiting locks' do @@ -192,22 +197,23 @@ module Hbase "NAMESPACE(ns4)\n" \ "Lock type: SHARED, count: 1\n\n" \ "TABLE(ns4:table4)\n" \ - "Lock type: EXCLUSIVE, procedure: {" \ - "\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"1\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", \"stateMessage\"=>[{" \ - "\"lockType\"=>\"EXCLUSIVE\", " \ - "\"tableName\"=>{\"namespace\"=>\"bnM0\", \"qualifier\"=>\"dGFibGU0\"" \ + 'Lock type: EXCLUSIVE, procedure: {' \ + '"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"1", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", "stateMessage"=>[{' \ + '"lockType"=>"EXCLUSIVE", ' \ + '"tableName"=>{"namespace"=>"bnM0", "qualifier"=>"dGFibGU0"' \ "}, \"description\"=>\"description\"}]}\n" \ "Waiting procedures\n" \ - "{\"className\"=>\"org.apache.hadoop.hbase.master.locking.LockProcedure\", " \ - "\"procId\"=>\"2\", \"submittedTime\"=>\"0\", \"state\"=>\"RUNNABLE\", " \ - "\"lastUpdate\"=>\"0\", \"stateMessage\"=>[{" \ - "\"lockType\"=>\"SHARED\", " \ - "\"tableName\"=>{\"namespace\"=>\"bnM0\", \"qualifier\"=>\"dGFibGU0\"}, " \ + '{"className"=>"org.apache.hadoop.hbase.master.locking.LockProcedure", ' \ + '"procId"=>"2", "submittedTime"=>"0", "state"=>"RUNNABLE", ' \ + '"lastUpdate"=>"0", "stateMessage"=>[{' \ + '"lockType"=>"SHARED", ' \ + '"tableName"=>{"namespace"=>"bnM0", "qualifier"=>"dGFibGU0"}, ' \ "\"description\"=>\"description\"}]}\n" \ "1 row(s)\n\n", - output) + output + ) end end end diff --git a/hbase-shell/src/test/ruby/shell/list_procedures_test.rb b/hbase-shell/src/test/ruby/shell/list_procedures_test.rb index 1cad23b0057f2b923543a0b1b0916537d943303e..ee45c434935091025f2056ab0061a25479809a19 100644 --- a/hbase-shell/src/test/ruby/shell/list_procedures_test.rb +++ b/hbase-shell/src/test/ruby/shell/list_procedures_test.rb @@ -41,7 +41,7 @@ module Hbase def create_procedure_regexp(table_name) regexp_string = '[0-9]+ .*ShellTestProcedure SUCCESS.*' \ - "\[{\"value\"=>\"#{table_name}\"}\]"; + "\[{\"value\"=>\"#{table_name}\"}\]" Regexp.new(regexp_string) end @@ -59,9 +59,7 @@ module Hbase lines = output.split(/\n/) lines.each do |line| - if regexp.match(line) - matching_lines += 1 - end + matching_lines += 1 if regexp.match(line) end assert_equal(1, matching_lines) diff --git a/hbase-shell/src/test/ruby/shell/noninteractive_test.rb b/hbase-shell/src/test/ruby/shell/noninteractive_test.rb index 0fae4cbb79a7401cf2240619f74a7f54b15fa497..a96e8b2cf3993d444df58f2e0f8cdedc990ab0b6 100644 --- a/hbase-shell/src/test/ruby/shell/noninteractive_test.rb +++ b/hbase-shell/src/test/ruby/shell/noninteractive_test.rb @@ -23,7 +23,7 @@ class NonInteractiveTest < Test::Unit::TestCase @shell = Shell::Shell.new(@hbase, false) end - define_test "Shell::Shell noninteractive mode should throw" do + define_test 'Shell::Shell noninteractive mode should throw' do # XXX Exception instead of StandardError because we throw things # that aren't StandardError assert_raise(ArgumentError) do @@ -35,6 +35,6 @@ class NonInteractiveTest < Test::Unit::TestCase # create a table that exists @shell.command('create', 'foo', 'family_1') end - assert_equal("Table already exists: foo!", exception.message) + assert_equal('Table already exists: foo!', exception.message) end end diff --git a/hbase-shell/src/test/ruby/shell/rsgroup_shell_test.rb b/hbase-shell/src/test/ruby/shell/rsgroup_shell_test.rb index ab7ba0d41fb148c46d03d3a2bdcef2dc5482701d..43dfc2b08535e9e6db74bc0e83c6507b77cb095f 100644 --- a/hbase-shell/src/test/ruby/shell/rsgroup_shell_test.rb +++ b/hbase-shell/src/test/ruby/shell/rsgroup_shell_test.rb @@ -27,7 +27,7 @@ module Hbase @shell = Shell::Shell.new(@hbase) connection = $TEST_CLUSTER.getConnection @rsgroup_admin = - org.apache.hadoop.hbase.rsgroup.RSGroupAdminClient.new(connection) + org.apache.hadoop.hbase.rsgroup.RSGroupAdminClient.new(connection) end define_test 'Test Basic RSGroup Commands' do @@ -120,13 +120,13 @@ module Hbase # we test exceptions that could be thrown by the ruby wrappers define_test 'Test bogus arguments' do assert_raise(ArgumentError) do - @hbase.rsgroup_admin().get_rsgroup('foobar') + @hbase.rsgroup_admin.get_rsgroup('foobar') end assert_raise(ArgumentError) do - @hbase.rsgroup_admin().get_rsgroup_of_server('foobar:123') + @hbase.rsgroup_admin.get_rsgroup_of_server('foobar:123') end assert_raise(ArgumentError) do - @hbase.rsgroup_admin().get_rsgroup_of_table('foobar') + @hbase.rsgroup_admin.get_rsgroup_of_table('foobar') end 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 e7f5b2639ceb222aa8c235688dfc3159d84a5765..546c73e766d7998e2f816f53d65b7cf00ce8d01e 100644 --- a/hbase-shell/src/test/ruby/shell/shell_test.rb +++ b/hbase-shell/src/test/ruby/shell/shell_test.rb @@ -28,31 +28,31 @@ class ShellTest < Test::Unit::TestCase @shell = Shell::Shell.new(@hbase) end - define_test "Shell::Shell#admin should return an admin instance" do + define_test 'Shell::Shell#admin should return an admin instance' do assert_kind_of(Hbase::Admin, @shell.admin) end - define_test "Shell::Shell#admin should cache admin instances" do + define_test 'Shell::Shell#admin should cache admin instances' do assert_same(@shell.admin, @shell.admin) end #------------------------------------------------------------------------------- - define_test "Shell::Shell#hbase_table should return a table instance" do + define_test 'Shell::Shell#hbase_table should return a table instance' do assert_kind_of(Hbase::Table, @shell.hbase_table('hbase:meta')) end - define_test "Shell::Shell#hbase_table should not cache table instances" do + define_test 'Shell::Shell#hbase_table should not cache table instances' do 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 + 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 + define_test 'Shell::Shell#export_commands should export command methods to specified object' do module Foo; end assert(!Foo.respond_to?(:version)) @shell.export_commands(Foo) @@ -61,13 +61,13 @@ class ShellTest < Test::Unit::TestCase #------------------------------------------------------------------------------- - define_test "Shell::Shell#command_instance should return a command class" do + define_test 'Shell::Shell#command_instance should return a command class' do assert_kind_of(Shell::Commands::Command, @shell.command_instance('version')) end #------------------------------------------------------------------------------- - define_test "Shell::Shell#command should execute a command" do + define_test 'Shell::Shell#command should execute a command' do @shell.command('version') end @@ -83,7 +83,7 @@ class ShellTest < Test::Unit::TestCase #----------------------------------------------------------------------------- - define_test "Shell::Shell interactive mode should not throw" do + define_test 'Shell::Shell interactive mode should not throw' do # incorrect number of arguments @shell.command('create', 'nothrow_table') @shell.command('create', 'nothrow_table', 'family_1') diff --git a/hbase-shell/src/test/ruby/test_helper.rb b/hbase-shell/src/test/ruby/test_helper.rb index 78fba7a2063560f1a985eea20b9edeeb6ddbe06d..245e3ac10f3292c7fd154fda78eba3a6a54eb329 100644 --- a/hbase-shell/src/test/ruby/test_helper.rb +++ b/hbase-shell/src/test/ruby/test_helper.rb @@ -21,9 +21,14 @@ module Testing # ... # end def define_test(name, &block) - test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym - defined = instance_method(test_name) rescue false + test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym + defined = begin + instance_method(test_name) + rescue StandardError + false + end raise "#{test_name} is already defined in #{self}" if defined + if block_given? define_method(test_name, &block) else @@ -45,7 +50,7 @@ module Hbase hbase = ::Hbase::Hbase.new($TEST_CLUSTER.getConfiguration) @shell = ::Shell::Shell.new(hbase, interactive = false) end - + def shutdown @shell.hbase.shutdown end @@ -90,14 +95,12 @@ module Hbase def create_test_table(name) # Create the table if needed unless admin.exists?(name) - command(:create, name, {'NAME' => 'x', 'VERSIONS' => 5}, 'y') + command(:create, name, { 'NAME' => 'x', 'VERSIONS' => 5 }, 'y') return end # Enable the table if needed - unless admin.enabled?(name) - admin.enable(name) - end + admin.enable(name) unless admin.enabled?(name) end def create_test_table_with_splits(name, splits) @@ -129,40 +132,36 @@ module Hbase def drop_test_table(name) return unless admin.exists?(name) + begin admin.disable(name) if admin.enabled?(name) - rescue => e + rescue StandardError => e puts "IGNORING DISABLE TABLE ERROR: #{e}" end begin admin.drop(name) - rescue => e + rescue StandardError => e puts "IGNORING DROP TABLE ERROR: #{e}" end end - def replication_status(format,type) - return admin.status(format,type) + def replication_status(format, type) + admin.status(format, type) end - def drop_test_snapshot() - begin - admin.delete_all_snapshot(".*") - rescue => e - puts "IGNORING DELETE ALL SNAPSHOT ERROR: #{e}" - end + def drop_test_snapshot + admin.delete_all_snapshot('.*') + rescue StandardError => e + puts "IGNORING DELETE ALL SNAPSHOT ERROR: #{e}" end - def capture_stdout - begin - old_stdout = $stdout - $stdout = StringIO.new('','w') - yield - $stdout.string - ensure - $stdout = old_stdout - end + old_stdout = $stdout + $stdout = StringIO.new('', 'w') + yield + $stdout.string + ensure + $stdout = old_stdout end end end @@ -172,4 +171,4 @@ Test::Unit::TestCase.extend(Testing::Declarative) # Add the $HBASE_HOME/lib/ruby directory to the ruby # load path so I can load up my HBase ruby modules -$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "..", "main", "ruby") +$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..', 'main', 'ruby') diff --git a/hbase-shell/src/test/ruby/tests_runner.rb b/hbase-shell/src/test/ruby/tests_runner.rb index 73d4a6e71133d0b224f49d9042b5be9b3b78c6c6..0972e2eb3e9b74db94355c32813c5ec081c8b0ff 100644 --- a/hbase-shell/src/test/ruby/tests_runner.rb +++ b/hbase-shell/src/test/ruby/tests_runner.rb @@ -26,17 +26,17 @@ unless defined?($TEST_CLUSTER) # Set logging level to avoid verboseness org.apache.log4j.Logger.getRootLogger.setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.zookeeper").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.hdfs").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.hbase").setLevel(org.apache.log4j.Level::OFF) - org.apache.log4j.Logger.getLogger("org.apache.hadoop.ipc.HBaseServer").setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.zookeeper').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.hdfs').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.hbase').setLevel(org.apache.log4j.Level::OFF) + org.apache.log4j.Logger.getLogger('org.apache.hadoop.ipc.HBaseServer').setLevel(org.apache.log4j.Level::OFF) java_import org.apache.hadoop.hbase.HBaseTestingUtility $TEST_CLUSTER = HBaseTestingUtility.new - $TEST_CLUSTER.configuration.setInt("hbase.regionserver.msginterval", 100) - $TEST_CLUSTER.configuration.setInt("hbase.client.pause", 250) - $TEST_CLUSTER.configuration.set("hbase.quota.enabled", "true") + $TEST_CLUSTER.configuration.setInt('hbase.regionserver.msginterval', 100) + $TEST_CLUSTER.configuration.setInt('hbase.client.pause', 250) + $TEST_CLUSTER.configuration.set('hbase.quota.enabled', 'true') $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.period', 5000) $TEST_CLUSTER.configuration.set('hbase.master.quotas.snapshot.chore.delay', 5000) $TEST_CLUSTER.configuration.setInt(org.apache.hadoop.hbase.HConstants::HBASE_CLIENT_RETRIES_NUMBER, 6) @@ -46,7 +46,7 @@ end require 'test_helper' -puts "Running tests..." +puts 'Running tests...' if java.lang.System.get_property('shell.test.include') includes = Set.new(java.lang.System.get_property('shell.test.include').split(',')) @@ -56,20 +56,20 @@ if java.lang.System.get_property('shell.test.exclude') excludes = Set.new(java.lang.System.get_property('shell.test.exclude').split(',')) end -files = Dir[ File.dirname(__FILE__) + "/**/*_test.rb" ] +files = Dir[File.dirname(__FILE__) + '/**/*_test.rb'] files.each do |file| filename = File.basename(file) - if includes != nil && !includes.include?(filename) + if !includes.nil? && !includes.include?(filename) puts "Skip #{filename} because of not included" next end - if excludes != nil && excludes.include?(filename) + if !excludes.nil? && excludes.include?(filename) puts "Skip #{filename} because of excluded" next end begin load(file) - rescue => e + rescue StandardError => e puts "ERROR: #{e}" raise end @@ -83,11 +83,11 @@ if java.lang.System.get_property('shell.test') runner_args << "--testcase=#{shell_test_pattern}" end # first couple of args are to match the defaults, so we can pass options to limit the tests run -if !(Test::Unit::AutoRunner.run(false, nil, runner_args)) - raise "Shell unit tests failed. Check output file for details." +unless Test::Unit::AutoRunner.run(false, nil, runner_args) + raise 'Shell unit tests failed. Check output file for details.' end -puts "Done with tests! Shutting down the cluster..." +puts 'Done with tests! Shutting down the cluster...' if @own_cluster $TEST_CLUSTER.shutdownMiniCluster java.lang.System.exit(0) -- 2.17.2 (Apple Git-113)