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

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

                Author: ASF GitHub Bot
            Created on: 24/Jun/19 20:48
            Start Date: 24/Jun/19 20:48
    Worklog Time Spent: 10m 
      Work Description: bharatviswa504 commented on pull request #956: 
HDDS-1638.  Implement Key Write Requests to use Cache and DoubleBuffer.
URL: https://github.com/apache/hadoop/pull/956#discussion_r296908937
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java
 ##########
 @@ -495,12 +495,27 @@ public boolean isVolumeEmpty(String volume) throws 
IOException {
   public boolean isBucketEmpty(String volume, String bucket)
       throws IOException {
     String keyPrefix = getBucketKey(volume, bucket);
-    //TODO: When Key ops are converted in to HA model, use cache also to
-    // determine bucket is empty or not.
+
+    // First check in key table cache.
+    Iterator<Map.Entry<CacheKey<String>, CacheValue<OmKeyInfo>>> iterator =
+        ((TypedTable< String, OmKeyInfo>) keyTable).cacheIterator();
+    while (iterator.hasNext()) {
+      Map.Entry< CacheKey<String>, CacheValue<OmKeyInfo>> entry =
+          iterator.next();
+      String key = entry.getKey().getCacheKey();
+      OmKeyInfo omKeyInfo = entry.getValue().getCacheValue();
+      // Making sure that entry is not for delete key request.
+      if (key.startsWith(keyPrefix) && omKeyInfo != null) {
+        return false;
+      }
+    }
     try (TableIterator<String, ? extends KeyValue<String, OmKeyInfo>> keyIter =
         keyTable.iterator()) {
       KeyValue<String, OmKeyInfo> kv = keyIter.seek(keyPrefix);
-      if (kv != null && kv.getKey().startsWith(keyPrefix)) {
+      // During iteration from DB, check in mean time if this key is not
+      // marked for delete.
+      if (kv != null && kv.getKey().startsWith(keyPrefix) &&
+          keyTable.get(kv.getKey()) != null) {
 
 Review comment:
   Done
 
----------------------------------------------------------------
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: 266103)
    Time Spent: 8h 50m  (was: 8h 40m)

> Implement Key Write Requests to use Cache and DoubleBuffer
> ----------------------------------------------------------
>
>                 Key: HDDS-1638
>                 URL: https://issues.apache.org/jira/browse/HDDS-1638
>             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: 8h 50m
>  Remaining Estimate: 0h
>
> Implement Key write requests to use OM Cache, double buffer. 
> In this Jira will add the changes to implement key operations, and HA/Non-HA 
> will have a different code path, but once all requests are implemented will 
> have a single code path.



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

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

Reply via email to