You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/11/22 14:58:23 UTC

[GitHub] [hbase] chenxu14 commented on a change in pull request #868: HBASE-23296 Add CompositeBucketCache to support tiered BC

chenxu14 commented on a change in pull request #868: HBASE-23296 Add CompositeBucketCache to support tiered BC
URL: https://github.com/apache/hbase/pull/868#discussion_r349637124
 
 

 ##########
 File path: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheFactory.java
 ##########
 @@ -110,29 +113,35 @@ public static BlockCache createBlockCache(Configuration conf) {
           + "we will remove the deprecated config.", DEPRECATED_BLOCKCACHE_BLOCKSIZE_KEY,
         BLOCKCACHE_BLOCKSIZE_KEY);
     }
-    FirstLevelBlockCache l1Cache = createFirstLevelCache(conf);
+    BlockCache l1Cache = createFirstLevelCache(conf);
     if (l1Cache == null) {
       return null;
     }
-    boolean useExternal = conf.getBoolean(EXTERNAL_BLOCKCACHE_KEY, EXTERNAL_BLOCKCACHE_DEFAULT);
-    if (useExternal) {
-      BlockCache l2CacheInstance = createExternalBlockcache(conf);
-      return l2CacheInstance == null ?
-          l1Cache :
-          new InclusiveCombinedBlockCache(l1Cache, l2CacheInstance);
+    if (conf.getBoolean(EXTERNAL_BLOCKCACHE_KEY, EXTERNAL_BLOCKCACHE_DEFAULT)) {
+      BlockCache l2Cache = createExternalBlockcache(conf);
+      return l2Cache == null ? l1Cache : new InclusiveCombinedBlockCache(
+          (FirstLevelBlockCache)l1Cache, l2Cache);
     } else {
       // otherwise use the bucket cache.
-      BucketCache bucketCache = createBucketCache(conf);
-      if (!conf.getBoolean("hbase.bucketcache.combinedcache.enabled", true)) {
-        // Non combined mode is off from 2.0
-        LOG.warn(
-            "From HBase 2.0 onwards only combined mode of LRU cache and bucket cache is available");
+      BucketCache l2Cache = createBucketCache(conf, CacheLevel.L2);
+      if (conf.getBoolean(BUCKET_CACHE_COMPOSITE_KEY, false)) {
+        return l2Cache == null ? l1Cache : new CompositeBucketCache((BucketCache)l1Cache, l2Cache);
+      } else {
+        if (!conf.getBoolean("hbase.bucketcache.combinedcache.enabled", true)) {
+          // Non combined mode is off from 2.0
+          LOG.warn("From HBase 2.0 onwards only combined mode of LRU cache and bucket"
+              + " cache is available");
+        }
+        return l2Cache == null ? l1Cache : new CombinedBlockCache(
+            (FirstLevelBlockCache)l1Cache, l2Cache);
       }
-      return bucketCache == null ? l1Cache : new CombinedBlockCache(l1Cache, bucketCache);
     }
   }
 
-  private static FirstLevelBlockCache createFirstLevelCache(final Configuration c) {
+  private static BlockCache createFirstLevelCache(final Configuration c) {
+    if (c.getBoolean(BUCKET_CACHE_COMPOSITE_KEY, false)) {
+      return createBucketCache(c, CacheLevel.L1);
 
 Review comment:
   We have exposed some conf key for each level's BucketCache (see CompositeBucketCache), such as the ioengine and cacheSize.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services