HBASE-10151 No-op HeapMemoryTuner

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1550871 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
anoopsamjohn 2013-12-14 03:01:11 +00:00
parent 763e060db9
commit 5fd25ffbc0
2 changed files with 56 additions and 6 deletions

View File

@ -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

View File

@ -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;
}
}