From dff86542d558394cc87ede256bd5432d071ed73f Mon Sep 17 00:00:00 2001 From: "Apekshit(Appy) Sharma" Date: Wed, 23 Sep 2015 01:17:50 -0700 Subject: [PATCH] HBASE-14469 Fix comment, validation and logging in HeapMemorySizeUtil.getGlobalMemStoreLowerMark --- .../hbase/io/util/HeapMemorySizeUtil.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/HeapMemorySizeUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/HeapMemorySizeUtil.java index 7cfa35d93f4..5bec65d2ba6 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/HeapMemorySizeUtil.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/util/HeapMemorySizeUtil.java @@ -90,24 +90,31 @@ public class HeapMemorySizeUtil { } /** - * Retrieve configured size for global memstore lower water mark as percentage of total heap. - * @param c - * @param globalMemStorePercent + * Retrieve configured size for global memstore lower water mark as fraction of global memstore + * size. */ - public static float getGlobalMemStoreLowerMark(final Configuration c, float globalMemStorePercent) { - String lowMarkPercentStr = c.get(MEMSTORE_SIZE_LOWER_LIMIT_KEY); + public static float getGlobalMemStoreLowerMark(final Configuration conf, float globalMemStorePercent) { + String lowMarkPercentStr = conf.get(MEMSTORE_SIZE_LOWER_LIMIT_KEY); if (lowMarkPercentStr != null) { - return Float.parseFloat(lowMarkPercentStr); + float lowMarkPercent = Float.parseFloat(lowMarkPercentStr); + if (lowMarkPercent > 1.0f) { + LOG.error("Bad configuration value for " + MEMSTORE_SIZE_LOWER_LIMIT_KEY + ": " + + lowMarkPercent + ". Using 1.0f instead."); + lowMarkPercent = 1.0f; + } + return lowMarkPercent; } - String lowerWaterMarkOldValStr = c.get(MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY); + String lowerWaterMarkOldValStr = conf.get(MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY); if (lowerWaterMarkOldValStr != null) { LOG.warn(MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY + " is deprecated. Instead use " + MEMSTORE_SIZE_LOWER_LIMIT_KEY); float lowerWaterMarkOldVal = Float.parseFloat(lowerWaterMarkOldValStr); if (lowerWaterMarkOldVal > globalMemStorePercent) { lowerWaterMarkOldVal = globalMemStorePercent; - LOG.info("Setting globalMemStoreLimitLowMark == globalMemStoreLimit " + "because supplied " - + MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY + " was > " + MEMSTORE_SIZE_OLD_KEY); + LOG.error("Value of " + MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY + " (" + lowerWaterMarkOldVal + + ") is greater than global memstore limit (" + globalMemStorePercent + ") set by " + + MEMSTORE_SIZE_KEY + "/" + MEMSTORE_SIZE_OLD_KEY + ". Setting memstore lower limit " + + "to " + globalMemStorePercent); } return lowerWaterMarkOldVal / globalMemStorePercent; }