You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "dombizita (via GitHub)" <gi...@apache.org> on 2023/01/24 10:25:38 UTC

[GitHub] [ozone] dombizita commented on a diff in pull request #4182: HDDS-5463. [FSO] Recon Container API does not work correctly with FSO.

dombizita commented on code in PR #4182:
URL: https://github.com/apache/ozone/pull/4182#discussion_r1085081760


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/ContainerEndpoint.java:
##########
@@ -157,11 +157,17 @@ public Response getKeysForContainer(
       for (ContainerKeyPrefix containerKeyPrefix : containerKeyPrefixMap
           .keySet()) {
 
-        // Directly calling get() on the Key table instead of iterating since
-        // only full keys are supported now. When we change to using a prefix
-        // of the key, this needs to change to prefix seek.
-        OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(getBucketLayout())
-            .getSkipCache(containerKeyPrefix.getKeyPrefix());
+      // Directly calling getSkipCache() on the Key/FileTable table accordingly
+      // instead of iterating since only full keys are supported now. We will
+      // try to get the OmKeyInfo object by searching the KEY_TABLE table with
+      // the key prefix. If it's not found, we will then search the FILE_TABLE
+        OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable(BucketLayout.LEGACY)
+            .getSkipCache(containerKeyPrefix.getKeyPrefix()) == null ?
+            omMetadataManager.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED)
+                .getSkipCache(containerKeyPrefix.getKeyPrefix()) :
+            omMetadataManager.getKeyTable(BucketLayout.LEGACY)
+                .getSkipCache(containerKeyPrefix.getKeyPrefix());

Review Comment:
   maybe we could avoid calling `omMetadataManager.getKeyTable(BucketLayout.LEGACY).getSkipCache(containerKeyPrefix.getKeyPrefix())` twice, either we could save the value to a variable and use that
   ```suggestion
           OmKeyInfo omKeyInfo = ((OmKeyInfo keyinfo =
           omMetadataManager.getKeyTable(BucketLayout.LEGACY).getSkipCache(
           containerKeyPrefix.getKeyPrefix())) == null) ?
           omMetadataManager.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED)
           .getSkipCache(containerKeyPrefix.getKeyPrefix()) : keyinfo;
   ```
   or we could do this
   ```suggestion
           OmKeyInfo omKeyInfo = Optional.ofNullable(omMetadataManager.getKeyTable(BucketLayout.LEGACY)
               .getSkipCache(containerKeyPrefix.getKeyPrefix()))
               .orElse(omMetadataManager.getKeyTable(BucketLayout.FILE_SYSTEM_OPTIMIZED)
                   .getSkipCache(containerKeyPrefix.getKeyPrefix()));
   ```
   let me know if I misunderstood something or you don't think this is necessary, but maybe it makes the code slightly more readable and we avoid a duplicated calling. 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org