HBASE-17071 Do not initialize MemstoreChunkPool when use mslab option is turned off.

This commit is contained in:
anoopsamjohn 2016-11-11 16:44:34 +05:30
parent f9c6b66b95
commit fa838b020d
6 changed files with 13 additions and 6 deletions

View File

@ -202,6 +202,11 @@ public class MemStoreChunkPool implements HeapMemoryTuneObserver {
synchronized (MemStoreChunkPool.class) {
if (chunkPoolDisabled) return null;
if (GLOBAL_INSTANCE != null) return GLOBAL_INSTANCE;
// When MSLAB is turned OFF no need to init chunk pool at all.
if (!conf.getBoolean(MemStoreLAB.USEMSLAB_KEY, MemStoreLAB.USEMSLAB_DEFAULT)) {
chunkPoolDisabled = true;
return null;
}
float poolSizePercentage = conf.getFloat(CHUNK_POOL_MAXSIZE_KEY, POOL_MAX_SIZE_DEFAULT);
if (poolSizePercentage <= 0) {
chunkPoolDisabled = true;

View File

@ -44,6 +44,9 @@ import org.apache.hadoop.hbase.classification.InterfaceAudience;
@InterfaceAudience.Private
public interface MemStoreLAB {
String USEMSLAB_KEY = "hbase.hregion.memstore.mslab.enabled";
boolean USEMSLAB_DEFAULT = true;
/**
* Allocates slice in this LAB and copy the passed Cell into this area. Returns new Cell instance
* over the copied the data. When this MemStoreLAB can not copy this Cell, it returns null.
@ -64,4 +67,5 @@ public interface MemStoreLAB {
* Called when closing a scanner on the data of this MemStoreLAB
*/
void decScannerCount();
}

View File

@ -35,8 +35,6 @@ import java.util.List;
@InterfaceAudience.Private
public final class SegmentFactory {
static final String USEMSLAB_KEY = "hbase.hregion.memstore.mslab.enabled";
static final boolean USEMSLAB_DEFAULT = true;
static final String MSLAB_CLASS_NAME = "hbase.regionserver.mslab.class";
private SegmentFactory() {}
@ -107,7 +105,7 @@ public final class SegmentFactory {
private MemStoreLAB getMemStoreLAB(Configuration conf) {
MemStoreLAB memStoreLAB = null;
if (conf.getBoolean(USEMSLAB_KEY, USEMSLAB_DEFAULT)) {
if (conf.getBoolean(MemStoreLAB.USEMSLAB_KEY, MemStoreLAB.USEMSLAB_DEFAULT)) {
String className = conf.get(MSLAB_CLASS_NAME, HeapMemStoreLAB.class.getName());
memStoreLAB = ReflectionUtils.instantiateWithCustomCtor(className,
new Class[] { Configuration.class }, new Object[] { conf });

View File

@ -72,7 +72,7 @@ public class TestCellFlatSet extends TestCase {
ascCbOnHeap = new CellArrayMap(CellComparator.COMPARATOR,ascCells,0,NUM_OF_CELLS,false);
descCells = new Cell[] {kv4,kv3,kv2,kv1};
descCbOnHeap = new CellArrayMap(CellComparator.COMPARATOR,descCells,0,NUM_OF_CELLS,true);
CONF.setBoolean(SegmentFactory.USEMSLAB_KEY, true);
CONF.setBoolean(MemStoreLAB.USEMSLAB_KEY, true);
CONF.setFloat(MemStoreChunkPool.CHUNK_POOL_MAXSIZE_KEY, 0.2f);
MemStoreChunkPool.chunkPoolDisabled = false;
mslab = new HeapMemStoreLAB(CONF);

View File

@ -86,7 +86,7 @@ public class TestCompactingMemStore extends TestDefaultMemStore {
protected void compactingSetUp() throws Exception {
super.internalSetUp();
Configuration conf = new Configuration();
conf.setBoolean(SegmentFactory.USEMSLAB_KEY, true);
conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, true);
conf.setFloat(MemStoreChunkPool.CHUNK_POOL_MAXSIZE_KEY, 0.2f);
conf.setInt(HRegion.MEMSTORE_PERIODIC_FLUSH_INTERVAL, 1000);
HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);

View File

@ -49,7 +49,7 @@ public class TestMemStoreChunkPool {
@BeforeClass
public static void setUpBeforeClass() throws Exception {
conf.setBoolean(SegmentFactory.USEMSLAB_KEY, true);
conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, true);
conf.setFloat(MemStoreChunkPool.CHUNK_POOL_MAXSIZE_KEY, 0.2f);
chunkPoolDisabledBeforeTest = MemStoreChunkPool.chunkPoolDisabled;
MemStoreChunkPool.chunkPoolDisabled = false;