smengcl commented on a change in pull request #584: HDDS-3054. 
OzoneFileStatus#getModificationTime should return actual directory modification 
time when its OmKeyInfo is available
URL: https://github.com/apache/hadoop-ozone/pull/584#discussion_r384707298
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
 ##########
 @@ -2005,15 +2016,21 @@ public OmKeyInfo lookupFile(OmKeyArgs args, String 
clientAddress)
               if (isFile) {
                 if (!deletedKeySet.contains(entryInDb)) {
                   cacheKeyMap.put(entryInDb,
-                      new OzoneFileStatus(value, scmBlockSize, !isFile));
+                      new OzoneFileStatus(omKeyInfo, scmBlockSize, !isFile));
                   countEntries++;
                 }
                 iterator.next();
               } else {
                 // if entry is a directory
                 if (!deletedKeySet.contains(entryInDb)) {
-                  cacheKeyMap.put(entryInDb,
-                      new OzoneFileStatus(immediateChild));
+                  if (!entryKeyName.equals(immediateChild)) {
+                    cacheKeyMap.put(entryInDb,
+                        new OzoneFileStatus(immediateChild));
+                  } else {
+                    // If entryKeyName matches dir name, we have the info
+                    cacheKeyMap.put(entryInDb,
+                        new OzoneFileStatus(omKeyInfo, 0, true));
 
 Review comment:
   > Could you please explain this change.
   
   `entryKeyName` is retrieved from a DB entry (actually exists), while 
`immediateChild` is generated using the information of parent dir and a key in 
it:
   ```java
   String immediateChild = OzoneFSUtils.getImmediateChild(entryKeyName, 
keyName);
   ```
   As seen in `getImmediateChild()`'s javadoc:
   ```java
     /**
      * The function returns immediate child of given ancestor in a particular
      * descendant. For example if ancestor is /a/b and descendant is /a/b/c/d/e
      * the function should return /a/b/c/. If the descendant itself is the
      * immediate child then it is returned as is without adding a trailing 
slash.
      * This is done to distinguish files from a directory as in ozone files do
      * not carry a trailing slash.
      */
     public static String getImmediateChild(String descendant, String ancestor) 
{
   ```

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


With regards,
Apache Git Services

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

Reply via email to