hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject hbase git commit: HBASE-13412 Region split decisions should have jitter
Date Wed, 08 Apr 2015 00:22:55 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 8dbe956eb -> bbdd50b9c


HBASE-13412 Region split decisions should have jitter


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/bbdd50b9
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/bbdd50b9
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/bbdd50b9

Branch: refs/heads/branch-1
Commit: bbdd50b9c5ad958bfb56f21ef2fdbc057de22f54
Parents: 8dbe956
Author: Elliott Clark <eclark@apache.org>
Authored: Mon Apr 6 10:22:32 2015 -0700
Committer: Elliott Clark <eclark@apache.org>
Committed: Tue Apr 7 17:20:26 2015 -0700

----------------------------------------------------------------------
 .../ConstantSizeRegionSplitPolicy.java           |  6 ++++++
 .../regionserver/TestRegionSplitPolicy.java      | 19 +++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bbdd50b9/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.java
index 2459ae6..66ef712 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ConstantSizeRegionSplitPolicy.java
@@ -23,6 +23,8 @@ import org.apache.hadoop.hbase.HBaseInterfaceAudience;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 
+import java.util.Random;
+
 /**
  * A {@link RegionSplitPolicy} implementation which splits a region
  * as soon as any of its store files exceeds a maximum configurable
@@ -34,6 +36,8 @@ import org.apache.hadoop.hbase.HTableDescriptor;
  */
 @InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.CONFIG)
 public class ConstantSizeRegionSplitPolicy extends RegionSplitPolicy {
+  private static final Random RANDOM = new Random();
+
   private long desiredMaxFileSize;
 
   @Override
@@ -48,6 +52,8 @@ public class ConstantSizeRegionSplitPolicy extends RegionSplitPolicy {
       this.desiredMaxFileSize = conf.getLong(HConstants.HREGION_MAX_FILESIZE,
         HConstants.DEFAULT_MAX_FILE_SIZE);
     }
+    double jitter = conf.getDouble("hbase.hregion.max.filesize.jitter", 0.25D);
+    this.desiredMaxFileSize += (long)(desiredMaxFileSize * (RANDOM.nextFloat() - 0.5D) *
jitter);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/bbdd50b9/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 ec64628..3146635 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
@@ -109,14 +109,21 @@ public class TestRegionSplitPolicy {
     // now be no longer be splittable since split size has gone up.
     regions.add(mockRegion);
     assertFalse(policy.shouldSplit());
-    // Quadruple (2 squared) the store size and make sure its just over; verify it'll split
-    Mockito.doReturn((flushSize * 2 * 2 * 2) + 1).when(mockStore).getSize();
+    // make sure its just over; verify it'll split
+    Mockito.doReturn((long)(maxSplitSize * 1.025 + 1)).when(mockStore).getSize();
     assertTrue(policy.shouldSplit());
 
     // Finally assert that even if loads of regions, we'll split at max size
-    assertEquals(maxSplitSize, policy.getSizeToCheck(1000));
+    assertWithinJitter(maxSplitSize, policy.getSizeToCheck(1000));
     // Assert same is true if count of regions is zero.
-    assertEquals(maxSplitSize, policy.getSizeToCheck(0));
+    assertWithinJitter(maxSplitSize, policy.getSizeToCheck(0));
+  }
+
+  private void assertWithinJitter(long maxSplitSize, long sizeToCheck) {
+    assertTrue("Size greater than lower bound of jitter",
+        (long)(maxSplitSize * 0.75) <= sizeToCheck);
+    assertTrue("Size less than upper bound of jitter",
+        (long)(maxSplitSize * 1.25) >= sizeToCheck);
   }
 
   @Test
@@ -128,13 +135,13 @@ public class TestRegionSplitPolicy {
     ConstantSizeRegionSplitPolicy policy =
         (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(
             mockRegion, conf);
-    assertEquals(1234L, policy.getDesiredMaxFileSize());
+    assertWithinJitter(1234L, policy.getDesiredMaxFileSize());
 
     // If specified in HTD, should use that
     htd.setMaxFileSize(9999L);
     policy = (ConstantSizeRegionSplitPolicy)RegionSplitPolicy.create(
         mockRegion, conf);
-    assertEquals(9999L, policy.getDesiredMaxFileSize());
+    assertWithinJitter(9999L, policy.getDesiredMaxFileSize());
   }
 
   /**


Mime
View raw message