-
Notifications
You must be signed in to change notification settings - Fork 392
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
[#4708] improvement(client-java/server): Add implementations for the getFileLocation
interface in Java Client / Server
#4858
Changes from 11 commits
e10a8dc
5c3b517
67aa723
4f4c81a
05fc5be
910b7da
e45fd5c
23c2609
9949b3f
e99f7e0
f3227ad
5edebdc
3b36e37
50b555a
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 |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
|
||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.Maps; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
@@ -29,13 +30,15 @@ | |
import org.apache.gravitino.Catalog; | ||
import org.apache.gravitino.NameIdentifier; | ||
import org.apache.gravitino.Namespace; | ||
import org.apache.gravitino.audit.CallerContext; | ||
import org.apache.gravitino.dto.AuditDTO; | ||
import org.apache.gravitino.dto.CatalogDTO; | ||
import org.apache.gravitino.dto.requests.FilesetCreateRequest; | ||
import org.apache.gravitino.dto.requests.FilesetUpdateRequest; | ||
import org.apache.gravitino.dto.requests.FilesetUpdatesRequest; | ||
import org.apache.gravitino.dto.responses.DropResponse; | ||
import org.apache.gravitino.dto.responses.EntityListResponse; | ||
import org.apache.gravitino.dto.responses.FileLocationResponse; | ||
import org.apache.gravitino.dto.responses.FilesetResponse; | ||
import org.apache.gravitino.exceptions.FilesetAlreadyExistsException; | ||
import org.apache.gravitino.exceptions.NoSuchFilesetException; | ||
|
@@ -238,7 +241,22 @@ public boolean dropFileset(NameIdentifier ident) { | |
@Override | ||
public String getFileLocation(NameIdentifier ident, String subPath) | ||
throws NoSuchFilesetException { | ||
throw new UnsupportedOperationException("Not implemented"); | ||
checkFilesetNameIdentifier(ident); | ||
Namespace fullNamespace = getFilesetFullNamespace(ident.namespace()); | ||
|
||
CallerContext callerContext = CallerContext.CallerContextHolder.get(); | ||
Map<String, String> queryParams = Maps.newHashMap(); | ||
queryParams.put("subPath", subPath); | ||
FileLocationResponse resp = | ||
restClient.get( | ||
formatFilesetRequestPath(fullNamespace) + "/" + ident.name() + "/" + "fileLocation", | ||
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. Is it better to add the th subPath into the URL, not a queryParam? 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. Hi, I prefer to use the
|
||
queryParams, | ||
FileLocationResponse.class, | ||
callerContext != null ? callerContext.context() : Collections.emptyMap(), | ||
ErrorHandlers.filesetErrorHandler()); | ||
resp.validate(); | ||
|
||
return resp.getFileLocation(); | ||
} | ||
|
||
@VisibleForTesting | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,9 @@ public boolean dropFileset(NameIdentifier ident) { | |
|
||
@Override | ||
public String getFileLocation(NameIdentifier ident, String subPath) { | ||
throw new UnsupportedOperationException("Not implemented"); | ||
// The constraints of the name spec may be more strict than underlying catalog, | ||
// and for compatibility reasons, we only apply case-sensitive capabilities here. | ||
return dispatcher.getFileLocation(normalizeCaseSensitive(ident), subPath); | ||
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. I would suggest split the core part logic into another PR. In this PR, we only focus on client and server side API. Don't make the PR too big, which is hard to review. 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. Done, this PR has been split to only include changes with the Java Client and Server. |
||
} | ||
|
||
private NameIdentifier normalizeNameIdentifier(NameIdentifier ident) { | ||
|
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.
I think maybe we should encoding the subPath to avoid supported chars in the URL.
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.
Done