HBASE-4588 The floating point arithmetic to validate memory allocation configurations need to be done as integers (dhruba)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1187551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Gray 2011-10-21 21:27:12 +00:00
parent f9f3a148d9
commit bd7ff8ece3
2 changed files with 18 additions and 6 deletions
CHANGES.txt
src/main/java/org/apache/hadoop/hbase

View File

@ -388,6 +388,8 @@ Release 0.92.0 - Unreleased
HBASE-4595 HFilePrettyPrinter Scanned kv count always 0 (Matteo Bertozzi)
HBASE-4580 Some invalid zk nodes were created when a clean cluster restarts
(Gaojinchao)
HBASE-4588 The floating point arithmetic to validate memory allocation
configurations need to be done as integers (dhruba)
TESTS
HBASE-4450 test for number of blocks read: to serve as baseline for expected

View File

@ -33,6 +33,9 @@ public class HBaseConfiguration extends Configuration {
private static final Log LOG = LogFactory.getLog(HBaseConfiguration.class);
// a constant to convert a fraction to a percentage
private static final int CONVERT_TO_PERCENTAGE = 100;
/**
* Instantinating HBaseConfiguration() is deprecated. Please use
* HBaseConfiguration#create() to construct a plain Configuration
@ -70,14 +73,21 @@ public class HBaseConfiguration extends Configuration {
private static void checkForClusterFreeMemoryLimit(Configuration conf) {
float globalMemstoreLimit = conf.getFloat("hbase.regionserver.global.memstore.upperLimit", 0.4f);
int gml = (int)(globalMemstoreLimit * CONVERT_TO_PERCENTAGE);
float blockCacheUpperLimit = conf.getFloat("hfile.block.cache.size", 0.2f);
if (1.0f - (globalMemstoreLimit + blockCacheUpperLimit)
< HConstants.HBASE_CLUSTER_MINIMUM_MEMORY_THRESHOLD) {
int bcul = (int)(blockCacheUpperLimit * CONVERT_TO_PERCENTAGE);
if (CONVERT_TO_PERCENTAGE - (gml + bcul)
< (int)(CONVERT_TO_PERCENTAGE *
HConstants.HBASE_CLUSTER_MINIMUM_MEMORY_THRESHOLD)) {
throw new RuntimeException(
"Current heap configuration for MemStore and BlockCache exceeds the threshold required for " +
"successful cluster operation. The combined value cannot exceed 0.8. Please check " +
"the settings for hbase.regionserver.global.memstore.upperLimit and" +
" hfile.block.cache.size in your configuration.");
"Current heap configuration for MemStore and BlockCache exceeds " +
"the threshold required for successful cluster operation. " +
"The combined value cannot exceed 0.8. Please check " +
"the settings for hbase.regionserver.global.memstore.upperLimit and " +
"hfile.block.cache.size in your configuration. " +
"hbase.regionserver.global.memstore.upperLimit is " +
globalMemstoreLimit +
" hfile.block.cache.size is " + blockCacheUpperLimit);
}
}