HBASE-2844 Capping the number of regions

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@983442 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2010-08-08 15:59:46 +00:00
parent 25ffbc5f11
commit f4ed3cd699
4 changed files with 36 additions and 1 deletions

View File

@ -827,6 +827,7 @@ Release 0.21.0 - Unreleased
HBASE-2886 Add search box to site (Alex Baranau via Stack)
HBASE-2792 Create a better way to chain log cleaners
(Chongxin Li via Stack)
HBASE-2844 Capping the number of regions (Pranav Khaitan via Stack)
NEW FEATURES
HBASE-1961 HBase EC2 scripts

View File

@ -49,11 +49,20 @@ class CompactSplitThread extends Thread {
private final HashSet<HRegion> regionsInQueue = new HashSet<HRegion>();
/**
* Splitting should not take place if the total number of regions exceed this.
* This is not a hard limit to the number of regions but it is a guideline to
* stop splitting after number of online regions is greater than this.
*/
private int regionSplitLimit;
/** @param server */
public CompactSplitThread(HRegionServer server) {
super();
this.server = server;
this.conf = server.conf;
this.regionSplitLimit = conf.getInt("hbase.regionserver.regionSplitLimit",
Integer.MAX_VALUE);
this.frequency =
conf.getLong("hbase.regionserver.thread.splitcompactcheckfrequency",
20 * 1000);
@ -73,7 +82,8 @@ class CompactSplitThread extends Thread {
try {
// Don't interrupt us while we are working
byte [] midKey = r.compactStores();
if (midKey != null && !this.server.isStopRequested()) {
if (shouldSplitRegion() && midKey != null &&
!this.server.isStopRequested()) {
split(r, midKey);
}
} finally {
@ -190,4 +200,15 @@ class CompactSplitThread extends Thread {
public int getCompactionQueueSize() {
return compactionQueue.size();
}
private boolean shouldSplitRegion() {
return (regionSplitLimit > server.getNumberOfOnlineRegions());
}
/**
* @return the regionSplitLimit
*/
public int getRegionSplitLimit() {
return this.regionSplitLimit;
}
}

View File

@ -2544,4 +2544,8 @@ public class HRegionServer implements HRegionInterface,
HRegionServer.class);
doMain(args, regionServerClass);
}
public int getNumberOfOnlineRegions() {
return onlineRegions.size();
}
}

View File

@ -185,6 +185,15 @@
milliseconds.
</description>
</property>
<property>
<name>hbase.regionserver.regionSplitLimit</name>
<value>2147483647</value>
<description>Limit for the number of regions after which no more region
splitting should take place. This is not a hard limit for the number of
regions but acts as a guideline for the regionserver to stop splitting after
a certain limit. Default is set to MAX_INT.
</description>
</property>
<property>
<name>hbase.regionserver.logroll.period</name>
<value>3600000</value>