Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-3054

OzoneFileStatus#getModificationTime should return actual directory modification time when its OmKeyInfo is available

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.0.0
    • None

    Description

      As of current implementation, getModificationTime() always returns "fake" modification time (current time) for directory due to the reason that a directory in Ozone might be faked from a file key.

      But, there are cases where real directory key exists in OzoneBucket. For example when user calls fs.mkdirs(directory). In this case, a reasonable thing to do would be getting the modification time from the OmInfoKey, rather than faking it.

      CC xyao

      My POC for the fix:

      Diff
      diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneFileStatus.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneFileStatus.java
      index 8717946512..708e62d692 100644
      --- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneFileStatus.java
      +++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneFileStatus.java
      @@ -93,7 +93,7 @@ public FileStatus makeQualified(URI defaultUri, Path parent,
          */
         @Override
         public long getModificationTime(){
      -    if (isDirectory()) {
      +    if (isDirectory() && super.getModificationTime() == 0) {
             return System.currentTimeMillis();
           } else {
             return super.getModificationTime();
      diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
      index 1be5fb3f3c..cb8f647a41 100644
      --- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
      +++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
      @@ -2004,8 +2004,14 @@ public OmKeyInfo lookupFile(OmKeyArgs args, String clientAddress)
                     } 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(value, 0, true));
      +                  }
                         countEntries++;
                       }
                       // skip the other descendants of this child directory.
      

      Attachments

        Issue Links

          Activity

            People

              smeng Siyao Meng
              smeng Siyao Meng
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m