hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liushao...@apache.org
Subject hbase git commit: HBASE-14591 Region with reference hfile may split after a forced split in IncreasingToUpperBoundRegionSplitPolicy
Date Wed, 14 Oct 2015 02:23:54 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 bced41b11 -> bbcb53a21


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/bbcb53a2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bbcb53a2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bbcb53a2

Branch: refs/heads/0.98
Commit: bbcb53a21527a65e44dcc9e9d03eb20b3e5f9ebb
Parents: bced41b
Author: Liu Shaohui <liushaohui@xiaomi.com>
Authored: Wed Oct 14 10:23:43 2015 +0800
Committer: Liu Shaohui <liushaohui@xiaomi.com>
Committed: Wed Oct 14 10:23:43 2015 +0800

----------------------------------------------------------------------
 ...IncreasingToUpperBoundRegionSplitPolicy.java |  4 +--
 .../regionserver/TestRegionSplitPolicy.java     | 28 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bbcb53a2/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 18bb376..7fbb73f 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
@@ -65,7 +65,7 @@ extends ConstantSizeRegionSplitPolicy {
 
   @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();
@@ -89,7 +89,7 @@ extends ConstantSizeRegionSplitPolicy {
       }
     }
 
-    return foundABigStore;
+    return foundABigStore | force;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/bbcb53a2/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 73c9403..c5ef972 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
@@ -63,6 +63,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.put(new byte[]{1}, 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,


Mime
View raw message