hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang...@apache.org
Subject hbase git commit: HBASE-16309 TestDefaultCompactSelection.testCompactionRatio is flaky
Date Fri, 09 Sep 2016 06:21:47 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 b4086795f -> bc4ab4714


HBASE-16309 TestDefaultCompactSelection.testCompactionRatio is flaky


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

Branch: refs/heads/branch-1
Commit: bc4ab47147428068d3b6b6bb2e284709bdf8fc05
Parents: b408679
Author: zhangduo <zhangduo@apache.org>
Authored: Fri Sep 9 11:09:17 2016 +0800
Committer: zhangduo <zhangduo@apache.org>
Committed: Fri Sep 9 14:21:31 2016 +0800

----------------------------------------------------------------------
 .../compactions/RatioBasedCompactionPolicy.java      |  3 ++-
 .../regionserver/TestDefaultCompactSelection.java    | 15 +++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bc4ab471/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
index 7b812cd..b378be7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/RatioBasedCompactionPolicy.java
@@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.regionserver.RSRpcServices;
 import org.apache.hadoop.hbase.regionserver.StoreConfigInformation;
 import org.apache.hadoop.hbase.regionserver.StoreFile;
 import org.apache.hadoop.hbase.regionserver.StoreUtils;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 
 /**
  * The default algorithm for selecting files for compaction.
@@ -61,7 +62,7 @@ public class RatioBasedCompactionPolicy extends SortedCompactionPolicy {
     }
     // TODO: Use better method for determining stamp of last major (HBASE-2990)
     long lowTimestamp = StoreUtils.getLowestTimestamp(filesToCompact);
-    long now = System.currentTimeMillis();
+    long now = EnvironmentEdgeManager.currentTime();
     if (lowTimestamp > 0L && lowTimestamp < (now - mcTime)) {
       // Major compaction time has elapsed.
       long cfTTL = this.storeConfigInfo.getStoreFileTtl();

http://git-wip-us.apache.org/repos/asf/hbase/blob/bc4ab471/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
index 9ed1ccd..38c1d4e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultCompactSelection.java
@@ -26,6 +26,8 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
 import org.apache.hadoop.hbase.regionserver.compactions.RatioBasedCompactionPolicy;
 import org.apache.hadoop.hbase.testclassification.SmallTests;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.hbase.util.TimeOffsetEnvironmentEdge;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -35,6 +37,8 @@ public class TestDefaultCompactSelection extends TestCompactionPolicy {
 
   @Test
   public void testCompactionRatio() throws IOException {
+    TimeOffsetEnvironmentEdge edge = new TimeOffsetEnvironmentEdge();
+    EnvironmentEdgeManager.injectEdge(edge);
     /**
      * NOTE: these tests are specific to describe the implementation of the
      * current compaction algorithm.  Developed to ensure that refactoring
@@ -91,10 +95,17 @@ public class TestDefaultCompactSelection extends TestCompactionPolicy
{
     conf.setFloat("hbase.hregion.majorcompaction.jitter", 0);
     store.storeEngine.getCompactionPolicy().setConf(conf);
     try {
+      // The modTime of the mocked store file is currentTimeMillis, so we need to increase
the
+      // timestamp a bit to make sure that now - lowestModTime is greater than major compaction
+      // period(1ms).
       // trigger an aged major compaction
-      compactEquals(sfCreate(50,25,12,12), 50, 25, 12, 12);
+      List<StoreFile> candidates = sfCreate(50, 25, 12, 12);
+      edge.increment(2);
+      compactEquals(candidates, 50, 25, 12, 12);
       // major sure exceeding maxCompactSize also downgrades aged minors
-      compactEquals(sfCreate(100,50,23,12,12), 23, 12, 12);
+      candidates = sfCreate(100, 50, 23, 12, 12);
+      edge.increment(2);
+      compactEquals(candidates, 23, 12, 12);
     } finally {
       conf.setLong(HConstants.MAJOR_COMPACTION_PERIOD, 1000*60*60*24);
       conf.setFloat("hbase.hregion.majorcompaction.jitter", 0.20F);


Mime
View raw message