You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2015/10/14 04:15:00 UTC
hbase git commit: HBASE-14591 Region with reference hfile may split
after a forced split in IncreasingToUpperBoundRegionSplitPolicy
Repository: hbase
Updated Branches:
refs/heads/master 4754e583f -> 0e41dc18c
HBASE-14591 Region with reference hfile may split after a forced split in IncreasingToUpperBoundRegionSplitPolicy
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/0e41dc18
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/0e41dc18
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/0e41dc18
Branch: refs/heads/master
Commit: 0e41dc18c0fb6a1533eff549f7836c0c9f5d4685
Parents: 4754e58
Author: Liu Shaohui <li...@xiaomi.com>
Authored: Wed Oct 14 10:14:50 2015 +0800
Committer: Liu Shaohui <li...@xiaomi.com>
Committed: Wed Oct 14 10:14:50 2015 +0800
----------------------------------------------------------------------
...IncreasingToUpperBoundRegionSplitPolicy.java | 6 ++---
.../regionserver/TestRegionSplitPolicy.java | 28 ++++++++++++++++++++
2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/0e41dc18/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java
index 8c31f0a..7144cb8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java
@@ -67,9 +67,7 @@ public class IncreasingToUpperBoundRegionSplitPolicy extends ConstantSizeRegionS
@Override
protected boolean shouldSplit() {
- if (region.shouldForceSplit()) {
- return true;
- }
+ boolean force = region.shouldForceSplit();
boolean foundABigStore = false;
// Get count of regions that have the same common table as this.region
int tableRegionsCount = getCountOfCommonTableRegions();
@@ -93,7 +91,7 @@ public class IncreasingToUpperBoundRegionSplitPolicy extends ConstantSizeRegionS
}
}
- return foundABigStore;
+ return foundABigStore | force;
}
/**
http://git-wip-us.apache.org/repos/asf/hbase/blob/0e41dc18/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java
index 3ceb8fe..1c38197 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionSplitPolicy.java
@@ -62,6 +62,34 @@ public class TestRegionSplitPolicy {
}
@Test
+ public void testForceSplitRegionWithReference() throws IOException {
+ htd.setMaxFileSize(1024L);
+ // Add a store above the requisite size. Should split.
+ HStore mockStore = Mockito.mock(HStore.class);
+ Mockito.doReturn(2000L).when(mockStore).getSize();
+ // Act as if there's a reference file or some other reason it can't split.
+ // This should prevent splitting even though it's big enough.
+ Mockito.doReturn(false).when(mockStore).canSplit();
+ stores.add(mockStore);
+
+ conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
+ ConstantSizeRegionSplitPolicy.class.getName());
+ ConstantSizeRegionSplitPolicy policy =
+ (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(mockRegion, conf);
+ assertFalse(policy.shouldSplit());
+ Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
+ assertFalse(policy.shouldSplit());
+
+ Mockito.doReturn(false).when(mockRegion).shouldForceSplit();
+ conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
+ IncreasingToUpperBoundRegionSplitPolicy.class.getName());
+ policy = (IncreasingToUpperBoundRegionSplitPolicy) RegionSplitPolicy.create(mockRegion, conf);
+ assertFalse(policy.shouldSplit());
+ Mockito.doReturn(true).when(mockRegion).shouldForceSplit();
+ assertFalse(policy.shouldSplit());
+ }
+
+ @Test
public void testIncreasingToUpperBoundRegionSplitPolicy() throws IOException {
// Configure IncreasingToUpperBoundRegionSplitPolicy as our split policy
conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,