From 64f88906f7cc7265fe0c42a4c42530dbd660c70b Mon Sep 17 00:00:00 2001 From: Aman Poonia Date: Tue, 27 Aug 2019 21:35:57 +0530 Subject: [PATCH] HBASE-22872 Don't try to create normalization plan unnecesarily when split and merge both are disabled Signed-off-by: Reid Chan --- .../normalizer/SimpleRegionNormalizer.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java index a30a13be243..b55d2b6870e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.java @@ -131,7 +131,23 @@ public class SimpleRegionNormalizer implements RegionNormalizer { LOG.debug("Normalization of system table " + table + " isn't allowed"); return null; } - + boolean splitEnabled = true, mergeEnabled = true; + try { + splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null, + RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled(); + } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { + LOG.debug("Unable to determine whether split is enabled", e); + } + try { + mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null, + RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled(); + } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { + LOG.debug("Unable to determine whether split is enabled", e); + } + if (!mergeEnabled && !splitEnabled) { + LOG.debug("Both split and merge are disabled for table: " + table); + return null; + } List plans = new ArrayList<>(); List tableRegions = masterServices.getAssignmentManager().getRegionStates(). getRegionsOfTable(table); @@ -189,19 +205,6 @@ public class SimpleRegionNormalizer implements RegionNormalizer { LOG.debug("Table " + table + ", average region size: " + avgRegionSize); int candidateIdx = 0; - boolean splitEnabled = true, mergeEnabled = true; - try { - splitEnabled = masterRpcServices.isSplitOrMergeEnabled(null, - RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.SPLIT)).getEnabled(); - } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { - LOG.debug("Unable to determine whether split is enabled", e); - } - try { - mergeEnabled = masterRpcServices.isSplitOrMergeEnabled(null, - RequestConverter.buildIsSplitOrMergeEnabledRequest(MasterSwitchType.MERGE)).getEnabled(); - } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { - LOG.debug("Unable to determine whether split is enabled", e); - } while (candidateIdx < tableRegions.size()) { RegionInfo hri = tableRegions.get(candidateIdx); long regionSize = getRegionSize(hri);