-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-7419. Integrate the GetKeyInfo API to OFS #3912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -367,7 +367,7 @@ private OmKeyInfo readKeyInfo(OmKeyArgs args) throws IOException { | |
| if (bucketLayout.isFileSystemOptimized()) { | ||
| value = getOmKeyInfoFSO(volumeName, bucketName, keyName); | ||
| } else { | ||
| value = getOmKeyInfo(volumeName, bucketName, keyName); | ||
| value = getOmKeyInfoDirectoryAware(volumeName, bucketName, keyName); | ||
| } | ||
| } catch (IOException ex) { | ||
| if (ex instanceof OMException) { | ||
|
|
@@ -396,8 +396,26 @@ private OmKeyInfo readKeyInfo(OmKeyArgs args) throws IOException { | |
| return value; | ||
| } | ||
|
|
||
| private OmKeyInfo getOmKeyInfoDirectoryAware(String volumeName, | ||
| String bucketName, String keyName) throws IOException { | ||
| OmKeyInfo keyInfo = getOmKeyInfo(volumeName, bucketName, keyName); | ||
|
|
||
| // Check if the key is a directory. | ||
| if (keyInfo != null) { | ||
| keyInfo.setFile(true); | ||
| return keyInfo; | ||
| } | ||
|
|
||
| String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName); | ||
| OmKeyInfo dirKeyInfo = getOmKeyInfo(volumeName, bucketName, dirKey); | ||
| if (dirKeyInfo != null) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about adding an assertion here that dirKeyInfo.isFile() is false?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That also works, just like the The decision of how to use that information should be in the hands of OM's clients. E.g. RpcClient should know it's looking for a file instead of relying on OM to decide. |
||
| dirKeyInfo.setFile(false); | ||
| } | ||
| return dirKeyInfo; | ||
| } | ||
|
|
||
| private OmKeyInfo getOmKeyInfo(String volumeName, String bucketName, | ||
| String keyName) throws IOException { | ||
| String keyName) throws IOException { | ||
| String keyBytes = | ||
| metadataManager.getOzoneKey(volumeName, bucketName, keyName); | ||
| BucketLayout bucketLayout = getBucketLayout(metadataManager, volumeName, | ||
|
|
@@ -425,6 +443,7 @@ private OmKeyInfo getOmKeyInfoFSO(String volumeName, String bucketName, | |
| fileStatus.getKeyInfo().getKeyName()); | ||
| fileStatus.getKeyInfo().setKeyName(keyPath); | ||
| } | ||
| fileStatus.getKeyInfo().setFile(fileStatus.isFile()); | ||
| return fileStatus.getKeyInfo(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to reuse
getKeyInfoand checkisFileif there was no exception (client used lookup and it failed)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible.
However, if we just reused
getKeyInfo, then in turn it would calllookupKeyfor older OM and that would not result in either isFile attribute orNOT_A_FILEexception. (For older OM, clients have to calllookupFile).Yet, to make things right, we can make
getKeyInfolooks like the following to make it reusable across object storage and OFS use cases.I feel that would just move complexity from one place to another.