From commits-return-88231-archive-asf-public=cust-asf.ponee.io@hbase.apache.org Thu Aug 1 01:52:28 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id EE28618062B for ; Thu, 1 Aug 2019 03:52:27 +0200 (CEST) Received: (qmail 83501 invoked by uid 500); 1 Aug 2019 01:52:26 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 83474 invoked by uid 99); 1 Aug 2019 01:52:26 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2019 01:52:26 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E0F5585EC0; Thu, 1 Aug 2019 01:52:25 +0000 (UTC) Date: Thu, 01 Aug 2019 01:52:30 +0000 To: "commits@hbase.apache.org" Subject: [hbase] branch master updated: HBASE-22735 list_regions show basic info for region currently in transition with error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <156462434550.13864.11842980576482192991@gitbox.apache.org> From: apurtell@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: hbase X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 35acf3cb78a8a70a60a96b5d31c2df814f55a338 X-Git-Newrev: 8cfc46d8d0b6d377cfbafc003f408d8cacb06c4e X-Git-Rev: 8cfc46d8d0b6d377cfbafc003f408d8cacb06c4e X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. apurtell pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/hbase.git The following commit(s) were added to refs/heads/master by this push: new 8cfc46d HBASE-22735 list_regions show basic info for region currently in transition with error handling 8cfc46d is described below commit 8cfc46d8d0b6d377cfbafc003f408d8cacb06c4e Author: Viraj Jasani AuthorDate: Mon Jul 29 00:29:59 2019 +0530 HBASE-22735 list_regions show basic info for region currently in transition with error handling Signed-off-by: Andrew Purtell Signed-off-by: Michael Stack --- .../src/main/ruby/shell/commands/list_regions.rb | 58 ++++++++++++++-------- 1 file changed, 37 insertions(+), 21 deletions(-) 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 3d6de4c..dc77ae7 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_regions.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_regions.rb @@ -79,7 +79,6 @@ 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 = org.apache.hadoop.hbase.ClusterStatus.new(admin_instance.getClusterMetrics) @@ -105,17 +104,24 @@ EOF regions.each do |hregion| hregion_info = hregion.getRegion server_name = hregion.getServerName - region_load_map = cluster_status.getLoad(server_name).getRegionsLoad + server_load = cluster_status.getLoad(server_name) + if server_load.nil? + region_load_map = java.util.HashMap.new + else + region_load_map = server_load.getRegionsLoad + end + region_name = hregion_info.getRegionNameAsString 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 + puts "Can not find all details for region: " \ + "#{region_name.strip} ," \ + " it may be disabled or in transition\n" + else + # Ignore regions which exceed our locality threshold + next unless accept_region_for_locality? region_load.getDataLocality, + locality_threshold end - - # 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') @@ -124,36 +130,48 @@ EOF end if size_hash.key?('REGION_NAME') - result_hash.store('REGION_NAME', hregion_info.getRegionNameAsString.strip) - size_hash['REGION_NAME'] = [size_hash['REGION_NAME'], hregion_info.getRegionNameAsString.length].max + result_hash.store('REGION_NAME', region_name.strip) + size_hash['REGION_NAME'] = [size_hash['REGION_NAME'], region_name.length].max end if size_hash.key?('START_KEY') - startKey = Bytes.toStringBinary(hregion_info.getStartKey).strip - result_hash.store('START_KEY', startKey) - size_hash['START_KEY'] = [size_hash['START_KEY'], startKey.length].max + start_key = Bytes.toStringBinary(hregion_info.getStartKey).strip + result_hash.store('START_KEY', start_key) + size_hash['START_KEY'] = [size_hash['START_KEY'], start_key.length].max end if size_hash.key?('END_KEY') - endKey = Bytes.toStringBinary(hregion_info.getEndKey).strip - result_hash.store('END_KEY', endKey) - size_hash['END_KEY'] = [size_hash['END_KEY'], endKey.length].max + end_key = Bytes.toStringBinary(hregion_info.getEndKey).strip + result_hash.store('END_KEY', end_key) + size_hash['END_KEY'] = [size_hash['END_KEY'], end_key.length].max end if size_hash.key?('SIZE') - region_store_file_size = region_load.getStorefileSizeMB.to_s.strip + if region_load.nil? + region_store_file_size = '' + else + region_store_file_size = region_load.getStorefileSizeMB.to_s.strip + end result_hash.store('SIZE', region_store_file_size) size_hash['SIZE'] = [size_hash['SIZE'], region_store_file_size.length].max end if size_hash.key?('REQ') - region_requests = region_load.getRequestsCount.to_s.strip + if region_load.nil? + region_requests = '' + else + region_requests = region_load.getRequestsCount.to_s.strip + end result_hash.store('REQ', region_requests) size_hash['REQ'] = [size_hash['REQ'], region_requests.length].max end if size_hash.key?('LOCALITY') - locality = region_load.getDataLocality.to_s.strip + if region_load.nil? + locality = '' + else + locality = region_load.getDataLocality.to_s.strip + end result_hash.store('LOCALITY', locality) size_hash['LOCALITY'] = [size_hash['LOCALITY'], locality.length].max end @@ -166,8 +184,6 @@ EOF @end_time = Time.now - return if error - size_hash.each do |param, length| printf(" %#{length}s |", param) end