Package org.apache.hadoop.hbase.io.util
Class MemorySizeUtil
java.lang.Object
org.apache.hadoop.hbase.io.util.MemorySizeUtil
Util class to calculate memory size for memstore(on heap, off heap), block cache(L1, L2) of RS.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkForClusterFreeHeapMemoryLimit
(org.apache.hadoop.conf.Configuration conf) Checks whether we have enough heap memory left out after portion for Memstore and Block cache.static float
getBlockCacheHeapPercent
(org.apache.hadoop.conf.Configuration conf) Retrieve configured size for on heap block cache as percentage of total heap.static long
getBucketCacheSize
(org.apache.hadoop.conf.Configuration conf) static float
getGlobalMemStoreHeapLowerMark
(org.apache.hadoop.conf.Configuration conf, boolean honorOldConfig) Retrieve configured size for global memstore lower water mark as fraction of global memstore size.static float
getGlobalMemStoreHeapPercent
(org.apache.hadoop.conf.Configuration c, boolean logInvalid) Retrieve global memstore configured size as percentage of total heap.static Pair<Long,
MemoryType> getGlobalMemStoreSize
(org.apache.hadoop.conf.Configuration conf) Returns Pair of global memstore size and memory type(ie.static long
getOnHeapCacheSize
(org.apache.hadoop.conf.Configuration conf) static long
getOnheapGlobalMemStoreSize
(org.apache.hadoop.conf.Configuration conf) Returns the onheap global memstore limit based on the config 'hbase.regionserver.global.memstore.size'.static MemoryUsage
Return JVM memory statistics while properly handling runtime exceptions from the JVM.
-
Field Details
-
MEMSTORE_SIZE_KEY
- See Also:
-
MEMSTORE_SIZE_OLD_KEY
- See Also:
-
MEMSTORE_SIZE_LOWER_LIMIT_KEY
- See Also:
-
MEMSTORE_SIZE_LOWER_LIMIT_OLD_KEY
- See Also:
-
OFFHEAP_MEMSTORE_SIZE_KEY
- See Also:
-
DEFAULT_MEMSTORE_SIZE
- See Also:
-
DEFAULT_MEMSTORE_SIZE_LOWER_LIMIT
- See Also:
-
LOG
-
CONVERT_TO_PERCENTAGE
- See Also:
-
JVM_HEAP_EXCEPTION
- See Also:
-
-
Constructor Details
-
MemorySizeUtil
public MemorySizeUtil()
-
-
Method Details
-
safeGetHeapMemoryUsage
Return JVM memory statistics while properly handling runtime exceptions from the JVM.- Returns:
- a memory usage object, null if there was a runtime exception. (n.b. you could also get -1 values back from the JVM)
- See Also:
-
checkForClusterFreeHeapMemoryLimit
Checks whether we have enough heap memory left out after portion for Memstore and Block cache. We need atleast 20% of heap left out for other RS functions. -
getGlobalMemStoreHeapPercent
public static float getGlobalMemStoreHeapPercent(org.apache.hadoop.conf.Configuration c, boolean logInvalid) Retrieve global memstore configured size as percentage of total heap. -
getGlobalMemStoreHeapLowerMark
public static float getGlobalMemStoreHeapLowerMark(org.apache.hadoop.conf.Configuration conf, boolean honorOldConfig) Retrieve configured size for global memstore lower water mark as fraction of global memstore size. -
getGlobalMemStoreSize
public static Pair<Long,MemoryType> getGlobalMemStoreSize(org.apache.hadoop.conf.Configuration conf) Returns Pair of global memstore size and memory type(ie. on heap or off heap). -
getOnheapGlobalMemStoreSize
Returns the onheap global memstore limit based on the config 'hbase.regionserver.global.memstore.size'.- Returns:
- the onheap global memstore limt
-
getBlockCacheHeapPercent
Retrieve configured size for on heap block cache as percentage of total heap. -
getOnHeapCacheSize
- Parameters:
conf
- used to read cache configs- Returns:
- the number of bytes to use for LRU, negative if disabled.
- Throws:
IllegalArgumentException
- if HFILE_BLOCK_CACHE_SIZE_KEY is > 1.0
-
getBucketCacheSize
- Parameters:
conf
- used to read config for bucket cache size.- Returns:
- the number of bytes to use for bucket cache, negative if disabled.
-