Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
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
- is related to
-
HDDS-2940 mkdir : create key table entries for intermediate directories in the path
- Resolved
- links to