Skip to content

Commit

Permalink
HBASE-24371 Add more details when print CompactionConfiguration info (#…
Browse files Browse the repository at this point in the history
…1711)

Signed-off-by: Anoop Sam John <anoopsamjohn@apache.org>
  • Loading branch information
binlijin committed May 27, 2020
1 parent abe5a05 commit 6e1d7f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.hadoop.hbase.regionserver;

import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;

Expand Down Expand Up @@ -53,4 +54,8 @@ public interface StoreConfigInformation {
* The number of files required before flushes for this store will be blocked.
*/
long getBlockingFileCount();

RegionInfo getRegionInfo();

String getColumnFamilyName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.util.StringUtils;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
Expand Down Expand Up @@ -154,7 +155,8 @@ public String toString() {
+ " major period %d, major jitter %f, min locality to compact %f;"
+ " tiered compaction: max_age %d, incoming window min %d,"
+ " compaction policy for tiered window %s, single output for minor %b,"
+ " compaction window factory %s",
+ " compaction window factory %s,"
+ " region %s columnFamilyName %s",
StringUtils.byteDesc(minCompactSize),
StringUtils.byteDesc(maxCompactSize),
StringUtils.byteDesc(offPeakMaxCompactSize),
Expand All @@ -170,7 +172,9 @@ public String toString() {
dateTieredIncomingWindowMin,
compactionPolicyForDateTieredWindow,
dateTieredSingleOutputForMinorCompaction,
dateTieredCompactionWindowFactory
dateTieredCompactionWindowFactory,
RegionInfo.prettyPrint(storeConfigInfo.getRegionInfo().getEncodedName()),
storeConfigInfo.getColumnFamilyName()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.regionserver.compactions.DefaultCompactor;
import org.apache.hadoop.hbase.regionserver.compactions.RatioBasedCompactionPolicy;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void testCustomParts() throws Exception {
conf.set(DefaultStoreEngine.DEFAULT_STORE_FLUSHER_CLASS_KEY,
DummyStoreFlusher.class.getName());
HStore mockStore = Mockito.mock(HStore.class);
Mockito.when(mockStore.getRegionInfo()).thenReturn(HRegionInfo.FIRST_META_REGIONINFO);
StoreEngine<?, ?, ?, ?> se = StoreEngine.create(mockStore, conf, CellComparatorImpl.COMPARATOR);
Assert.assertTrue(se instanceof DefaultStoreEngine);
Assert.assertTrue(se.getCompactionPolicy() instanceof DummyCompactionPolicy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext;
import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequestImpl;
import org.apache.hadoop.hbase.regionserver.compactions.StripeCompactionPolicy;
Expand Down Expand Up @@ -118,6 +119,7 @@ private static HStoreFile createFile() throws Exception {

private static TestStoreEngine createEngine(Configuration conf) throws Exception {
HStore store = mock(HStore.class);
when(store.getRegionInfo()).thenReturn(HRegionInfo.FIRST_META_REGIONINFO);
CellComparatorImpl kvComparator = mock(CellComparatorImpl.class);
return (TestStoreEngine)StoreEngine.create(store, conf, kvComparator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void testSingleStripeCompaction() throws Exception {
conf.setInt(StripeStoreConfig.MAX_FILES_KEY, 4);
conf.setLong(StripeStoreConfig.SIZE_TO_SPLIT_KEY, 1000); // make sure the are no splits
StoreConfigInformation sci = mock(StoreConfigInformation.class);
when(sci.getRegionInfo()).thenReturn(HRegionInfo.FIRST_META_REGIONINFO);
StripeStoreConfig ssc = new StripeStoreConfig(conf, sci);
StripeCompactionPolicy policy = new StripeCompactionPolicy(conf, sci, ssc) {
@Override
Expand Down Expand Up @@ -476,6 +477,7 @@ private static StripeCompactionPolicy createPolicy(Configuration conf,
conf.setInt(StripeStoreConfig.INITIAL_STRIPE_COUNT_KEY, initialCount);
StoreConfigInformation sci = mock(StoreConfigInformation.class);
when(sci.getStoreFileTtl()).thenReturn(hasTtl ? defaultTtl : Long.MAX_VALUE);
when(sci.getRegionInfo()).thenReturn(HRegionInfo.FIRST_META_REGIONINFO);
StripeStoreConfig ssc = new StripeStoreConfig(conf, sci);
return new StripeCompactionPolicy(conf, sci, ssc);
}
Expand Down

0 comments on commit 6e1d7f0

Please sign in to comment.