VladRodionov commented on code in PR #8653:
URL: https://github.com/apache/hbase/pull/8653#discussion_r4068414130


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheFactory.java:
##########
@@ -135,6 +138,62 @@ public static BlockCache createBlockCache(Configuration 
conf) {
     return createBlockCache(conf, null);
   }
 
+  /**
+   * Creates the configured first-level cache as a cache engine.
+   * <p>
+   * Cache implementations that have been migrated to {@link CacheEngine} are 
instantiated directly.
+   * Legacy {@link FirstLevelBlockCache} implementations are adapted until 
their migration is
+   * complete.
+   * @param c cache configuration
+   * @return first-level cache engine, or {@code null} when the on-heap cache 
is disabled
+   */
+  public static CacheEngine createFirstLevelCacheEngine(final Configuration c) 
{
+    final long cacheSize = MemorySizeUtil.getOnHeapCacheSize(c);
+    if (cacheSize < 0) {
+      return null;
+    }
+
+    String policy = c.get(BLOCKCACHE_POLICY_KEY, BLOCKCACHE_POLICY_DEFAULT);
+    int blockSize = c.getInt(BLOCKCACHE_BLOCKSIZE_KEY, 
HConstants.DEFAULT_BLOCKSIZE);
+    LOG.info("Allocating CacheEngine size=" + StringUtils.byteDesc(cacheSize) 
+ ", blockSize="
+      + StringUtils.byteDesc(blockSize));
+
+    if (policy.equalsIgnoreCase("LRU")) {

Review Comment:
   I will address his once start working on Factory.



-- 
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]

Reply via email to