diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BusyRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BusyRegionSplitPolicy.java index d51d29441ee..edfded6c426 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BusyRegionSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/BusyRegionSplitPolicy.java @@ -20,10 +20,10 @@ package org.apache.hadoop.hbase.regionserver; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseInterfaceAudience; +import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; /** * This class represents a split policy which makes the split decision based @@ -60,6 +60,12 @@ public class BusyRegionSplitPolicy extends IncreasingToUpperBoundRegionSplitPoli private long blockedRequestCount; private float blockedRate; + @Override + public String toString() { + return "BusyRegionSplitPolicy{" + "maxBlockedRequests=" + maxBlockedRequests + ", minAge=" + + minAge + ", aggregationWindow=" + aggregationWindow + ", " + super.toString() + '}'; + } + @Override protected void configureForRegion(final HRegion region) { super.configureForRegion(region); 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 1f22dc4d2b2..92b5ed8ce94 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 @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -17,14 +17,13 @@ */ package org.apache.hadoop.hbase.regionserver; -import java.util.Random; - +import java.util.concurrent.ThreadLocalRandom; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseInterfaceAudience; import org.apache.hadoop.hbase.HConstants; -import org.apache.yetus.audience.InterfaceAudience; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.procedure2.util.StringUtils; +import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,12 +40,16 @@ import org.slf4j.LoggerFactory; public class ConstantSizeRegionSplitPolicy extends RegionSplitPolicy { private static final Logger LOG = LoggerFactory.getLogger(ConstantSizeRegionSplitPolicy.class); - private static final Random RANDOM = new Random(); - private long desiredMaxFileSize; private double jitterRate; protected boolean overallHRegionFiles; + @Override + public String toString() { + return "ConstantSizeRegionSplitPolicy{" + "desiredMaxFileSize=" + desiredMaxFileSize + + ", jitterRate=" + jitterRate + '}'; + } + @Override protected void configureForRegion(HRegion region) { super.configureForRegion(region); @@ -62,9 +65,9 @@ public class ConstantSizeRegionSplitPolicy extends RegionSplitPolicy { this.overallHRegionFiles = conf.getBoolean(HConstants.OVERALL_HREGION_FILES, HConstants.DEFAULT_OVERALL_HREGION_FILES); double jitter = conf.getDouble("hbase.hregion.max.filesize.jitter", 0.25D); - this.jitterRate = (RANDOM.nextFloat() - 0.5D) * jitter; + this.jitterRate = (ThreadLocalRandom.current().nextFloat() - 0.5D) * jitter; long jitterValue = (long) (this.desiredMaxFileSize * this.jitterRate); - // make sure the long value won't overflow with jitter + // Default jitter is ~12% +/-. Make sure the long value won't overflow with jitter if (this.jitterRate > 0 && jitterValue > (Long.MAX_VALUE - this.desiredMaxFileSize)) { this.desiredMaxFileSize = Long.MAX_VALUE; } else { @@ -100,7 +103,7 @@ public class ConstantSizeRegionSplitPolicy extends RegionSplitPolicy { } if (sumSize > sizeToCheck) { LOG.debug("ShouldSplit because region size is big enough " - + "size={}, sizeToCheck={}{}", StringUtils.humanSize(sumSize), + + "sumSize={}, sizeToCheck={}", StringUtils.humanSize(sumSize), StringUtils.humanSize(sizeToCheck)); return true; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DelimitedKeyPrefixRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DelimitedKeyPrefixRegionSplitPolicy.java index c90860d08ce..33caa936849 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DelimitedKeyPrefixRegionSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DelimitedKeyPrefixRegionSplitPolicy.java @@ -47,6 +47,12 @@ public class DelimitedKeyPrefixRegionSplitPolicy extends IncreasingToUpperBoundR private byte[] delimiter = null; + @Override + public String toString() { + return "DelimitedKeyPrefixRegionSplitPolicy{" + "delimiter=" + Bytes.toStringBinary(delimiter) + + ", " + super.toString() + '}'; + } + @Override protected void configureForRegion(HRegion region) { super.configureForRegion(region); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushAllStoresPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushAllStoresPolicy.java index 97a04f01809..712113cca1b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushAllStoresPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushAllStoresPolicy.java @@ -1,4 +1,4 @@ -/** +/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -26,10 +26,13 @@ import org.apache.yetus.audience.InterfaceAudience; */ @InterfaceAudience.Private public class FlushAllStoresPolicy extends FlushPolicy { + @Override + public String toString() { + return "FlushAllStoresPolicy"; + } @Override public Collection selectStoresToFlush() { return region.stores.values(); } - } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushLargeStoresPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushLargeStoresPolicy.java index 4da1857a88a..8e3c4af6f6e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushLargeStoresPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/FlushLargeStoresPolicy.java @@ -43,6 +43,11 @@ public abstract class FlushLargeStoresPolicy extends FlushPolicy { protected long flushSizeLowerBound = -1; + @Override + public String toString() { + return "FlushLargeStoresPolicy{" + "flushSizeLowerBound=" + flushSizeLowerBound + '}'; + } + protected void setFlushSizeLowerBounds(HRegion region) { int familyNumber = region.getTableDescriptor().getColumnFamilyCount(); // For multiple families, lower bound is the "average flush size" by default diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 44a5879aa40..d54dc799de4 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -1082,7 +1082,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } } - LOG.info("Opened {}; next sequenceid={}", this.getRegionInfo().getShortNameToLog(), nextSeqId); + LOG.info("Opened {}; next sequenceid={}; {}, {}", + this.getRegionInfo().getShortNameToLog(), nextSeqId, this.splitPolicy, this.flushPolicy); // A region can be reopened if failed a split; reset flags this.closing.set(false); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java index 72e8853a41e..97f9851d4cc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/IncreasingToUpperBoundRegionSplitPolicy.java @@ -49,6 +49,12 @@ public class IncreasingToUpperBoundRegionSplitPolicy extends ConstantSizeRegionS protected long initialSize; + @Override + public String toString() { + return "IncreasingToUpperBoundRegionSplitPolicy{" + "initialSize=" + initialSize + + ", " + super.toString() + '}'; + } + @Override protected void configureForRegion(HRegion region) { super.configureForRegion(region); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyPrefixRegionSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyPrefixRegionSplitPolicy.java index 660da57080d..29c7d11ac1d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyPrefixRegionSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyPrefixRegionSplitPolicy.java @@ -40,6 +40,12 @@ public class KeyPrefixRegionSplitPolicy extends IncreasingToUpperBoundRegionSpli private int prefixLength = 0; + @Override + public String toString() { + return "KeyPrefixRegionSplitPolicy{" + "prefixLength=" + prefixLength + ", " + + super.toString() + '}'; + } + @Override protected void configureForRegion(HRegion region) { super.configureForRegion(region); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SteppingSplitPolicy.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SteppingSplitPolicy.java index 84973db7075..8343259ee9d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SteppingSplitPolicy.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SteppingSplitPolicy.java @@ -21,6 +21,11 @@ import org.apache.yetus.audience.InterfaceAudience; @InterfaceAudience.Private public class SteppingSplitPolicy extends IncreasingToUpperBoundRegionSplitPolicy { + @Override + public String toString() { + return "SteppingSplitPolicysuper{" + super.toString() + "}"; + } + /** * @return flushSize * 2 if there's exactly one region of the table in question * found on this regionserver. Otherwise max file size. @@ -31,6 +36,4 @@ public class SteppingSplitPolicy extends IncreasingToUpperBoundRegionSplitPolicy protected long getSizeToCheck(final int tableRegionsCount) { return tableRegionsCount == 1 ? this.initialSize : getDesiredMaxFileSize(); } - - }