[ 
https://issues.apache.org/jira/browse/HDDS-1802?focusedWorklogId=277097&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-277097
 ]

ASF GitHub Bot logged work on HDDS-1802:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Jul/19 01:00
            Start Date: 16/Jul/19 01:00
    Worklog Time Spent: 10m 
      Work Description: arp7 commented on pull request #1100: HDDS-1802. Add 
Eviction policy for table cache.
URL: https://github.com/apache/hadoop/pull/1100#discussion_r303692949
 
 

 ##########
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/TypedTable.java
 ##########
 @@ -104,14 +148,25 @@ public boolean isExist(KEY key) throws IOException {
   public VALUE get(KEY key) throws IOException {
     // Here the metadata lock will guarantee that cache is not updated for same
     // key during get key.
-    CacheValue< VALUE > cacheValue = cache.get(new CacheKey<>(key));
-    if (cacheValue == null) {
-      // If no cache for the table or if it does not exist in cache get from
-      // RocksDB table.
+
+    // First get from cache. If it has return value.
+    // If it does not have
+    //  If cache cleanup policy is NEVER return null. Because cache here is
+    //  full table data in-memory, so no need to get from underlying rocksdb
+    //  table.
+    //  If cache cleanup policy is AFTER_FLUSH return from underlying rocksdb
+    //  table. As it might have been cleaned up from cache, might be there in
+    //  DB.
+    CacheValue<VALUE> cacheValue =
+        Optional.fromNullable(cache.get(new CacheKey<>(key))).orNull();
+    if (cacheValue != null) {
+      return cacheValue.getCacheValue();
+    }
+
+    if (cacheCleanupPolicy == TableCacheImpl.CacheCleanupPolicy.AFTER_FLUSH) {
 
 Review comment:
   Same here.. we should not have these checks here.
 
----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 277097)
    Time Spent: 50m  (was: 40m)

> Add Eviction policy for table cache
> -----------------------------------
>
>                 Key: HDDS-1802
>                 URL: https://issues.apache.org/jira/browse/HDDS-1802
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>            Reporter: Bharat Viswanadham
>            Assignee: Bharat Viswanadham
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> In this Jira we will add eviction policy for table cache.
> In this Jira, we will add 2 eviction policies for the cache.
> NEVER, // Cache will not be cleaned up. This mean's the table maintains full 
> cache.
> AFTERFLUSH // Cache will be cleaned up, once after flushing to DB.
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to