HBASE-18894: null pointer exception in list_regions in shell command

Signed-off-by: Mike Drob <mdrob@apache.org>
This commit is contained in:
Yi Liang 2017-09-28 13:07:27 -07:00 committed by Mike Drob
parent 24e40f3e85
commit 176d8bd2c7
1 changed files with 10 additions and 1 deletions

View File

@ -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." raise "#{cols} must be an array of strings. Possible values are SERVER_NAME, REGION_NAME, START_KEY, END_KEY, SIZE, REQ, LOCALITY."
end end
error = false
admin_instance = admin.instance_variable_get('@admin') admin_instance = admin.instance_variable_get('@admin')
conn_instance = admin_instance.getConnection conn_instance = admin_instance.getConnection
cluster_status = admin_instance.getClusterStatus cluster_status = admin_instance.getClusterStatus
@ -105,6 +106,12 @@ EOF
region_load_map = cluster_status.getLoad(server_name).getRegionsLoad region_load_map = cluster_status.getLoad(server_name).getRegionsLoad
region_load = region_load_map.get(hregion_info.getRegionName) 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 # Ignore regions which exceed our locality threshold
next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold next unless accept_region_for_locality? region_load.getDataLocality, locality_threshold
result_hash = {} result_hash = {}
@ -157,12 +164,14 @@ EOF
@end_time = Time.now @end_time = Time.now
return if error
size_hash.each do |param, length| size_hash.each do |param, length|
printf(" %#{length}s |", param) printf(" %#{length}s |", param)
end end
printf("\n") printf("\n")
size_hash.each do |_param, length| size_hash.each_value do |length|
str = '-' * length str = '-' * length
printf(" %#{length}s |", str) printf(" %#{length}s |", str)
end end