From 50c3203bbe1e40bba4615b581d5eb766780a624f Mon Sep 17 00:00:00 2001 From: Yi Liang Date: Thu, 28 Sep 2017 13:07:27 -0700 Subject: [PATCH] HBASE-18894: null pointer exception in list_regions in shell command Signed-off-by: Mike Drob --- hbase-shell/src/main/ruby/shell/commands/list_regions.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 5feb926140..bcc0c4aaf3 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -77,6 +77,7 @@ EOF raise "#{cols} must be an array of strings. Possible values are SERVER_NAME, REGION_NAME, START_KEY, END_KEY, SIZE, REQ, LOCALITY." end + error = false admin_instance = admin.instance_variable_get('@admin') conn_instance = admin_instance.getConnection cluster_status = admin_instance.getClusterStatus @@ -105,6 +106,12 @@ EOF region_load_map = cluster_status.getLoad(server_name).getRegionsLoad region_load = region_load_map.get(hregion_info.getRegionName) + if region_load.nil? + puts "Can not find region: #{hregion_info.getRegionName} , it may be disabled or in transition\n" + error = true + break + end + # Ignore regions which exceed our locality threshold next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold result_hash = {} @@ -157,12 +164,14 @@ EOF @end_time = Time.now + return if error + size_hash.each do |param, length| printf(" %#{length}s |", param) end printf("\n") - size_hash.each do |_param, length| + size_hash.each_value do |length| str = '-' * length printf(" %#{length}s |", str) end -- 2.14.1