HBASE-4432 Enable/Disable off heap cache with config (Li Pi)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1172802 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e1244033bf
commit
7f0c31e55f
|
@ -513,6 +513,7 @@ Release 0.91.0 - Unreleased
|
|||
(David Revell)
|
||||
HBASE-4424 Provide coprocessors access to createTable() via
|
||||
MasterServices
|
||||
HBASE-4432 Enable/Disable off heap cache with config (Li Pi)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -378,12 +378,18 @@ public class StoreFile {
|
|||
MemoryUsage mu = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||
long cacheSize = (long)(mu.getMax() * cachePercentage);
|
||||
int blockSize = conf.getInt("hbase.offheapcache.minblocksize", HFile.DEFAULT_BLOCKSIZE);
|
||||
long offHeapCacheSize = (long) (conf.getFloat("hbase.offheapcache.percentage", (float) 0.95) * DirectMemoryUtils.getDirectMemorySize());
|
||||
boolean enableOffHeapCache = conf.getBoolean("hbase.offheapcache.enable", false);
|
||||
long offHeapCacheSize = enableOffHeapCache ?
|
||||
(long) (conf.getFloat("hbase.offheapcache.percentage",
|
||||
(float) 0.95) * DirectMemoryUtils.getDirectMemorySize()) :
|
||||
0;
|
||||
LOG.info("Allocating LruBlockCache with maximum size " +
|
||||
StringUtils.humanReadableInt(cacheSize));
|
||||
if(offHeapCacheSize <= 0) {
|
||||
hfileBlockCache = new LruBlockCache(cacheSize, DEFAULT_BLOCKSIZE_SMALL);
|
||||
} else {
|
||||
LOG.info("Allocating OffHeapCache with maximum size " +
|
||||
StringUtils.humanReadableInt(offHeapCacheSize));
|
||||
hfileBlockCache = new DoubleBlockCache(cacheSize, offHeapCacheSize, DEFAULT_BLOCKSIZE_SMALL, blockSize, conf);
|
||||
}
|
||||
return hfileBlockCache;
|
||||
|
|
Loading…
Reference in New Issue