HBASE-11237 Bulk load initiated by user other than hbase fails

This commit is contained in:
Jimmy Xiang 2014-06-02 12:24:48 -07:00
parent 8fd62d1e89
commit 57826c7da9
3 changed files with 6 additions and 3 deletions

View File

@ -423,7 +423,8 @@ public class CacheConfig {
static BlockCache GLOBAL_BLOCK_CACHE_INSTANCE; static BlockCache GLOBAL_BLOCK_CACHE_INSTANCE;
/** Boolean whether we have disabled the block cache entirely. */ /** Boolean whether we have disabled the block cache entirely. */
private static boolean blockCacheDisabled = false; @VisibleForTesting
static boolean blockCacheDisabled = false;
/** /**
* Returns the block cache or <code>null</code> in case none should be used. * Returns the block cache or <code>null</code> in case none should be used.
@ -437,7 +438,7 @@ public class CacheConfig {
float cachePercentage = conf.getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, float cachePercentage = conf.getFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY,
HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT); HConstants.HFILE_BLOCK_CACHE_SIZE_DEFAULT);
if (cachePercentage == 0L) { if (cachePercentage <= 0.0001f) {
blockCacheDisabled = true; blockCacheDisabled = true;
return null; return null;
} }

View File

@ -57,6 +57,7 @@ public class TestPrefetch {
conf.setInt(HFile.FORMAT_VERSION_KEY, 3); conf.setInt(HFile.FORMAT_VERSION_KEY, 3);
conf.setBoolean(CacheConfig.PREFETCH_BLOCKS_ON_OPEN_KEY, true); conf.setBoolean(CacheConfig.PREFETCH_BLOCKS_ON_OPEN_KEY, true);
fs = HFileSystem.get(conf); fs = HFileSystem.get(conf);
CacheConfig.blockCacheDisabled = false;
cacheConf = new CacheConfig(conf); cacheConf = new CacheConfig(conf);
} }

View File

@ -53,7 +53,7 @@ import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class) @RunWith(Parameterized.class)
@Category(SmallTests.class) @Category(SmallTests.class)
public class TestScannerSelectionUsingKeyRange { public class TestScannerSelectionUsingKeyRange {
private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility().createLocalHTU(); private static final HBaseTestingUtility TEST_UTIL = HBaseTestingUtility.createLocalHTU();
private static TableName TABLE = TableName.valueOf("myTable"); private static TableName TABLE = TableName.valueOf("myTable");
private static String FAMILY = "myCF"; private static String FAMILY = "myCF";
private static byte[] FAMILY_BYTES = Bytes.toBytes(FAMILY); private static byte[] FAMILY_BYTES = Bytes.toBytes(FAMILY);
@ -113,6 +113,7 @@ public class TestScannerSelectionUsingKeyRange {
} }
Scan scan = new Scan(Bytes.toBytes("aaa"), Bytes.toBytes("aaz")); Scan scan = new Scan(Bytes.toBytes("aaa"), Bytes.toBytes("aaz"));
CacheConfig.blockCacheDisabled = false;
CacheConfig cacheConf = new CacheConfig(conf); CacheConfig cacheConf = new CacheConfig(conf);
LruBlockCache cache = (LruBlockCache) cacheConf.getBlockCache(); LruBlockCache cache = (LruBlockCache) cacheConf.getBlockCache();
cache.clearCache(); cache.clearCache();