HBASE-20449 The minimun number of region should be configurable in Normalizer

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
wangyu 2018-04-18 18:09:03 +08:00 committed by tedyu
parent f4f2b68238
commit 80cbc0d1fe
2 changed files with 12 additions and 3 deletions

View File

@ -616,6 +616,11 @@ possible configurations would overwhelm and obscure the important.
<value>300000</value> <value>300000</value>
<description>Period at which the region normalizer runs in the Master.</description> <description>Period at which the region normalizer runs in the Master.</description>
</property> </property>
<property>
<name>hbase.normalizer.min.region.count</name>
<value>3</value>
<description>configure the minimum number of regions</description>
</property>
<property> <property>
<name>hbase.regions.slop</name> <name>hbase.regions.slop</name>
<value>0.001</value> <value>0.001</value>

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseIOException; import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.RegionMetrics; import org.apache.hadoop.hbase.RegionMetrics;
import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.ServerName;
@ -61,11 +62,14 @@ import org.apache.hadoop.hbase.shaded.protobuf.RequestConverter;
public class SimpleRegionNormalizer implements RegionNormalizer { public class SimpleRegionNormalizer implements RegionNormalizer {
private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class); private static final Logger LOG = LoggerFactory.getLogger(SimpleRegionNormalizer.class);
private static final int MIN_REGION_COUNT = 3; private int minRegionCount;
private MasterServices masterServices; private MasterServices masterServices;
private MasterRpcServices masterRpcServices; private MasterRpcServices masterRpcServices;
private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length]; private static long[] skippedCount = new long[NormalizationPlan.PlanType.values().length];
public SimpleRegionNormalizer() {
minRegionCount = HBaseConfiguration.create().getInt("hbase.normalizer.min.region.count", 3);
}
/** /**
* Set the master service. * Set the master service.
* @param masterServices inject instance of MasterServices * @param masterServices inject instance of MasterServices
@ -131,10 +135,10 @@ public class SimpleRegionNormalizer implements RegionNormalizer {
getRegionsOfTable(table); getRegionsOfTable(table);
//TODO: should we make min number of regions a config param? //TODO: should we make min number of regions a config param?
if (tableRegions == null || tableRegions.size() < MIN_REGION_COUNT) { if (tableRegions == null || tableRegions.size() < minRegionCount) {
int nrRegions = tableRegions == null ? 0 : tableRegions.size(); int nrRegions = tableRegions == null ? 0 : tableRegions.size();
LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number" LOG.debug("Table " + table + " has " + nrRegions + " regions, required min number"
+ " of regions for normalizer to run is " + MIN_REGION_COUNT + ", not running normalizer"); + " of regions for normalizer to run is " + minRegionCount + ", not running normalizer");
return null; return null;
} }