You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2016/09/09 06:20:57 UTC
hbase git commit: HBASE-16309
TestDefaultCompactSelection.testCompactionRatio is flaky
Repository: hbase
Updated Branches:
refs/heads/master e11aafae9 -> 6c8d1f0ae
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/6c8d1f0a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/6c8d1f0a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/6c8d1f0a
Branch: refs/heads/master
Commit: 6c8d1f0ae82b736322a37bafabf795c8b3a0fdd4
Parents: e11aafa
Author: zhangduo <zh...@apache.org>
Authored: Fri Sep 9 11:09:17 2016 +0800
Committer: zhangduo <zh...@apache.org>
Committed: Fri Sep 9 14:20:39 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/6c8d1f0a/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 3386bfd..a3e10f8 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/6c8d1f0a/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 dbd6f11..1513cd0 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
@@ -25,6 +25,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;
@@ -34,6 +36,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
@@ -90,10 +94,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);