From 5f3c0b7f9be00430e8ea53b7d4afae5f6f3a8b3b Mon Sep 17 00:00:00 2001 From: Ted Yu Date: Tue, 1 Jul 2014 16:32:03 +0000 Subject: [PATCH] HBASE-11439 StripeCompaction may not obey the OffPeak rule to compaction (Victor Xu) --- .../compactions/StripeCompactionPolicy.java | 2 +- .../compactions/TestStripeCompactionPolicy.java | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java index 7189d216479..22697e987f9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/StripeCompactionPolicy.java @@ -266,7 +266,7 @@ public class StripeCompactionPolicy extends CompactionPolicy { int minFilesLocal = Math.max( allFilesOnly ? sfs.size() : 0, this.config.getStripeCompactMinFiles()); int maxFilesLocal = Math.max(this.config.getStripeCompactMaxFiles(), minFilesLocal); - return stripePolicy.applyCompactionPolicy(sfs, isOffpeak, false, minFilesLocal, maxFilesLocal); + return stripePolicy.applyCompactionPolicy(sfs, false, isOffpeak, minFilesLocal, maxFilesLocal); } /** diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java index 64a41478566..a4f8f5bcd0e 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestStripeCompactionPolicy.java @@ -277,6 +277,22 @@ public class TestStripeCompactionPolicy { verifySingleStripeCompaction(specPolicy, si, 1, null); } + @Test + public void testSplitOffStripeOffPeak() throws Exception { + // for HBASE-11439 + Configuration conf = HBaseConfiguration.create(); + conf.setInt(StripeStoreConfig.MIN_FILES_KEY, 2); + // Select the last 2 files. + StripeCompactionPolicy.StripeInformationProvider si = + createStripesWithSizes(0, 0, new Long[] { defaultSplitSize - 2, 1L, 1L }); + assertEquals(2, createPolicy(conf).selectCompaction(si, al(), false).getRequest().getFiles() + .size()); + // Make sure everything is eligible in offpeak. + conf.setFloat("hbase.hstore.compaction.ratio.offpeak", 500f); + assertEquals(3, createPolicy(conf).selectCompaction(si, al(), true).getRequest().getFiles() + .size()); + } + @Test public void testSplitOffStripeDropDeletes() throws Exception { Configuration conf = HBaseConfiguration.create();