-
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
Conversation
| if (omVersion.compareTo(OzoneManagerVersion.OPTIMIZED_GET_KEY_INFO) >= 0) { | ||
| keyInfo = ozoneManagerClient.getKeyInfo(keyArgs, false) | ||
| .getKeyInfo(); | ||
| if (!keyInfo.isFile()) { |
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 getKeyInfo and check isFile if 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 call lookupKey for older OM and that would not result in either isFile attribute or NOT_A_FILE exception. (For older OM, clients have to call lookupFile).
Yet, to make things right, we can make getKeyInfo looks like the following to make it reusable across object storage and OFS use cases.
private OmKeyInfo getKeyInfo(String volumeName, String bucketName, String keyName,
boolean forceUpdateContainerCache, boolean lookupFile) {
if (newOM) { call getKeyInfo }
else if (lookupFile) { call lookupFile }
else { call lookupKey }
}
I feel that would just move complexity from one place to another.
DaveTeng0
left a comment
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.
(except Ritesh's suggestion) otherwise LGTM!
jojochuang
left a comment
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.
qq: Will it work as expected if a new client connects to an old OM?
I suspect this scenario wouldn't work but want to double check with you.
Thanks
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmKeyInfo.java
Outdated
Show resolved
Hide resolved
|
|
||
| String dirKey = OzoneFSUtils.addTrailingSlashIfNeeded(keyName); | ||
| OmKeyInfo dirKeyInfo = getOmKeyInfo(volumeName, bucketName, dirKey); | ||
| if (dirKeyInfo != null) { |
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.
how about adding an assertion here that dirKeyInfo.isFile() is false?
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.
That also works, just like the lookupFile does today. Yet, I think getKeyInfo should be a generic API that provide key information, like its name.
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.
Thanks for the review, @jojochuang. |
jojochuang
left a comment
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.
+1 from me. Merging now.
What changes were proposed in this pull request?
Problem
The target of this task is to deprecate the
LookupFileinterface and useGetKeyInfofor the OFS use case.The gap between OFS and object storage use cases (like S3) is that due to a file system nature, OFS has to answer the file read requests from its client. A file read input is a file path and OFS needs to be able to decide if the given path is a valid file. To be specific, if the given path is not a file (but a directory), OFS should return an error. Reading empty files is a valid use case.
The
lookupKeyAPI returns the same content for an empty file and directory.Today, this is solved in Ozone by the separated
lookupFileAPI, detecting if the given key is a directory and throwing an error on server-side.GetKeyInforeplaceslookupKeyand inherits the same limit.Solution
To make
GetKeyInfoavailable for OFS, we can simply add to its response a field indicating if the key represents a directory or a file so that OFS client code can make the assertion.https://issues.apaceorg/jira/browse/HDDS-7419
How was this patch tested?
OFS integration test.