VladRodionov commented on code in PR #8384:
URL: https://github.com/apache/hbase/pull/8384#discussion_r3456271052
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestCacheOnWrite.java:
##########
@@ -148,70 +152,73 @@ public void modifyConf(Configuration conf) {
}
public TestCacheOnWrite(CacheOnWriteType cowType, Compression.Algorithm
compress,
- boolean cacheCompressedData, BlockCache blockCache) {
+ boolean cacheCompressedData, CacheAccessService blockCache) {
this.cowType = cowType;
this.compress = compress;
this.cacheCompressedData = cacheCompressedData;
- this.blockCache = blockCache;
+ this.cache = blockCache;
testDescription = "[cacheOnWrite=" + cowType + ", compress=" + compress
+ ", cacheCompressedData=" + cacheCompressedData + "]";
LOG.info(testDescription);
}
- private static List<BlockCache> getBlockCaches() throws IOException {
+ private static List<CacheAccessService> getCacheServices() throws
IOException {
Configuration conf = TEST_UTIL.getConfiguration();
- List<BlockCache> blockcaches = new ArrayList<>();
+ List<CacheAccessService> caches = new ArrayList<>();
// default
- blockcaches.add(BlockCacheFactory.createBlockCache(conf));
+ caches.add(CacheAccessServiceTestFactory.fromConfiguration(conf));
// set LruBlockCache.LRU_HARD_CAPACITY_LIMIT_FACTOR_CONFIG_NAME to 2.0f
due to HBASE-16287
TEST_UTIL.getConfiguration().setFloat(LruBlockCache.LRU_HARD_CAPACITY_LIMIT_FACTOR_CONFIG_NAME,
2.0f);
// memory
- BlockCache lru = new LruBlockCache(128 * 1024 * 1024, 64 * 1024,
TEST_UTIL.getConfiguration());
- blockcaches.add(lru);
+ CacheAccessService lru =
+ CacheAccessServiceTestFactory.lru(128 * 1024 * 1024, 64 * 1024,
TEST_UTIL.getConfiguration());
+ caches.add(lru);
// bucket cache
FileSystem.get(conf).mkdirs(TEST_UTIL.getDataTestDir());
int[] bucketSizes =
{ INDEX_BLOCK_SIZE, DATA_BLOCK_SIZE, BLOOM_BLOCK_SIZE, 64 * 1024, 128 *
1024 };
- BlockCache bucketcache =
- new BucketCache("offheap", 128 * 1024 * 1024, 64 * 1024, bucketSizes, 5,
64 * 100, null);
- blockcaches.add(bucketcache);
- return blockcaches;
+ CacheAccessService bucketcache =
CacheAccessServiceTestFactory.bucket("offheap",
+ 128 * 1024 * 1024, 64 * 1024, bucketSizes, 5, 64 * 100, null);
+ caches.add(bucketcache);
+ return caches;
}
public static Stream<Arguments> parameters() throws IOException {
List<Arguments> params = new ArrayList<>();
- for (BlockCache blockCache : getBlockCaches()) {
+ for (CacheAccessService cache : getCacheServices()) {
for (CacheOnWriteType cowType : CacheOnWriteType.values()) {
for (Compression.Algorithm compress :
HBaseCommonTestingUtil.COMPRESSION_ALGORITHMS) {
for (boolean cacheCompressedData : new boolean[] { false, true }) {
- params.add(Arguments.of(cowType, compress, cacheCompressedData,
blockCache));
+ params.add(Arguments.of(cowType, compress, cacheCompressedData,
cache));
}
}
}
}
return params.stream();
}
- private void clearBlockCache(BlockCache blockCache) throws
InterruptedException {
- if (blockCache instanceof LruBlockCache) {
- ((LruBlockCache) blockCache).clearCache();
+ private void clearBlockCache(CacheAccessService cache) throws
InterruptedException {
+ // TODO: HBASE-30018 refactor later
+ BlockCache blockCache = ((BlockCacheBackedCacheAccessService)
cache).getBlockCache();
+ if (cache instanceof LruBlockCache) {
+ ((LruBlockCache) cache).clearCache();
} else {
Review Comment:
Fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]