From 4f06279caaefa7dac795fb88d6711cc234a01600 Mon Sep 17 00:00:00 2001 From: tedyu Date: Mon, 29 Jun 2015 15:00:29 -0700 Subject: [PATCH] HBASE-13989 Threshold for combined MemStore and BlockCache percentages is not checked --- .../hadoop/hbase/regionserver/HeapMemoryManager.java | 9 +++++---- .../hadoop/hbase/regionserver/TestHeapMemoryManager.java | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HeapMemoryManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HeapMemoryManager.java index 8f001a16621..77a9186e0b0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HeapMemoryManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HeapMemoryManager.java @@ -111,6 +111,7 @@ public class HeapMemoryManager { } private boolean doInit(Configuration conf) { + boolean tuningEnabled = true; globalMemStorePercent = HeapMemorySizeUtil.getGlobalMemStorePercent(conf, false); blockCachePercent = conf.getFloat(HFILE_BLOCK_CACHE_SIZE_KEY, HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT); @@ -136,7 +137,7 @@ public class HeapMemoryManager { } if (globalMemStorePercent == globalMemStorePercentMinRange && globalMemStorePercent == globalMemStorePercentMaxRange) { - return false; + tuningEnabled = false; } // Initialize max and min range for block cache blockCachePercentMinRange = conf.getFloat(BLOCK_CACHE_SIZE_MIN_RANGE_KEY, blockCachePercent); @@ -155,9 +156,9 @@ public class HeapMemoryManager { blockCachePercentMaxRange = blockCachePercent; conf.setFloat(BLOCK_CACHE_SIZE_MAX_RANGE_KEY, blockCachePercentMaxRange); } - if (blockCachePercent == blockCachePercentMinRange + if (tuningEnabled && blockCachePercent == blockCachePercentMinRange && blockCachePercent == blockCachePercentMaxRange) { - return false; + tuningEnabled = false; } int gml = (int) (globalMemStorePercentMaxRange * CONVERT_TO_PERCENTAGE); @@ -183,7 +184,7 @@ public class HeapMemoryManager { + globalMemStorePercentMinRange + " and " + BLOCK_CACHE_SIZE_MAX_RANGE_KEY + " is " + blockCachePercentMaxRange); } - return true; + return tuningEnabled; } public void start(ChoreService service) { diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHeapMemoryManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHeapMemoryManager.java index 76d182f1690..202e0846084 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHeapMemoryManager.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHeapMemoryManager.java @@ -58,8 +58,9 @@ public class TestHeapMemoryManager { @Test public void testAutoTunerShouldBeOffWhenMaxMinRangesForMemstoreIsNotGiven() throws Exception { Configuration conf = HBaseConfiguration.create(); + conf.setFloat(HeapMemorySizeUtil.MEMSTORE_SIZE_KEY, 0.02f); conf.setFloat(HeapMemoryManager.BLOCK_CACHE_SIZE_MAX_RANGE_KEY, 0.75f); - conf.setFloat(HeapMemoryManager.BLOCK_CACHE_SIZE_MIN_RANGE_KEY, 0.05f); + conf.setFloat(HeapMemoryManager.BLOCK_CACHE_SIZE_MIN_RANGE_KEY, 0.03f); HeapMemoryManager manager = new HeapMemoryManager(new BlockCacheStub(0), new MemstoreFlusherStub(0), new RegionServerStub(conf), new RegionServerAccountingStub()); assertFalse(manager.isTunerOn()); @@ -68,8 +69,9 @@ public class TestHeapMemoryManager { @Test public void testAutoTunerShouldBeOffWhenMaxMinRangesForBlockCacheIsNotGiven() throws Exception { Configuration conf = HBaseConfiguration.create(); + conf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.02f); conf.setFloat(HeapMemoryManager.MEMSTORE_SIZE_MAX_RANGE_KEY, 0.75f); - conf.setFloat(HeapMemoryManager.MEMSTORE_SIZE_MIN_RANGE_KEY, 0.05f); + conf.setFloat(HeapMemoryManager.MEMSTORE_SIZE_MIN_RANGE_KEY, 0.03f); HeapMemoryManager manager = new HeapMemoryManager(new BlockCacheStub(0), new MemstoreFlusherStub(0), new RegionServerStub(conf), new RegionServerAccountingStub()); assertFalse(manager.isTunerOn());