diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultHeapMemoryTuner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultHeapMemoryTuner.java index 27edbbb7f94..75caf1e5352 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultHeapMemoryTuner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/DefaultHeapMemoryTuner.java @@ -45,6 +45,9 @@ class DefaultHeapMemoryTuner implements HeapMemoryTuner { public static final String STEP_KEY = "hbase.regionserver.heapmemory.autotuner.step"; public static final float DEFAULT_STEP_VALUE = 0.02f; // 2% + private static final TunerResult TUNER_RESULT = new TunerResult(true); + private static final TunerResult NO_OP_TUNER_RESULT = new TunerResult(false); + private Configuration conf; private float step = DEFAULT_STEP_VALUE; @@ -61,9 +64,8 @@ class DefaultHeapMemoryTuner implements HeapMemoryTuner { boolean memstoreSufficient = blockedFlushCount == 0 && unblockedFlushCount == 0; boolean blockCacheSufficient = evictCount == 0; if (memstoreSufficient && blockCacheSufficient) { - return new TunerResult(false); + return NO_OP_TUNER_RESULT; } - TunerResult result = new TunerResult(true); float newMemstoreSize; float newBlockCacheSize; if (memstoreSufficient) { @@ -75,7 +77,7 @@ class DefaultHeapMemoryTuner implements HeapMemoryTuner { newBlockCacheSize = context.getCurBlockCacheSize() - step; newMemstoreSize = context.getCurMemStoreSize() + step; } else { - return new TunerResult(false); + return NO_OP_TUNER_RESULT; // As of now not making any tuning in write/read heavy scenario. } if (newMemstoreSize > globalMemStorePercentMaxRange) { @@ -88,9 +90,9 @@ class DefaultHeapMemoryTuner implements HeapMemoryTuner { } else if (newBlockCacheSize < blockCachePercentMinRange) { newBlockCacheSize = blockCachePercentMinRange; } - result.setBlockCacheSize(newBlockCacheSize); - result.setMemstoreSize(newMemstoreSize); - return result; + TUNER_RESULT.setBlockCacheSize(newBlockCacheSize); + TUNER_RESULT.setMemstoreSize(newMemstoreSize); + return TUNER_RESULT; } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NoOpHeapMemoryTuner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NoOpHeapMemoryTuner.java new file mode 100644 index 00000000000..2ec5bedac37 --- /dev/null +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/NoOpHeapMemoryTuner.java @@ -0,0 +1,48 @@ +/** + * 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 + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hbase.regionserver; + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.regionserver.HeapMemoryManager.TunerContext; +import org.apache.hadoop.hbase.regionserver.HeapMemoryManager.TunerResult; + +/** + * An implementation of HeapMemoryTuner which is not doing any tuning activity but just allows to + * continue with old style fixed proportions. + */ +@InterfaceAudience.Private +public class NoOpHeapMemoryTuner implements HeapMemoryTuner { + + private static final TunerResult NO_OP_TUNER_RESULT = new TunerResult(false); + + @Override + public Configuration getConf() { + return null; + } + + @Override + public void setConf(Configuration conf) { + + } + + @Override + public TunerResult tune(TunerContext context) { + return NO_OP_TUNER_RESULT; + } +}