rakeshadr commented on a change in pull request #1775:
URL: https://github.com/apache/ozone/pull/1775#discussion_r555557385



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
##########
@@ -696,6 +698,28 @@ public OmKeyInfo lookupKey(OmKeyArgs args, String 
clientAddress)
     return value;
   }
 
+  private OmKeyInfo getOmKeyInfo(String volumeName, String bucketName,
+                                 String keyName) throws IOException {
+    String keyBytes = metadataManager.getOzoneKey(
+            volumeName, bucketName, keyName);
+    return metadataManager.getKeyTable().get(keyBytes);
+  }
+
+  /**
+   * Look up will return only closed fileInfo. This will return null if the
+   * keyName is a directory or if the keyName is still open for writing.
+   */
+  private OmKeyInfo getOmKeyInfoV1(String volumeName, String bucketName,
+                                   String keyName) throws IOException {
+    OzoneFileStatus fileStatus =
+            OMFileRequest.getOMKeyInfoIfExists(metadataManager,
+                    volumeName, bucketName, keyName, scmBlockSize);
+    if (fileStatus == null) {
+      return null;
+    }
+    return fileStatus.isFile() ? fileStatus.getKeyInfo() : null;

Review comment:
       Thanks @linyiqun for the reviews.
   
   In V0(existing code), the intermediate path will be accessed using a 
trialing slash but at the OM server the below function will remove the trailing 
slash and then the directory won't be accessible via lookupKey() API.
      ```
    String keyName = OMClientRequest.validateAndNormalizeKey(
           enableFileSystemPaths, args.getKeyName());
   ```
   [Lookup Code 
Snippet](https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java#L649)
   
   Adding few details about the FS structure. For ex, a/b/c/file1, which will 
create table entries like,
   **V0 - existing code:**
   KeyTable
        /vol1/buck1/a/
        /vol1/buck1/a/b/
        /vol1/buck1/a/b/c/
        /vol1/buck1/a/b/c/file1
   
   **V1 - new code:**
   DirTable:
        512/a/ -> 1024
        1024/b/ -> 1025
        1025/c/ -> 1026
   FileTable:
        1026/file1 -> 1027
   
   I will add more test verification step, which will verify using V0 and V1 
code path, this will help to confirm the behavior in both the code paths.
   ```
       // read intermediate directory
       verifyIntermediateDir(bucket, "a/b/c/");
       verifyIntermediateDir(bucket, "a/b/c");
       verifyIntermediateDir(bucket, "/a/b/c/");
       verifyIntermediateDir(bucket, "/a/b/c");
   ```




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



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

Reply via email to