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

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

                Author: ASF GitHub Bot
            Created on: 14/May/19 23:25
            Start Date: 14/May/19 23:25
    Worklog Time Spent: 10m 
      Work Description: arp7 commented on pull request #798: HDDS-1499. 
OzoneManager Cache.
URL: https://github.com/apache/hadoop/pull/798#discussion_r284037057
 
 

 ##########
 File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/utils/db/TypedTable.java
 ##########
 @@ -69,8 +94,40 @@ public boolean isEmpty() throws IOException {
     return rawTable.isEmpty();
   }
 
+  /**
+   * Returns the value mapped to the given key in byte array or returns null
+   * if the key is not found.
+   *
+   * First it will check from cache, if it has entry return the value
+   * otherwise, get from the RocksDB table.
+   *
+   * @param key metadata key
+   * @return VALUE
+   * @throws IOException
+   */
   @Override
   public VALUE get(KEY key) throws IOException {
+    // Here the metadata lock will guarantee that cache is not updated for same
+    // key during get key.
+    if (cache != null) {
+      CacheValue<VALUE> cacheValue = cache.get(new CacheKey<>(key));
+      if (cacheValue == null) {
+        return getFromTable(key);
+      } else {
+        // Doing this because, if the Cache Value Last operation is deleted
+        // means it will eventually removed from DB. So, we should return null.
+        if (cacheValue.getLastOperation() != CacheValue.OperationType.DELETED) 
{
+          return cacheValue.getValue();
+        } else {
+          return null;
 
 Review comment:
   Instead of making delete operation a special case, in case of delete we can 
just push a null value into the cache. So it will automatically return null.
 
----------------------------------------------------------------
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:
us...@infra.apache.org


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

    Worklog Id:     (was: 242133)
    Time Spent: 4.5h  (was: 4h 20m)

> OzoneManager Cache
> ------------------
>
>                 Key: HDDS-1499
>                 URL: https://issues.apache.org/jira/browse/HDDS-1499
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: Ozone Manager
>            Reporter: Bharat Viswanadham
>            Assignee: Bharat Viswanadham
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> In this Jira, we shall implement a cache for Table.
> As with OM HA, we are planning to implement double buffer implementation to 
> flush transaction in a batch, instead of using rocksdb put() for every 
> operation. When this comes in to place we need cache in OzoneManager HA to 
> handle/server the requests for validation/returning responses.
>  
> This Jira will implement Cache as an integral part of the table. In this way 
> users using this table does not need to handle like check cache/db. For this, 
> we can update get API in the table to handle the cache.
>  
> This Jira will implement:
>  # Cache as a part of each Table.
>  # Uses this cache in get().
>  # Exposes api for cleanup, add entries to cache.
> Usage to add the entries in to cache will be done in further jira's.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to